caller-id

WebJar for caller-id

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

caller-id
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

caller-id
WebJar for caller-id
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/pixelsandbytes/caller-id

Download caller-id

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/caller-id/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>caller-id</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/caller-id/
implementation 'org.webjars.npm:caller-id:0.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/caller-id/
implementation ("org.webjars.npm:caller-id:0.1.0")
'org.webjars.npm:caller-id:jar:0.1.0'
<dependency org="org.webjars.npm" name="caller-id" rev="0.1.0">
  <artifact name="caller-id" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='caller-id', version='0.1.0')
)
libraryDependencies += "org.webjars.npm" % "caller-id" % "0.1.0"
[org.webjars.npm/caller-id "0.1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : stack-trace jar [0.0.7,0.1)

Project Modules

There are no modules declared in this project.

caller-id

A utility for getting information on the caller of a function in node.js

Build Status

Installation

  1. Add caller-id as a dependency to your project’s package.json
  2. Run npm install

Usage Examples

getData

getData() can be used to get raw data about a function's caller

var callerId = require('caller-id');

// 1. Function calling another function
function foo() {
    bar();
}
function bar() {
    var caller = callerId.getData();
    /*
    caller = {
        typeName: 'Object',
        functionName: 'foo',
        filePath: '/path/of/this/file.js',
        lineNumber: 5,
        topLevelFlag: true,
        nativeFlag: false,
        evalFlag: false
    }
    */
}

// 2. Method in a class calling a function
function Lorem() {}
Lorem.prototype.ipsum = function() {
    baz();
}
function baz() {
    var caller = callerId.getData();
    /*
    caller = {
        typeName: 'Lorem',
        functionName: 'Lorem.ipsum',
        methodName: 'ipsum',
        filePath: '/path/of/this/file.js',
        lineNumber: 25,
        topLevelFlag: false,
        nativeFlag: false,
        evalFlag: false
    }
    */
}

// 3. Function in an eval calling another function
function func() {
    var caller = callerId.getData();
    /*
    caller = {
        typeName: 'Object',
        functionName: 'evil',
        lineNumber: 2,
        topLevelFlag: true,
        nativeFlag: false,
        evalFlag: true,
        evalOrigin: 'eval at <anonymous> (/path/of/this/file.js:58:7)'
    }
    */
}
eval('(function evil() {' + '\\n' +
    'func();' + '\\n' +
    '})();');

getString

getString() returns a brief string representing a function's caller

var callerId = require('caller-id');

function myFunction() {
    var callerString = callerId.getString();
}

Using the same examples as above, getString() returns the following:

  1. foo
  2. Lorem.ipsum
  3. (eval)evil

getDetailedString

getDetailedString() returns a more detailed string representing a function's caller

var callerId = require('caller-id');

function myFunction() {
    var detailedCallerString = callerId.getDetailedString();
}

Using the same examples as above, getDetailedString() returns the following:

  1. foo at /path/of/this/file.js:5
  2. Lorem.ipsum at /path/of/this/file.js:25
  3. eval at (/path/of/this/file.js:58:7)

Versions

Version
0.1.0