{"_id":"strong-trace-scopetracer","_rev":"53-a3956437367cc998356acea32d4bb365","name":"strong-trace-scopetracer","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"strong-trace-scopetracer","version":"1.0.0","keywords":["strongloop","scope","ast","esprima","tracing"],"author":{"name":"StrongLoop","email":"engineering@strongloop.com"},"license":{"url":"https://github.com/strongloop/strong-trace-scopetracer/blob/master/LICENSE","name":"StrongLoop"},"_id":"strong-trace-scopetracer@1.0.0","maintainers":[{"name":"setogit","email":"setogit@gmail.com"}],"homepage":"https://github.com/strongloop/strong-trace-scopetracer","bugs":{"url":"https://github.com/strongloop/strong-trace-scopetracer/issues"},"dist":{"shasum":"685f2e1e204d98c0da51b77983d2fa3c90d5c184","tarball":"https://registry.npmjs.org/strong-trace-scopetracer/-/strong-trace-scopetracer-1.0.0.tgz","integrity":"sha512-J57sQK9lD46GIAVxWWS6Wl772lZqQl1NGvSAmZwzSJC06HJn5qnEOWn41sexwMwUCSbP0ngYnQkT+m6RU/6KvQ==","signatures":[{"sig":"MEYCIQCSAuiI8e+1OQa0ksiri0PCuousUfFwgyY54DFh2hrDHQIhALPScWo/QjMKodNxtjMQh6vq+7PVBKBoSRlQWBSoK4fM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"scopetracer.js","_from":".","_shasum":"685f2e1e204d98c0da51b77983d2fa3c90d5c184","gitHead":"d831ea49f3e9dedee388964a49a0f0e43a591fb5","scripts":{"test":"node test/"},"_npmUser":{"name":"setogit","email":"setogit@gmail.com"},"repository":{"url":"git://github.com/strongloop/strong-trace-scopetracer.git","type":"git"},"_npmVersion":"2.5.1","description":"Modify JavaScript strings by applying mutation functions to each scope node in the AST","directories":{"test":"test"},"_nodeVersion":"0.10.33","dependencies":{"strong-trace-scopenodes":"~1.0.0"},"jshintConfig":{"asi":true,"node":true,"eqeqeq":false,"eqnull":true,"loopfunc":true,"validthis":true,"globalstrict":true},"devDependencies":{"tape":"^2.13.3"}},"1.0.2":{"name":"strong-trace-scopetracer","version":"1.0.2","keywords":["strongloop","scope","ast","esprima","tracing"],"author":{"name":"StrongLoop","email":"engineering@strongloop.com"},"license":{"url":"https://github.com/strongloop/strong-trace-scopetracer/blob/master/LICENSE","name":"StrongLoop"},"_id":"strong-trace-scopetracer@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-scopetracer","bugs":{"url":"https://github.com/strongloop/strong-trace-scopetracer/issues"},"dist":{"shasum":"add578eea7bfafb998362e168676afe69588134e","tarball":"https://registry.npmjs.org/strong-trace-scopetracer/-/strong-trace-scopetracer-1.0.2.tgz","integrity":"sha512-jIsKWcMAKMm66lSNDLQW+Q8dgRCynIStzL1iK5dfih9gXazvFW8444YOgdRS6IL+xKWP5CRP0ZwrF05S849H9w==","signatures":[{"sig":"MEUCIQCa+U4Q8Iw6Pd3we6bBZflBvzZ2cmPbFqw09dsjmj/QrAIgRi/r076CBB4g80gf+35sL39wzmDgBTExNxyeIDfeWhY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"scopetracer.js","_from":".","_shasum":"add578eea7bfafb998362e168676afe69588134e","gitHead":"4df19909fba886e2007411f5ac47962711f0cdfe","scripts":{"test":"node test/"},"_npmUser":{"name":"octet","email":"sam@strongloop.com"},"repository":{"url":"git://github.com/strongloop/strong-trace-scopetracer.git","type":"git"},"_npmVersion":"2.11.0","description":"Modify JavaScript strings by applying mutation functions to each scope node in the AST","directories":{"test":"test"},"_nodeVersion":"2.1.0","dependencies":{"strong-trace-scopenodes":"~1.0.0"},"jshintConfig":{"asi":true,"node":true,"eqeqeq":false,"eqnull":true,"loopfunc":true,"validthis":true,"globalstrict":true},"devDependencies":{"tape":"^2.13.3"}},"1.0.3":{"name":"strong-trace-scopetracer","version":"1.0.3","keywords":["strongloop","scope","ast","esprima","tracing"],"author":{"name":"StrongLoop","email":"engineering@strongloop.com"},"license":{"url":"https://github.com/strongloop/strong-trace-scopetracer/blob/master/LICENSE","name":"StrongLoop"},"_id":"strong-trace-scopetracer@1.0.3","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-scopetracer","bugs":{"url":"https://github.com/strongloop/strong-trace-scopetracer/issues"},"dist":{"shasum":"cd7e63c5ce42f6c0464eb8a9d7c3d54effbf204e","tarball":"https://registry.npmjs.org/strong-trace-scopetracer/-/strong-trace-scopetracer-1.0.3.tgz","integrity":"sha512-QwID+O0ruoN4ljH3poVd3ERaV1qx7waZE0Ui0WLJZ6zZOORPqkQXa665MtFLLjQUwbdP1vcLLCJ4svVH0oXlbw==","signatures":[{"sig":"MEUCIAjAYAaTbi/PuSx6iHqy1rBArKFZBM4F76J27dPks0leAiEA2oKvSX4tFtcRXuQYwkCi79wWx8A0H4d4UrJbBwdSU5c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"scopetracer.js","_from":".","_shasum":"cd7e63c5ce42f6c0464eb8a9d7c3d54effbf204e","gitHead":"fc2e0e9d886fac7df655b2ab04f503502e6cada3","scripts":{"test":"node test/"},"_npmUser":{"name":"octet","email":"sam@strongloop.com"},"repository":{"url":"git://github.com/strongloop/strong-trace-scopetracer.git","type":"git"},"_npmVersion":"2.11.0","description":"Modify JavaScript strings by applying mutation functions to each scope node in the AST","directories":{"test":"test"},"_nodeVersion":"2.1.0","dependencies":{"strong-trace-scopenodes":"~1.0.0"},"jshintConfig":{"asi":true,"node":true,"eqeqeq":false,"eqnull":true,"loopfunc":true,"validthis":true,"globalstrict":true},"devDependencies":{"tape":"^2.13.3"}}},"time":{"created":"2015-04-01T19:35:27.376Z","modified":"2026-04-14T15:16:30.326Z","1.0.0":"2015-04-01T19:35:27.376Z","1.0.2":"2015-06-03T20:49:21.632Z","1.0.3":"2015-06-03T23:54:42.679Z"},"bugs":{"url":"https://github.com/strongloop/strong-trace-scopetracer/issues"},"author":{"name":"StrongLoop","email":"engineering@strongloop.com"},"license":{"url":"https://github.com/strongloop/strong-trace-scopetracer/blob/master/LICENSE","name":"StrongLoop"},"homepage":"https://github.com/strongloop/strong-trace-scopetracer","keywords":["strongloop","scope","ast","esprima","tracing"],"repository":{"url":"git://github.com/strongloop/strong-trace-scopetracer.git","type":"git"},"description":"Modify JavaScript strings by applying mutation functions to each scope node in the AST","maintainers":[],"readme":"strong-trace-scopetracer\n=====\n\nModify scoped segments of JavaScript. Provide a mutating function and a filter test, and it will apply the mutator to scope blocks found in JavaScript strings.\n\nExample\n---\n\n```javascript\nvar ScopeTracer = require(\"strong-trace-scopetracer\")\n\nvar input = \"// some javascript!\\n\\\nfunction foo() {\\n\\\n  // In a function\\n\\\n  var abc = 'ABC'\\n\\\n  setTimeout(function () {\\n\\\n    console.log(abc)\\n\\\n  }, 10)\\n\\\n}\\n\\\nfoo()\\n\"\n\nfunction mutate(content) {\n  // We're putting things in single quotes, escape single quotes\n  var name = this.fnName.replace(/'/g, \"\\\\'\")\n  if (this.body.length === 0) {\n    return []\n  }\n  return [{insertion: \"console.log('entering \" + name + \"');\", pos: this.body[0].range[0]}]\n}\n\nfunction nodeTest() {\n  // Only functions, not outer enclosing scope.\n  return this.path.length > 0\n}\n\nvar tracer = ScopeTracer(mutate, nodeTest)\n\nvar output = tracer.transform(input)\n\nconsole.log(output)\n\n/*\n  // some javascript!\n  function foo() {\n    // In a function\n    console.log('entering foo');var abc = 'ABC'\n    setTimeout(function () {\n      console.log('entering foo>setTimeout() fn argument');console.log(abc)\n    }, 10)\n  }\n  foo()\n*/\n\neval(output)\n\n/*\n  entering foo\n  entering foo>setTimeout() fn argument\n  ABC\n*/\n\n```\n\nAPI\n===\n\n`var scopetracer = require(\"scopetracer\")(mutate[, nodeTest])`\n---\n\nCreates a tracer object that can be used to transform javascript strings.\n\n`mutate(content[, extra[, ...]])`\n---\n\nThe mutate function is called with the context of `this` being the [scopenodes](http://npm.im/scopenodes) node defining this scope.\n\nThis is usually a function, though will also include the outer Program enclosing scope.\n\nIt is an Esprima AST node with a couple of additions added by scopenodes.\n\nTo mutate the content, return an array of objects defining the insertions or replacements to make.\n\nInsertions are always safe, but it is up to you to make sure that replacements (using remove) do overlap other insertions or replacements.\n\n```js\n[\n  {\n    insertion: \"string to insert\",\n    pos: 200, // Position to insert, relative to the Esprima \"range\" e.g. this.range[0]\n    remove: 0, // optional, how many characters to remove from content prior to inserting\n    pri: 0, // optional: insertion priority in case of a `pos` tie. Lower pri inserts before higher pri.\n  },\n  {\n    // ... return as many mutations as you like\n  }\n]\n```\n\n`nodeTest(content[, extra[, ...]])`\n---\n\nThe test function is called with the same context as `mutate`.\n\nIt is simply expected to return `true` if `mutate` should be run or `false` if `mutate` is to be skipped for this node.\n\nThe default nodeTest if not defined is `function nodeTest() { return true; }` i.e. always call `mutate`.\n\n`scopetracer.transform(content[, extra[, ...]])`\n---\n\nExtract scope nodes, then transform them according to mutate and nodeTest.\n\nAny extra arguments will be added as arguments to `mutate` and `nodeTest`.\n\n\nSimilar Projects\n---\n\n[falafel](http://npm.im/falafel)\n\nLICENSE\n=======\n\nMIT\n","readmeFilename":"README.md"}