{"name":"stack-chain","description":"API for combining call site modifiers","version":"0.3.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./stack-chain.js","scripts":{"test":"tap ./test/simple"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/stack-chain.git"},"keywords":["stack","chain","trace","call site","concat","format"],"devDependencies":{"tap":"0.4.x"},"license":"MIT","engines":{"node":"0.10 || 0.11","npm":"1"},"bugs":{"url":"https://github.com/AndreasMadsen/stack-chain/issues"},"_id":"stack-chain@0.3.0","dist":{"shasum":"b47e449c4090595ccf0d1e6531a5090b82ca2ffb","tarball":"http://registry-npm.ywwl.com/stack-chain/download/stack-chain-0.3.0.tgz","integrity":"sha512-Ni8suuinUNDOFoMU8294Sy5Z3QUAbGHALQntAfCaFA4SJnhr6/H31l9hB8K9KYCAmd5F7/sN49KWgyvJ+Ks8Nw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHLXH48V5osOlBc4+dBBbHwTiO/Qh6YmSevOLi3o9WPaAiAJ0/uAM5IqeT4P+gPeng8+kS8xFiNnJti9pxKk5PMX3A=="}],"size":4631,"noattachment":false,"key":"/stack-chain/-/stack-chain-0.3.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{},"readme":"# stack-chain [![Build Status](https://secure.travis-ci.org/AndreasMadsen/stack-chain.png)](http://travis-ci.org/AndreasMadsen/stack-chain)\n\n> API for combining call site modifyers\n\n## Installation\n\n```sheel\nnpm install stack-chain\n```\n## API documentation\n\n```JavaScript\nvar chain = require('stack-chain');\n```\n\nWhen the `Error.stack` getter is executed, the `stack-chain` will perform the\nfollowing:\n\n1. execute the `modifiers` attached by `chain.extend`.\n2. execute the `modifiers` attached by `chain.filter`.\n3. execute the `formater` set by `chain.format.replace`.\n\n### chain.extend.attach(modifier)\n### chain.filter.attach(modifier)\n\nWill modify the callSite array. Note you shouldn't format the stack trace.\n\nThe `modifier` is a function there takes two arguments `error` and `frames`.\n\n* `error` is the `Error` object.\n* `frames` is an array of `callSite` objects, see\n  [v8 documentation](https://github.com/v8/v8/wiki/Stack-Trace-API)\n  for details.\n\nWhen the `modifier` is done, it should `return` a modified `frames` array.\n\n```JavaScript\nchain.filter.attach(function (error, frames) {\n\n    // Filter out traces related to this file\n    var rewrite = frames.filter(function (callSite) {\n      return callSite.getFileName() !== module.filename;\n    });\n\n    return rewrite;\n});\n```\n\n### chain.extend.deattach(modifier)\n### chain.filter.deattach(modifier)\n\nRemoves a `modifier` function from the list of `modifiers`.\n\n```JavaScript\nvar modifier = function () {};\n\n// Attach modifier function\nchain.extend.attach(modifier);\n\n// Deattach modifier function\nchain.extend.deattach(modifier);\n```\n\n### chain.format.replace(formater)\n\nReplaces the default v8 `formater`. The new `formater` takes a two arguments\n`error` and `frames`.\n\n* `error` is the `Error` object.\n* `callSites` is an array of `callSite` objects, see\n  [v8 documentation](https://github.com/v8/v8/wiki/Stack-Trace-API)\n  for details.\n\nWhen the `formater` is done, it should `return` a `string`. The `string` will\nwhat `Error.stack` returns.\n\n```JavaScript\nchain.format.replace(function (error, frames) {\n  var lines = [];\n\n  lines.push(error.toString());\n\n  for (var i = 0; i < frames.length; i++) {\n    lines.push(\"    at \" + frames[i].toString());\n  }\n\n  return lines.join(\"\\n\");\n});\n```\n\n### chain.format.restore()\n\nWill restore the default v8 `formater`. Note that dude to the nature of v8\n`Error` objects, if one of the getters `Error.stack` or `Error.callSite` has\nalready executed, the value of `Error.stack` won't change.\n\n### chain.callSite([options])\n\nThis will return the unmodified `callSite` array from the current tick. This\nis a performance shortcut, as it does not require generating the `.stack`\nstring. This behaviour is different from the `Error().callSite` properties.\n\nWhile this is mostly generating `callSite` in hot code, it can be useful to\ndo some modification on the array. The `options` object, supports the following:\n\n```javascript\noptions = {\n  // (default false) run the extenders on the callSite array.\n  extend: true,\n\n  // (default false) run the filters on the callSite array.\n  filter: true,\n\n  // (default 0) before running extend or filter methods, slice of some of the\n  // end. This can be useful for hiding the place from where you called this\n  // function.\n  slice: 2\n}\n```\n\n### chain.originalCallSite(error)\n\nReturns the original `callSite` array.\n\n### chain.mutatedCallSite(error)\n\nReturns the mutated `callSite` array, that is after `extend` and `filter`\nis applied. The array will not exceed the `Error.stackTraceLimit`.\n\n### Error.stackTraceLimit\n\nThis limites the size of the `callSites` array. The default value is 10, and\ncan be set to any positive number including `Infinity`. See\n[v8 documentation](https://github.com/v8/v8/wiki/Stack-Trace-API)\nfor details.\n\n## License\n\n**The software is license under \"MIT\"**\n\n> Copyright (c) 2012 Andreas Madsen\n>\n> Permission is hereby granted, free of charge, to any person obtaining a copy\n> of this software and associated documentation files (the \"Software\"), to deal\n> in the Software without restriction, including without limitation the rights\n> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n> copies of the Software, and to permit persons to whom the Software is\n> furnished to do so, subject to the following conditions:\n>\n> The above copyright notice and this permission notice shall be included in\n> all copies or substantial portions of the Software.\n>\n> THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n> THE SOFTWARE.\n","publish_time":1378132527180,"_cnpm_publish_time":1378132527180,"dist-tags":{"latest":"2.0.0"}}