{"_id":"caller-id","_rev":"300139","name":"caller-id","description":"A utility for getting information on the caller of a function in node.js","dist-tags":{"latest":"0.1.0"},"maintainers":[{"name":"pixelsandbytes","email":"pxandbytes@gmail.com"}],"time":{"modified":"2021-06-03T19:04:50.000Z","created":"2013-11-05T03:18:17.049Z","0.1.0":"2013-11-05T03:18:17.049Z"},"users":{"tandrewnichols":true,"byteshiva":true,"8code":true,"winmintun":true,"charlie.wilson":true},"author":{"name":"Pixels & Bytes","email":"pxandbytes@gmail.com"},"repository":{"type":"git","url":"https://github.com/pixelsandbytes/caller-id.git"},"versions":{"0.1.0":{"name":"caller-id","version":"0.1.0","author":{"name":"Pixels & Bytes","email":"pxandbytes@gmail.com"},"description":"A utility for getting information on the caller of a function in node.js","repository":{"type":"git","url":"https://github.com/pixelsandbytes/caller-id.git"},"main":"./lib/caller-id.js","keywords":["function","method","call","caller","stack","trace","stacktrace","caller-id"],"devDependencies":{"grunt":"~0.4.1","grunt-cli":"~0.1.9","grunt-contrib-jshint":"~0.7.1","grunt-simple-mocha":"~0.4.0","should":"~2.0.2"},"dependencies":{"stack-trace":"~0.0.7"},"engines":{"node":">=0.8"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/pixelsandbytes/caller-id/issues"},"_id":"caller-id@0.1.0","dist":{"shasum":"59bdac0893d12c3871408279231f97458364f07b","size":4087,"noattachment":false,"key":"/caller-id/-/caller-id-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/caller-id/download/caller-id-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"pixelsandbytes","email":"pxandbytes@gmail.com"},"maintainers":[{"name":"pixelsandbytes","email":"pxandbytes@gmail.com"}],"directories":{},"publish_time":1383621497049,"_cnpm_publish_time":1383621497049,"_hasShrinkwrap":false}},"readme":"# caller-id\r\n\r\nA utility for getting information on the caller of a function in node.js\r\n\r\n[![Build Status](https://travis-ci.org/pixelsandbytes/caller-id.png?branch=master)](https://travis-ci.org/pixelsandbytes/caller-id)\r\n\r\n## Installation\r\n1. Add `caller-id` as a dependency to your project’s `package.json`\r\n2. Run `npm install`\r\n\r\n## Usage Examples\r\n\r\n### `getData`\r\n\r\n`getData()` can be used to get raw data about a function's caller\r\n\r\n    var callerId = require('caller-id');\r\n\r\n    // 1. Function calling another function\r\n    function foo() {\r\n        bar();\r\n    }\r\n    function bar() {\r\n        var caller = callerId.getData();\r\n        /*\r\n        caller = {\r\n            typeName: 'Object',\r\n            functionName: 'foo',\r\n            filePath: '/path/of/this/file.js',\r\n            lineNumber: 5,\r\n            topLevelFlag: true,\r\n            nativeFlag: false,\r\n            evalFlag: false\r\n        }\r\n        */\r\n    }\r\n\r\n    // 2. Method in a class calling a function\r\n    function Lorem() {}\r\n    Lorem.prototype.ipsum = function() {\r\n        baz();\r\n    }\r\n    function baz() {\r\n        var caller = callerId.getData();\r\n        /*\r\n        caller = {\r\n            typeName: 'Lorem',\r\n            functionName: 'Lorem.ipsum',\r\n            methodName: 'ipsum',\r\n            filePath: '/path/of/this/file.js',\r\n            lineNumber: 25,\r\n            topLevelFlag: false,\r\n            nativeFlag: false,\r\n            evalFlag: false\r\n        }\r\n        */\r\n    }\r\n\r\n    // 3. Function in an eval calling another function\r\n    function func() {\r\n        var caller = callerId.getData();\r\n        /*\r\n        caller = {\r\n            typeName: 'Object',\r\n            functionName: 'evil',\r\n            lineNumber: 2,\r\n            topLevelFlag: true,\r\n            nativeFlag: false,\r\n            evalFlag: true,\r\n            evalOrigin: 'eval at <anonymous> (/path/of/this/file.js:58:7)'\r\n        }\r\n        */\r\n    }\r\n    eval('(function evil() {' + '\\\\n' +\r\n        'func();' + '\\\\n' +\r\n        '})();');\r\n\r\n### `getString`\r\n\r\n`getString()` returns a brief string representing a function's caller\r\n\r\n    var callerId = require('caller-id');\r\n\r\n    function myFunction() {\r\n        var callerString = callerId.getString();\r\n    }\r\n\r\nUsing the same examples as above, `getString()` returns the following:\r\n\r\n1.  foo\r\n2.  Lorem.ipsum\r\n3.  (eval)evil\r\n\r\n### `getDetailedString`\r\n\r\n`getDetailedString()` returns a more detailed string representing a function's caller\r\n\r\n    var callerId = require('caller-id');\r\n\r\n    function myFunction() {\r\n        var detailedCallerString = callerId.getDetailedString();\r\n    }\r\n\r\nUsing the same examples as above, `getDetailedString()` returns the following:\r\n\r\n1.  foo at /path/of/this/file.js:5\r\n2.  Lorem.ipsum at /path/of/this/file.js:25\r\n3.  eval at <anonymous> (/path/of/this/file.js:58:7)","_attachments":{},"readmeFilename":"README.md","bugs":{"url":"https://github.com/pixelsandbytes/caller-id/issues"},"license":"MIT"}