{"id":19574699,"url":"https://github.com/stringparser/callsite-tracker","last_synced_at":"2026-06-10T13:31:33.366Z","repository":{"id":21110887,"uuid":"24411416","full_name":"stringparser/callsite-tracker","owner":"stringparser","description":"callsite-based information tool","archived":false,"fork":false,"pushed_at":"2014-09-29T13:52:36.000Z","size":224,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T11:47:47.987Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stringparser.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-24T10:52:47.000Z","updated_at":"2014-09-24T10:57:23.000Z","dependencies_parsed_at":"2022-08-25T12:41:03.115Z","dependency_job_id":null,"html_url":"https://github.com/stringparser/callsite-tracker","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Fcallsite-tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Fcallsite-tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Fcallsite-tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Fcallsite-tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stringparser","download_url":"https://codeload.github.com/stringparser/callsite-tracker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240840938,"owners_count":19866291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T06:43:31.091Z","updated_at":"2026-06-10T13:31:28.345Z","avatar_url":"https://github.com/stringparser.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# callsite-tracker [\u003cimg alt=\"progressed.io\" src=\"http://progressed.io/bar/99\" align=\"right\"/\u003e](https://github.com/fehmicansaglam/progressed.io)\n\n[\u003cimg alt=\"build\" src=\"http://img.shields.io/travis/stringparser/callsite-tracker/master.svg?style=flat-square\" align=\"left\"/\u003e](https://travis-ci.org/stringparser/callsite-tracker/builds)\n[\u003cimg alt=\"NPM version\" src=\"http://img.shields.io/npm/v/callsite-tracker.svg?style=flat-square\" align=\"right\"/\u003e](http://www.npmjs.org/package/callsite-tracker)\n\u003cbr\u003e\u003cbr\u003e\n\n[V8 stacktrace API](https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi)-based information tool.\n\u003cbr\u003e\n\n## install\n\n    npm install callsite-tracker\n\n## example\n\n```js\nvar tracker = require('callsite-tracker');\n\ndescribe('tracker', function (){\n\n  it('should give me info!', function origin(){\n\n    tracked = tracker(3, origin);\n    should(tracked.module).be('mocha');\n    console.log(tracked);\n  })\n})\n// Of course! this is a mocha test file!\n// its just to illustrate things better.\n```\n\nwhich will output\n\n```js\n{\n  module: 'mocha',\n  scope: 'mocha/lib',\n  path: '/home/jcm/npm/lib/node_modules/mocha/lib/runner.js',\n  isCore: false,\n  isNative: false,\n  site:\n   [ { receiver: [Object], fun: [Function: callFn], pos: 5274 },\n     { receiver: [Object], fun: [Function], pos: 5169 },\n     { receiver: [Object], fun: [Function], pos: 7711 } ] }\n```\n\n### documentation\n\n`var tracker = require('callsite-tracker')([frames, origin])`\n\n - `frames` if specified should be an `integer` bigger than `0` or `Infinity`.\n - `origin` if specified should be a function.\n - if no arguments, the default number of `frames` is `2` so the `origin` is the module itself. The returned stack is sliced by one.\n\nThe instance returned can walk through the recorded stack on a simple manner\n\n```js\nvar tracker = require('callsite-tracker');\nvar tracked = tracker(3);  // \u003c- creates the `tracker` instance\n\ntracked        // looks the same as the above output given\ntracked.get(1) // will move to the second element of the sites array\n               // and get the same information overriding\n               // whatever value the properties had\n```\n\n### tracker properties\n\nEach tracker instance has attached the stack trace with the callsites. I called each \"step\" of the `stack` a frame. So if you had\n\n```bash\ncallFn (/home/jcm/npm/lib/node_modules/mocha/lib/runnable.js:249:21)\nTest.Runnable.run (/home/jcm/npm/lib/node_modules/mocha/lib/runnable.js:242:7)\nRunner.runTest (/home/jcm/npm/lib/node_modules/mocha/lib/runner.js:373:10)\n```\neach line represents in my head a `callsite` frame. The first frame would be\nthat of the `caller`.\n\n - `module`: the module from which that frame comes from.\n - `scope` : the module's module (thats why is called scope you know).\n - `path`  : `__filename` of the frame.\n - `isCore` : was the `module` a `node`'s core module?\n - `isNative` : was a native `v8` module?\n - `sites` : an array of callsites.\n\n\nAll `tracker.sites` elements are callsites so they have their own `api`. Go and see the [avaliable methods](https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi) of the V8 stack trace api like:\n - `getLineNumber`\n - `getFileName`\n - `getEvalOrigin`\n - etc.\n\non that link.\n\n## why\n\nYou want to know stuff.\n\nBy default two frames are recorded, though you can even lower it to one providing a function from which start.\n\n### inspirated and based on\n\nIt serves for the same use cases implemented on this cool modules\n\n - [visionmedia `callsite`](https://github.com/visionmedia/callsite)\n - [sindresorhus `callsites`](https://github.com/sindresorhus/callsites)\n\nI've been using those a lot.\n\n## test\n\n    npm test\n\n### license\n\n[\u003cimg alt=\"LICENSE\" src=\"http://img.shields.io/npm/l/callsite-tracker.svg?style=flat-square\"/\u003e](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringparser%2Fcallsite-tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstringparser%2Fcallsite-tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringparser%2Fcallsite-tracker/lists"}