✏️ 编辑:index.js
路径:
/home/boguraj1/public_html/jobsite/node_modules/parent-module/index.js
大小:641 B · 修改:2022-11-21 20:10:38 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
'use strict'; const callsites = require('callsites'); module.exports = filepath => { const stacks = callsites(); if (!filepath) { return stacks[2].getFileName(); } let seenVal = false; // Skip the first stack as it's this function stacks.shift(); for (const stack of stacks) { const parentFilepath = stack.getFileName(); if (typeof parentFilepath !== 'string') { continue; } if (parentFilepath === filepath) { seenVal = true; continue; } // Skip native modules if (parentFilepath === 'module.js') { continue; } if (seenVal && parentFilepath !== filepath) { return parentFilepath; } } };
💾 保存
取消
保存为 UTF-8,换行统一为 LF