{
  "name": "source-map",
  "description": "Generates and consumes source maps",
  "version": "0.1.31",
  "homepage": "https://github.com/mozilla/source-map",
  "author": {
    "name": "Nick Fitzgerald",
    "email": "nfitzgerald@mozilla.com"
  },
  "contributors": [
    {
      "name": "Tobias Koppers",
      "email": "tobias.koppers@googlemail.com"
    },
    {
      "name": "Duncan Beevers",
      "email": "duncan@dweebd.com"
    },
    {
      "name": "Stephen Crane",
      "email": "scrane@mozilla.com"
    },
    {
      "name": "Ryan Seddon",
      "email": "seddon.ryan@gmail.com"
    },
    {
      "name": "Miles Elam",
      "email": "miles.elam@deem.com"
    },
    {
      "name": "Mihai Bazon",
      "email": "mihai.bazon@gmail.com"
    },
    {
      "name": "Michael Ficarra",
      "email": "github.public.email@michael.ficarra.me"
    },
    {
      "name": "Todd Wolfson",
      "email": "todd@twolfson.com"
    },
    {
      "name": "Alexander Solovyov",
      "email": "alexander@solovyov.net"
    },
    {
      "name": "Felix Gnass",
      "email": "fgnass@gmail.com"
    },
    {
      "name": "Conrad Irwin",
      "email": "conrad.irwin@gmail.com"
    },
    {
      "name": "usrbincc",
      "email": "usrbincc@yahoo.com"
    },
    {
      "name": "David Glasser",
      "email": "glasser@davidglasser.net"
    },
    {
      "name": "Chase Douglas",
      "email": "chase@newrelic.com"
    },
    {
      "name": "Evan Wallace",
      "email": "evan.exe@gmail.com"
    },
    {
      "name": "Heather Arthur",
      "email": "fayearthur@gmail.com"
    }
  ],
  "repository": {
    "type": "git",
    "url": "http://github.com/mozilla/source-map.git"
  },
  "directories": {
    "lib": "./lib"
  },
  "main": "./lib/source-map.js",
  "engines": {
    "node": ">=0.8.0"
  },
  "licenses": [
    {
      "type": "BSD",
      "url": "http://opensource.org/licenses/BSD-3-Clause"
    }
  ],
  "dependencies": {
    "amdefine": ">=0.0.4"
  },
  "devDependencies": {
    "dryice": ">=0.4.8"
  },
  "scripts": {
    "test": "node test/run-tests.js",
    "build": "node Makefile.dryice.js"
  },
  "readme": "# Source Map\n\nThis is a library to generate and consume the source map format\n[described here][format].\n\nThis library is written in the Asynchronous Module Definition format, and works\nin the following environments:\n\n* Modern Browsers supporting ECMAScript 5 (either after the build, or with an\n  AMD loader such as RequireJS)\n\n* Inside Firefox (as a JSM file, after the build)\n\n* With NodeJS versions 0.8.X and higher\n\n## Node\n\n    $ npm install source-map\n\n## Building from Source (for everywhere else)\n\nInstall Node and then run\n\n    $ git clone https://fitzgen@github.com/mozilla/source-map.git\n    $ cd source-map\n    $ npm link .\n\nNext, run\n\n    $ node Makefile.dryice.js\n\nThis should spew a bunch of stuff to stdout, and create the following files:\n\n* `dist/source-map.js` - The unminified browser version.\n\n* `dist/source-map.min.js` - The minified browser version.\n\n* `dist/SourceMap.jsm` - The JavaScript Module for inclusion in Firefox source.\n\n## Examples\n\n### Consuming a source map\n\n    var rawSourceMap = {\n      version: 3,\n      file: 'min.js',\n      names: ['bar', 'baz', 'n'],\n      sources: ['one.js', 'two.js'],\n      sourceRoot: 'http://example.com/www/js/',\n      mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'\n    };\n\n    var smc = new SourceMapConsumer(rawSourceMap);\n\n    console.log(smc.sources);\n    // [ 'http://example.com/www/js/one.js',\n    //   'http://example.com/www/js/two.js' ]\n\n    console.log(smc.originalPositionFor({\n      line: 2,\n      column: 28\n    }));\n    // { source: 'http://example.com/www/js/two.js',\n    //   line: 2,\n    //   column: 10,\n    //   name: 'n' }\n\n    console.log(smc.generatedPositionFor({\n      source: 'http://example.com/www/js/two.js',\n      line: 2,\n      column: 10\n    }));\n    // { line: 2, column: 28 }\n\n    smc.eachMapping(function (m) {\n      // ...\n    });\n\n### Generating a source map\n\nIn depth guide:\n[**Compiling to JavaScript, and Debugging with Source Maps**](https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/)\n\n#### With SourceNode (high level API)\n\n    function compile(ast) {\n      switch (ast.type) {\n      case 'BinaryExpression':\n        return new SourceNode(\n          ast.location.line,\n          ast.location.column,\n          ast.location.source,\n          [compile(ast.left), \" + \", compile(ast.right)]\n        );\n      case 'Literal':\n        return new SourceNode(\n          ast.location.line,\n          ast.location.column,\n          ast.location.source,\n          String(ast.value)\n        );\n      // ...\n      default:\n        throw new Error(\"Bad AST\");\n      }\n    }\n\n    var ast = parse(\"40 + 2\", \"add.js\");\n    console.log(compile(ast).toStringWithSourceMap({\n      file: 'add.js'\n    }));\n    // { code: '40 + 2',\n    //   map: [object SourceMapGenerator] }\n\n#### With SourceMapGenerator (low level API)\n\n    var map = new SourceMapGenerator({\n      file: \"source-mapped.js\"\n    });\n\n    map.addMapping({\n      generated: {\n        line: 10,\n        column: 35\n      },\n      source: \"foo.js\",\n      original: {\n        line: 33,\n        column: 2\n      },\n      name: \"christopher\"\n    });\n\n    console.log(map.toString());\n    // '{\"version\":3,\"file\":\"source-mapped.js\",\"sources\":[\"foo.js\"],\"names\":[\"christopher\"],\"mappings\":\";;;;;;;;;mCAgCEA\"}'\n\n## API\n\nGet a reference to the module:\n\n    // NodeJS\n    var sourceMap = require('source-map');\n\n    // Browser builds\n    var sourceMap = window.sourceMap;\n\n    // Inside Firefox\n    let sourceMap = {};\n    Components.utils.import('resource:///modules/devtools/SourceMap.jsm', sourceMap);\n\n### SourceMapConsumer\n\nA SourceMapConsumer instance represents a parsed source map which we can query\nfor information about the original file positions by giving it a file position\nin the generated source.\n\n#### new SourceMapConsumer(rawSourceMap)\n\nThe only parameter is the raw source map (either as a string which can be\n`JSON.parse`'d, or an object). According to the spec, source maps have the\nfollowing attributes:\n\n* `version`: Which version of the source map spec this map is following.\n\n* `sources`: An array of URLs to the original source files.\n\n* `names`: An array of identifiers which can be referrenced by individual\n  mappings.\n\n* `sourceRoot`: Optional. The URL root from which all sources are relative.\n\n* `sourcesContent`: Optional. An array of contents of the original source files.\n\n* `mappings`: A string of base64 VLQs which contain the actual mappings.\n\n* `file`: The generated filename this source map is associated with.\n\n#### SourceMapConsumer.prototype.originalPositionFor(generatedPosition)\n\nReturns the original source, line, and column information for the generated\nsource's line and column positions provided. The only argument is an object with\nthe following properties:\n\n* `line`: The line number in the generated source.\n\n* `column`: The column number in the generated source.\n\nand an object is returned with the following properties:\n\n* `source`: The original source file, or null if this information is not\n  available.\n\n* `line`: The line number in the original source, or null if this information is\n  not available.\n\n* `column`: The column number in the original source, or null or null if this\n  information is not available.\n\n* `name`: The original identifier, or null if this information is not available.\n\n#### SourceMapConsumer.prototype.generatedPositionFor(originalPosition)\n\nReturns the generated line and column information for the original source,\nline, and column positions provided. The only argument is an object with\nthe following properties:\n\n* `source`: The filename of the original source.\n\n* `line`: The line number in the original source.\n\n* `column`: The column number in the original source.\n\nand an object is returned with the following properties:\n\n* `line`: The line number in the generated source, or null.\n\n* `column`: The column number in the generated source, or null.\n\n#### SourceMapConsumer.prototype.sourceContentFor(source)\n\nReturns the original source content for the source provided. The only\nargument is the URL of the original source file.\n\n#### SourceMapConsumer.prototype.eachMapping(callback, context, order)\n\nIterate over each mapping between an original source/line/column and a\ngenerated line/column in this source map.\n\n* `callback`: The function that is called with each mapping. Mappings have the\n  form `{ source, generatedLine, generatedColumn, originalLine, originalColumn,\n  name }`\n\n* `context`: Optional. If specified, this object will be the value of `this`\n  every time that `callback` is called.\n\n* `order`: Either `SourceMapConsumer.GENERATED_ORDER` or\n  `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to iterate over\n  the mappings sorted by the generated file's line/column order or the\n  original's source/line/column order, respectively. Defaults to\n  `SourceMapConsumer.GENERATED_ORDER`.\n\n### SourceMapGenerator\n\nAn instance of the SourceMapGenerator represents a source map which is being\nbuilt incrementally.\n\n#### new SourceMapGenerator(startOfSourceMap)\n\nTo create a new one, you must pass an object with the following properties:\n\n* `file`: The filename of the generated source that this source map is\n  associated with.\n\n* `sourceRoot`: An optional root for all relative URLs in this source map.\n\n#### SourceMapGenerator.fromSourceMap(sourceMapConsumer)\n\nCreates a new SourceMapGenerator based on a SourceMapConsumer\n\n* `sourceMapConsumer` The SourceMap.\n\n#### SourceMapGenerator.prototype.addMapping(mapping)\n\nAdd a single mapping from original source line and column to the generated\nsource's line and column for this source map being created. The mapping object\nshould have the following properties:\n\n* `generated`: An object with the generated line and column positions.\n\n* `original`: An object with the original line and column positions.\n\n* `source`: The original source file (relative to the sourceRoot).\n\n* `name`: An optional original token name for this mapping.\n\n#### SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)\n\nSet the source content for an original source file.\n\n* `sourceFile` the URL of the original source file.\n\n* `sourceContent` the content of the source file.\n\n#### SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile])\n\nApplies a SourceMap for a source file to the SourceMap.\nEach mapping to the supplied source file is rewritten using the\nsupplied SourceMap. Note: The resolution for the resulting mappings\nis the minimium of this map and the supplied map.\n\n* `sourceMapConsumer`: The SourceMap to be applied.\n\n* `sourceFile`: Optional. The filename of the source file.\n  If omitted, sourceMapConsumer.file will be used.\n\n#### SourceMapGenerator.prototype.toString()\n\nRenders the source map being generated to a string.\n\n### SourceNode\n\nSourceNodes provide a way to abstract over interpolating and/or concatenating\nsnippets of generated JavaScript source code, while maintaining the line and\ncolumn information associated between those snippets and the original source\ncode. This is useful as the final intermediate representation a compiler might\nuse before outputting the generated JS and source map.\n\n#### new SourceNode(line, column, source[, chunk[, name]])\n\n* `line`: The original line number associated with this source node, or null if\n  it isn't associated with an original line.\n\n* `column`: The original column number associated with this source node, or null\n  if it isn't associated with an original column.\n\n* `source`: The original source's filename.\n\n* `chunk`: Optional. Is immediately passed to `SourceNode.prototype.add`, see\n  below.\n\n* `name`: Optional. The original identifier.\n\n#### SourceNode.fromStringWithSourceMap(code, sourceMapConsumer)\n\nCreates a SourceNode from generated code and a SourceMapConsumer.\n\n* `code`: The generated code\n\n* `sourceMapConsumer` The SourceMap for the generated code\n\n#### SourceNode.prototype.add(chunk)\n\nAdd a chunk of generated JS to this source node.\n\n* `chunk`: A string snippet of generated JS code, another instance of\n   `SourceNode`, or an array where each member is one of those things.\n\n#### SourceNode.prototype.prepend(chunk)\n\nPrepend a chunk of generated JS to this source node.\n\n* `chunk`: A string snippet of generated JS code, another instance of\n   `SourceNode`, or an array where each member is one of those things.\n\n#### SourceNode.prototype.setSourceContent(sourceFile, sourceContent)\n\nSet the source content for a source file. This will be added to the\n`SourceMap` in the `sourcesContent` field.\n\n* `sourceFile`: The filename of the source file\n\n* `sourceContent`: The content of the source file\n\n#### SourceNode.prototype.walk(fn)\n\nWalk over the tree of JS snippets in this node and its children. The walking\nfunction is called once for each snippet of JS and is passed that snippet and\nthe its original associated source's line/column location.\n\n* `fn`: The traversal function.\n\n#### SourceNode.prototype.walkSourceContents(fn)\n\nWalk over the tree of SourceNodes. The walking function is called for each\nsource file content and is passed the filename and source content.\n\n* `fn`: The traversal function.\n\n#### SourceNode.prototype.join(sep)\n\nLike `Array.prototype.join` except for SourceNodes. Inserts the separator\nbetween each of this source node's children.\n\n* `sep`: The separator.\n\n#### SourceNode.prototype.replaceRight(pattern, replacement)\n\nCall `String.prototype.replace` on the very right-most source snippet. Useful\nfor trimming whitespace from the end of a source node, etc.\n\n* `pattern`: The pattern to replace.\n\n* `replacement`: The thing to replace the pattern with.\n\n#### SourceNode.prototype.toString()\n\nReturn the string representation of this source node. Walks over the tree and\nconcatenates all the various snippets together to one string.\n\n### SourceNode.prototype.toStringWithSourceMap(startOfSourceMap)\n\nReturns the string representation of this tree of source nodes, plus a\nSourceMapGenerator which contains all the mappings between the generated and\noriginal sources.\n\nThe arguments are the same as those to `new SourceMapGenerator`.\n\n## Tests\n\n[![Build Status](https://travis-ci.org/mozilla/source-map.png?branch=master)](https://travis-ci.org/mozilla/source-map)\n\nInstall NodeJS version 0.8.0 or greater, then run `node test/run-tests.js`.\n\nTo add new tests, create a new file named `test/test-<your new test name>.js`\nand export your test functions with names that start with \"test\", for example\n\n    exports[\"test doing the foo bar\"] = function (assert, util) {\n      ...\n    };\n\nThe new test will be located automatically when you run the suite.\n\nThe `util` argument is the test utility module located at `test/source-map/util`.\n\nThe `assert` argument is a cut down version of node's assert module. You have\naccess to the following assertion functions:\n\n* `doesNotThrow`\n\n* `equal`\n\n* `ok`\n\n* `strictEqual`\n\n* `throws`\n\n(The reason for the restricted set of test functions is because we need the\ntests to run inside Firefox's test suite as well and so the assert module is\nshimmed in that environment. See `build/assert-shim.js`.)\n\n[format]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit\n[feature]: https://wiki.mozilla.org/DevTools/Features/SourceMap\n[Dryice]: https://github.com/mozilla/dryice\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/mozilla/source-map/issues"
  },
  "_id": "source-map@0.1.31",
  "_from": "source-map@~0.1.7"
}
