caller-path:获取调用者模块的路径

时间:2021-04-29 03:15:41
【文件属性】:
文件名称:caller-path:获取调用者模块的路径
文件大小:6KB
文件格式:ZIP
更新时间:2021-04-29 03:15:41
JavaScript 呼叫者路径 获取调用者函数的路径 重要提示:您必须使用'use strict'; 请在您的代码中使用该模块,以确保该模块正常工作,或者确保该模块是ESM模块,这是隐式严格的。 安装 $ npm install caller-path 用法 // foo.js const callerPath = require ( 'caller-path' ) ; module . exports = ( ) => { console . log ( callerPath ( ) ) ; //=> '/Users/sindresorhus/dev/unicorn/bar.js' } // bar.js const foo = require ( './foo' ) ; foo ( ) ; 如果由于某种原因undefined调用方的呼叫对象getFileName ,则它将返回undefined 。
【文件预览】:
caller-path-main
----index.test-d.ts(217B)
----.gitattributes(19B)
----.github()
--------funding.yml(47B)
--------security.md(179B)
--------workflows()
----fixture2.js(84B)
----test.js(598B)
----license(1KB)
----fixture3.js(144B)
----index.d.ts(1KB)
----fixture.js(135B)
----.npmrc(19B)
----.editorconfig(175B)
----.gitignore(23B)
----index.js(197B)
----readme.md(2KB)
----package.json(704B)

网友评论