0.2.0 • Published 2 years ago

@lunjs/caller-path v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@lunjs/caller-path

Get the path of the caller function

Installation

npm install @lunjs/caller-path

Usage

  • Example 1
// main.js
const { callerPath } = require('@lunjs/cller-path');
function main() {
  console.log(callerPath());
}
main(); // => /full/path/to/main.js
  • Example 2
// foo.js
const { callerPath } = require('@lunjs/cller-path');
function foo() {
  console.log(callerPath({ shift: 1 }))
}
module.exports = {
  foo
};
// bar.js
const { foo } = require('./foo');
foo(); // => /full/path/to/bar.js

API

callerPath(options?)

  • shift
    • Type: number
    • Default: 0
  • excludeFileNames
    • Type: Array<string|RegExp>
    • Default: undefined
  • excludeFunctionNames
    • Type: Array<string|RegExp>
    • Default: undefined
  • debug
    • Type: boolean
    • Default: false

License

MIT