{"_id":"strong-trace-scopenodes","_rev":"54-37eff9b33de5c5ec25fb33b6daeb6adc","name":"strong-trace-scopenodes","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"strong-trace-scopenodes","version":"1.0.0","keywords":["strongloop","scope","ast","esprima","functions"],"author":{"name":"StrongLoop","email":"engineering@strongloop.com"},"license":{"url":"https://github.com/strongloop/strong-trace-scopenodes/blob/master/LICENSE","name":"StrongLoop"},"_id":"strong-trace-scopenodes@1.0.0","maintainers":[{"name":"setogit","email":"setogit@gmail.com"}],"homepage":"https://github.com/strongloop/strong-trace-scopenodes","bugs":{"url":"https://github.com/strongloop/strong-trace-scopenodes/issues"},"dist":{"shasum":"6ba40671a9d5153c39db5b52b7d6940adbb03937","tarball":"https://registry.npmjs.org/strong-trace-scopenodes/-/strong-trace-scopenodes-1.0.0.tgz","integrity":"sha512-c5q+NlqUYJqHg4rmlkHLBOpPRvQI51hGrlrhfXpHBLWuSdXF7Od3kqwk7IU9RNhoq8NxKQXFvIqM4lRmMZ9WFA==","signatures":[{"sig":"MEUCICk4oWlsVUN4F6bxpQVLMHHatMK2ZXkiLVgW/uhxa5gTAiEAwxqqeySAue++BK1YKbprIm6r6txwMIKo5DKnX3/T0N4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"scopenodes.js","_from":".","_shasum":"6ba40671a9d5153c39db5b52b7d6940adbb03937","gitHead":"8c3e5f3b390fee3dd1d13f8277b992d671432267","scripts":{"test":"node test/"},"_npmUser":{"name":"setogit","email":"setogit@gmail.com"},"repository":{"url":"git://github.com/strongloop/strong-trace-scopenodes.git","type":"git"},"_npmVersion":"2.5.1","description":"Extract AST nodes from a js string that define scope","directories":{"test":"test"},"_nodeVersion":"0.10.33","dependencies":{"esprima":"^1.2.2","estraverse":"^1.5.0"},"jshintConfig":{"asi":true,"node":true,"eqeqeq":false,"eqnull":true,"globalstrict":true},"devDependencies":{"tape":"^2.13.3"}},"1.0.1":{"name":"strong-trace-scopenodes","version":"1.0.1","keywords":["strongloop","scope","ast","esprima","functions"],"author":{"name":"StrongLoop","email":"engineering@strongloop.com"},"license":{"url":"https://github.com/strongloop/strong-trace-scopenodes/blob/master/LICENSE","name":"StrongLoop"},"_id":"strong-trace-scopenodes@1.0.1","maintainers":[{"name":"setogit","email":"setogit@gmail.com"},{"name":"octet","email":"sam@strongloop.com"},{"name":"rmg","email":"r.m.graham@gmail.com"},{"name":"kraman","email":"kraman@strongloop.com"},{"name":"strongloop","email":"callback@strongloop.com"}],"homepage":"https://github.com/strongloop/strong-trace-scopenodes","bugs":{"url":"https://github.com/strongloop/strong-trace-scopenodes/issues"},"dist":{"shasum":"df6529cb74fc266274306459fe768685e8a851cf","tarball":"https://registry.npmjs.org/strong-trace-scopenodes/-/strong-trace-scopenodes-1.0.1.tgz","integrity":"sha512-ihCa3FTCtdQtT7wuMK3tXJN2v3Wzm4p9TSYJcpVdyh5qfYG2WoLkRFSrlThfEWQ9zoY9VnD8gsTsYuhF19qpsg==","signatures":[{"sig":"MEYCIQClty3pU8PVMrGaPiehLPNjOQysIG8aDxM8UEPurkRi/AIhAPamQRyIMQdjtgGucr+5GPaVmymz9nVGqBXkuebc3uA7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"scopenodes.js","_from":".","_shasum":"df6529cb74fc266274306459fe768685e8a851cf","gitHead":"14e49ba681361e9528ad71809f59495fccf0a254","scripts":{"test":"node test/"},"_npmUser":{"name":"octet","email":"sam@strongloop.com"},"repository":{"url":"git://github.com/strongloop/strong-trace-scopenodes.git","type":"git"},"_npmVersion":"2.11.0","description":"Extract AST nodes from a js string that define scope","directories":{"test":"test"},"_nodeVersion":"2.1.0","dependencies":{"esprima":"^1.2.2","estraverse":"^1.5.0"},"jshintConfig":{"asi":true,"node":true,"eqeqeq":false,"eqnull":true,"globalstrict":true},"devDependencies":{"tape":"^2.13.3"}},"1.0.2":{"name":"strong-trace-scopenodes","version":"1.0.2","keywords":["strongloop","scope","ast","esprima","functions"],"author":{"name":"StrongLoop","email":"engineering@strongloop.com"},"license":{"url":"https://github.com/strongloop/strong-trace-scopenodes/blob/master/LICENSE","name":"StrongLoop"},"_id":"strong-trace-scopenodes@1.0.2","maintainers":[{"name":"setogit","email":"setogit@gmail.com"},{"name":"octet","email":"sam@strongloop.com"},{"name":"rmg","email":"r.m.graham@gmail.com"},{"name":"kraman","email":"kraman@strongloop.com"},{"name":"strongloop","email":"callback@strongloop.com"}],"homepage":"https://github.com/strongloop/strong-trace-scopenodes","bugs":{"url":"https://github.com/strongloop/strong-trace-scopenodes/issues"},"dist":{"shasum":"aea63a46abc36813666cac175fb8931d2ea30426","tarball":"https://registry.npmjs.org/strong-trace-scopenodes/-/strong-trace-scopenodes-1.0.2.tgz","integrity":"sha512-XTfzX2/uctghFaMdR9GKVBuQ2JxYFZ5AJP18rUQqoNG5ILOZ4xC21sDoMCHZaWqOQlc8meZ9Sy9sUisfyU8EOA==","signatures":[{"sig":"MEQCIE2hCJNxWPxwkK7/3LcgcJZYuXMtlC0uWDgyJ/8ZewqtAiBuoI+p1jlBEpXEcjRY/8oHMxbu0gmL9esUXOKGKqzuCA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"scopenodes.js","_from":".","_shasum":"aea63a46abc36813666cac175fb8931d2ea30426","gitHead":"41423bd457b0e0d33dd8d08c0b4a2ed3698dab00","scripts":{"test":"node test/"},"_npmUser":{"name":"octet","email":"sam@strongloop.com"},"repository":{"url":"git://github.com/strongloop/strong-trace-scopenodes.git","type":"git"},"_npmVersion":"2.11.0","description":"Extract AST nodes from a js string that define scope","directories":{"test":"test"},"_nodeVersion":"2.1.0","dependencies":{"esprima":"^1.2.2","estraverse":"^1.5.0"},"jshintConfig":{"asi":true,"node":true,"eqeqeq":false,"eqnull":true,"globalstrict":true},"devDependencies":{"tape":"^2.13.3"}}},"time":{"created":"2015-04-01T19:33:16.521Z","modified":"2026-04-14T15:16:29.425Z","1.0.0":"2015-04-01T19:33:16.521Z","1.0.1":"2015-06-03T20:49:17.365Z","1.0.2":"2015-06-03T23:54:33.113Z"},"bugs":{"url":"https://github.com/strongloop/strong-trace-scopenodes/issues"},"author":{"name":"StrongLoop","email":"engineering@strongloop.com"},"license":{"url":"https://github.com/strongloop/strong-trace-scopenodes/blob/master/LICENSE","name":"StrongLoop"},"homepage":"https://github.com/strongloop/strong-trace-scopenodes","keywords":["strongloop","scope","ast","esprima","functions"],"repository":{"url":"git://github.com/strongloop/strong-trace-scopenodes.git","type":"git"},"description":"Extract AST nodes from a js string that define scope","maintainers":[],"readme":"strong-trace-scopenodes\n=====\n\nFind the AST nodes from a string of JavaScript that define scope. E.g. The outer Program scope and functions.\n\nExample\n---\n\n```javascript\nvar scopenodes = require(\"strong-trace-scopenodes\")\nvar fs = require(\"fs\")\n\nvar filename = process.argv[2] || \"./test/lib/nested.js\"\nvar content = fs.readFileSync(filename).toString()\nvar out = scopenodes(content)\nconsole.log(out)\n\n/*\n  [ { type: 'Program',\n    body: [ [Object], [Object] ],\n    range: [ 0, 116 ],\n    loc: { start: [Object], end: [Object] },\n    path: [],\n    parent: null },\n  { type: 'BlockStatement',\n    body: [ [Object] ],\n    range: [ 21, 69 ],\n    loc: { start: [Object], end: [Object] },\n    path: [ [Object] ],\n    parent:\n     { type: 'FunctionDeclaration',\n       id: [Object],\n       params: [Object],\n  ...\n\n*/\n\n```\n\nAPI\n===\n\n`scopenodes(jsString)`\n---\n\nWill return a list of nodes from an AST (Esprima) that define scoped blocks of the provided JavaScript string.\n\nIt will add some properties to each node:\n  * fnName: An attempted guess at the function name. It should always be right if the function is named.\n  * path: A list of outer scopes in order of scopechain for this node\n  * parent: For a FunctionDeclaration or FunctionExpression node, the declaration or expression.\n  * isStrict: a boolean value as to whether *THIS SCOPE SPECIFICALLY* has declared strict mode. Does not account for inherited strict mode.\n\nNaming generally works like the following, and may change as we go:\n  1. If the function is named, use that name.\n  2. If it is an assigment, use what it is assigned to\n  3. If it is a function call argument or `new` argument, call it \"fnName() fn argument\" where fnName is the function called.\n  4. If the call is complex (contains a parenthesis) attempt to remove all but the last bit. (e.g. foo.map(...).sort(...).forEach(...) will become \".forEach() fn argument\")\n  5. If the function looks like listener for an on event (e.g. `foo.on('exit', ...))` call it `foo.on 'exit' listener`\n  6. In any of the above cases if that name has already been assigned, start indexing the names like so: foo, foo{2}, foo{3}, etc.\n\nNaming nests with scope, so if you have code such as this:\n\n```js\nfunction foo() {\n  function bar() {\n    // ...\n  }\n}\n```\n\nThe two functions would be named `foo` and `foo>bar` denoting that this bar is the one defind in the scope of `foo`.\n\n","readmeFilename":"README.md"}