{"name":"stack-mapper","version":"0.1.4","description":"Initialize it with a source map, then feed it error stacks to have the trace locations mapped to the original files.","main":"index.js","scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"git://github.com/thlorenz/stack-mapper.git"},"homepage":"https://github.com/thlorenz/stack-mapper","dependencies":{"stack-trace":"0.0.7","isarray":"0.0.1","array-map":"0.0.0","foreach-shim":"~0.1.1","source-map-cjs":"~0.1.31"},"devDependencies":{"tape":"~1.0.4","convert-source-map":"~0.3.3","browserify":"~3.14.1","tap":"~0.4.6"},"keywords":["sourcemap","source-map","error","stack","trace","map"],"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"license":{"type":"MIT","url":"https://github.com/thlorenz/stack-mapper/blob/master/LICENSE"},"engine":{"node":">=0.6"},"testling":{"files":"test/prepared/*.js","browsers":["ie/6..latest","firefox/22..latest","firefox/nightly","chrome/26..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"bugs":{"url":"https://github.com/thlorenz/stack-mapper/issues"},"_id":"stack-mapper@0.1.4","dist":{"shasum":"9501951c51b962be4414d118f16461551a75801f","tarball":"http://registry-npm.ywwl.com/stack-mapper/download/stack-mapper-0.1.4.tgz","integrity":"sha512-9cgNJD7v2NhrtRIA8b0vO2xS3qJjtJj4Sy4FMIqrKyfSweSdNJqZ9bwWJhkPFb1J4v8d6VjmnOagbEbg/y70wA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGWrzv0DQD3ZPCu/SXpC+EOpDDOWdUh0Qt0hznse/Q1WAiEAtkTMamo27vswYCqx1h2vpOw/bgmErQIlOAP3afDUrwY="}],"size":7089,"noattachment":false,"key":"/stack-mapper/-/stack-mapper-0.1.4.tgz"},"_from":".","_npmVersion":"1.3.22","_npmUser":{"name":"thlorenz","email":"thlorenz@gmx.de"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"directories":{},"readme":"# stack-mapper [![build status](https://secure.travis-ci.org/thlorenz/stack-mapper.png)](http://travis-ci.org/thlorenz/stack-mapper)\n\n[![testling badge](https://ci.testling.com/thlorenz/stack-mapper.png)](https://ci.testling.com/thlorenz/stack-mapper)\n\nInitialize it with a source map, then feed it error stacks to have the trace locations mapped to the original files.\n\n```js\nvar stackMapper = require('stack-mapper');\n\n// it is up to you to create stack-mapper compatible frame objects\n// this will depend on your environment\nvar inframes = [{\n  filename: '/full/path/to/bundle.js',\n  line: 5,\n  column: 10\n}, {\n  filename: '/full/path/to/bundle.js',\n  line: 9,\n  column: 10\n}, {\n  filename: '/full/path/to/bundle.js',\n  line: 20,\n  column: 12\n}, {\n  filename: '/full/path/to/bundle.js',\n  line: 22,\n  column: 10,\n}, {\n  filename: '/Users/thlorenz/dev/js/projects/stack-mapper/test/twofiles.js',\n  line: 18,\n  column: 21\n}];\n\nvar map = { version: 3,\n  file: 'generated.js',\n  sources:\n   [ '/Users/thlorenz/dev/js/projects/stack-mapper/test/twofiles/barbar.js',\n     '/Users/thlorenz/dev/js/projects/stack-mapper/test/twofiles/main.js' ],\n  names: [],\n  mappings: ';AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA',\n  sourcesContent:\n   [ '\\'use strict\\';\\n\\nfunction foobar() {\\n  return new Error();\\n}\\n\\nvar go = module.exports = function () {\\n  return foobar();  \\n};\\n',\n     '\\'use strict\\';\\n\\nvar barbar = require(\\'./barbar\\');\\n\\nmodule.exports = function main() {\\n  var a = 1;\\n  function bar() {\\n    return barbar();\\n  }\\n  return bar();\\n}\\n' ] }\n\nvar sm = stackMapper(map);\nvar frames = sm.map(inframes);\n\nconsole.log(frames);\n```\n\n#### Output\n\n```\n[{\n    filename: '/Users/thlorenz/dev/js/projects/stack-mapper/test/twofiles/barbar.js',\n    line: 4,\n    column: 10\n}, {\n    filename: '/Users/thlorenz/dev/js/projects/stack-mapper/test/twofiles/barbar.js',\n    line: 8,\n    column: 10\n}, {\n ...\n}]\n```\n\n## Obtaining the source map\n\nYou need to pass the source map as an object as shown in the example. If your source map happens to be in a different\nformat, please use the [convert-source-map](https://github.com/thlorenz/convert-source-map) module in order to convert it.\n\n[browserify](https://github.com/substack/node-browserify) attaches source maps to the bottom of the bundle if the `--debug` flag is set, here is an example how to\nobtain and convert it to use with `stack-mapper`.\n\n```js\nvar browserify =  require('browserify')\n  , convert    =  require('convert-source-map')\n\nbrowserify()\n  .require(entry)\n  .bundle({ debug: true }, function (err, src) {\n    if (err) return cb(err);\n\n    var map = convert.fromSource(src).toObject();\n  });\n```\n\n## Installation\n\n    npm install stack-mapper\n\n## API\n\n### stackMapper(sourcemap)\n\n```\n/**\n * Returns a Stackmapper that will use the given source map to map error trace locations.\n * \n * @name stackMapper\n * @function\n * @param {Object} sourcemap source map for the generated file\n * @return {StackMapper} stack mapper for the particular source map\n */\n```\n\n### stackMapper.map(frames, includeSource)\n\n```\n/**\n * Maps the trace statements of the given error stack and replaces locations\n * referencing code in the generated file with the locations inside the original files.\n * \n * @name map\n * @function\n * @param {Array} array of callsite objects (see readme for details about Callsite object)\n * @param {boolean} includeSource if set to true, the source code at the first traced location is included\n * @return {Array.<Object>} info about the error stack with adapted locations, each with the following properties\n *    - filename: original filename \n *    - line: origial line in that filename of the trace\n *    - column: origial column on that line of the trace\n */\n```\n\n## Stack Frames\n\nThe frames array passed to stackMapper.map should contain at least the following items\n\n* filename\n* line\n* column\n\n## License\n\nMIT\n","publish_time":1388266560011,"_cnpm_publish_time":1388266560011,"dist-tags":{"latest":"0.2.2"}}