forked from enviPath/enviPy
Current Dev State
This commit is contained in:
31
static/js/ketcher2/node_modules/parent-module/index.js
generated
vendored
Normal file
31
static/js/ketcher2/node_modules/parent-module/index.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
var callsites = require('callsites');
|
||||
|
||||
module.exports = function (filepath) {
|
||||
var stacks = callsites();
|
||||
|
||||
if (!filepath) {
|
||||
return stacks[2].getFileName();
|
||||
}
|
||||
|
||||
var seenVal = false;
|
||||
|
||||
// skip the first stack as it's this function
|
||||
for (var i = 1; i < stacks.length; i++) {
|
||||
var parentFilepath = stacks[i].getFileName();
|
||||
|
||||
if (parentFilepath === filepath) {
|
||||
seenVal = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip native modules
|
||||
if (parentFilepath === 'module.js') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (seenVal && parentFilepath !== filepath) {
|
||||
return parentFilepath;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user