Skip to content

stringparser/callers-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

callers-module progressed.io

build NPM version

V8 stacktrace API based caller's module information

install

npm install --save callers-module

usage

var path = require('path');
var callersModule = require('callers-module');

// $ mocha test/fileName.js
module.exports = function(){
  it('should give callers module', function(){
    console.log(callersModule());
    // => {
    //    module : 'mocha',
    //     scope : 'mocha/lib',
    //      path : 'node_modules/mocha/lib/runnable.js',
    //  location : 'node_modules/mocha/lib/runnable.js:249:21'
    // };
  })
}

documentation

require('callers-module')([frames, origin])

  • frames if specified should be an integer bigger than 0 or Infinity.
  • origin if specified should be a function.
  • if no arguments, the default number of frames is 2 so the origin is the module itself. The stack is sliced by one.

why

You would like to set how many frames are recorded (Error.stackTraceLimit) and from which function the stack should be traced back (Error.captureStackTrace).

By default two frames are recorded, though you can even lower it to one providing a function from which start.

inspirated by

It serves for the same use cases implemented on this cool modules

test

npm test

license

LICENSE

About

caller's module information

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published