\href{https://travis-ci.org/mozilla/source-map}{\texttt{ }}

\href{https://www.npmjs.com/package/source-map}{\texttt{ }}

This is a library to generate and consume the source map format \href{https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit}{\texttt{ described here}}.\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32737}{}\doxysection{Use with Node}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32737}
\begin{DoxyVerb}$ npm install source-map
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32738}{}\doxysection{Use on the Web}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32738}
\begin{DoxyVerb}<script src="https://raw.githubusercontent.com/mozilla/source-map/master/dist/source-map.min.js" defer></script>
\end{DoxyVerb}
 \DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32739}{}\doxysection{Table of Contents}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32739}

\begin{DoxyItemize}
\item \href{\#examples}{\texttt{ Examples}}
\begin{DoxyItemize}
\item \href{\#consuming-a-source-map}{\texttt{ Consuming a source map}}
\item \href{\#generating-a-source-map}{\texttt{ Generating a source map}}
\begin{DoxyItemize}
\item \href{\#with-sourcenode-high-level-api}{\texttt{ With Source\+Node (high level API)}}
\item \href{\#with-sourcemapgenerator-low-level-api}{\texttt{ With Source\+Map\+Generator (low level API)}}
\end{DoxyItemize}
\end{DoxyItemize}
\item \href{\#api}{\texttt{ API}}
\begin{DoxyItemize}
\item \href{\#sourcemapconsumer}{\texttt{ Source\+Map\+Consumer}}
\begin{DoxyItemize}
\item \href{\#new-sourcemapconsumerrawsourcemap}{\texttt{ new Source\+Map\+Consumer(raw\+Source\+Map)}}
\item \href{\#sourcemapconsumerprototypecomputecolumnspans}{\texttt{ Source\+Map\+Consumer.\+prototype.\+compute\+Column\+Spans()}}
\item \href{\#sourcemapconsumerprototypeoriginalpositionforgeneratedposition}{\texttt{ Source\+Map\+Consumer.\+prototype.\+original\+Position\+For(generated\+Position)}}
\item \href{\#sourcemapconsumerprototypegeneratedpositionfororiginalposition}{\texttt{ Source\+Map\+Consumer.\+prototype.\+generated\+Position\+For(original\+Position)}}
\item \href{\#sourcemapconsumerprototypeallgeneratedpositionsfororiginalposition}{\texttt{ Source\+Map\+Consumer.\+prototype.\+all\+Generated\+Positions\+For(original\+Position)}}
\item \href{\#sourcemapconsumerprototypehascontentsofallsources}{\texttt{ Source\+Map\+Consumer.\+prototype.\+has\+Contents\+Of\+All\+Sources()}}
\item \href{\#sourcemapconsumerprototypesourcecontentforsource-returnnullonmissing}{\texttt{ Source\+Map\+Consumer.\+prototype.\+source\+Content\+For(source\mbox{[}, return\+Null\+On\+Missing\mbox{]})}}
\item \href{\#sourcemapconsumerprototypeeachmappingcallback-context-order}{\texttt{ Source\+Map\+Consumer.\+prototype.\+each\+Mapping(callback, context, order)}}
\end{DoxyItemize}
\item \href{\#sourcemapgenerator}{\texttt{ Source\+Map\+Generator}}
\begin{DoxyItemize}
\item \href{\#new-sourcemapgeneratorstartofsourcemap}{\texttt{ new Source\+Map\+Generator(\mbox{[}start\+Of\+Source\+Map\mbox{]})}}
\item \href{\#sourcemapgeneratorfromsourcemapsourcemapconsumer}{\texttt{ Source\+Map\+Generator.\+from\+Source\+Map(source\+Map\+Consumer)}}
\item \href{\#sourcemapgeneratorprototypeaddmappingmapping}{\texttt{ Source\+Map\+Generator.\+prototype.\+add\+Mapping(mapping)}}
\item \href{\#sourcemapgeneratorprototypesetsourcecontentsourcefile-sourcecontent}{\texttt{ Source\+Map\+Generator.\+prototype.\+set\+Source\+Content(source\+File, source\+Content)}}
\item \href{\#sourcemapgeneratorprototypeapplysourcemapsourcemapconsumer-sourcefile-sourcemappath}{\texttt{ Source\+Map\+Generator.\+prototype.\+apply\+Source\+Map(source\+Map\+Consumer\mbox{[}, source\+File\mbox{[}, source\+Map\+Path\mbox{]}\mbox{]})}}
\item \href{\#sourcemapgeneratorprototypetostring}{\texttt{ Source\+Map\+Generator.\+prototype.\+to\+String()}}
\end{DoxyItemize}
\item \href{\#sourcenode}{\texttt{ Source\+Node}}
\begin{DoxyItemize}
\item \href{\#new-sourcenodeline-column-source-chunk-name}{\texttt{ new Source\+Node(\mbox{[}line, column, source\mbox{[}, chunk\mbox{[}, name\mbox{]}\mbox{]}\mbox{]})}}
\item \href{\#sourcenodefromstringwithsourcemapcode-sourcemapconsumer-relativepath}{\texttt{ Source\+Node.\+from\+String\+With\+Source\+Map(code, source\+Map\+Consumer\mbox{[}, relative\+Path\mbox{]})}}
\item \href{\#sourcenodeprototypeaddchunk}{\texttt{ Source\+Node.\+prototype.\+add(chunk)}}
\item \href{\#sourcenodeprototypeprependchunk}{\texttt{ Source\+Node.\+prototype.\+prepend(chunk)}}
\item \href{\#sourcenodeprototypesetsourcecontentsourcefile-sourcecontent}{\texttt{ Source\+Node.\+prototype.\+set\+Source\+Content(source\+File, source\+Content)}}
\item \href{\#sourcenodeprototypewalkfn}{\texttt{ Source\+Node.\+prototype.\+walk(fn)}}
\item \href{\#sourcenodeprototypewalksourcecontentsfn}{\texttt{ Source\+Node.\+prototype.\+walk\+Source\+Contents(fn)}}
\item \href{\#sourcenodeprototypejoinsep}{\texttt{ Source\+Node.\+prototype.\+join(sep)}}
\item \href{\#sourcenodeprototypereplacerightpattern-replacement}{\texttt{ Source\+Node.\+prototype.\+replace\+Right(pattern, replacement)}}
\item \href{\#sourcenodeprototypetostring}{\texttt{ Source\+Node.\+prototype.\+to\+String()}}
\item \href{\#sourcenodeprototypetostringwithsourcemapstartofsourcemap}{\texttt{ Source\+Node.\+prototype.\+to\+String\+With\+Source\+Map(\mbox{[}start\+Of\+Source\+Map\mbox{]})}}
\end{DoxyItemize}
\end{DoxyItemize}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32740}{}\doxysection{Examples}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32740}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32741}{}\doxysubsection{Consuming a source map}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32741}

\begin{DoxyCode}{0}
\DoxyCodeLine{var rawSourceMap = \{}
\DoxyCodeLine{  version: 3,}
\DoxyCodeLine{  file: 'min.js',}
\DoxyCodeLine{  names: ['bar', 'baz', 'n'],}
\DoxyCodeLine{  sources: ['one.js', 'two.js'],}
\DoxyCodeLine{  sourceRoot: 'http://example.com/www/js/',}
\DoxyCodeLine{  mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\DoxyCodeLine{var smc = new SourceMapConsumer(rawSourceMap);}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(smc.sources);}
\DoxyCodeLine{// [ 'http://example.com/www/js/one.js',}
\DoxyCodeLine{//   'http://example.com/www/js/two.js' ]}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(smc.originalPositionFor(\{}
\DoxyCodeLine{  line: 2,}
\DoxyCodeLine{  column: 28}
\DoxyCodeLine{\}));}
\DoxyCodeLine{// \{ source: 'http://example.com/www/js/two.js',}
\DoxyCodeLine{//   line: 2,}
\DoxyCodeLine{//   column: 10,}
\DoxyCodeLine{//   name: 'n' \}}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(smc.generatedPositionFor(\{}
\DoxyCodeLine{  source: 'http://example.com/www/js/two.js',}
\DoxyCodeLine{  line: 2,}
\DoxyCodeLine{  column: 10}
\DoxyCodeLine{\}));}
\DoxyCodeLine{// \{ line: 2, column: 28 \}}
\DoxyCodeLine{}
\DoxyCodeLine{smc.eachMapping(function (m) \{}
\DoxyCodeLine{  // ...}
\DoxyCodeLine{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32742}{}\doxysubsection{Generating a source map}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32742}
In depth guide\+: \href{https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/}{\texttt{ {\bfseries{Compiling to Java\+Script, and Debugging with Source Maps}}}}\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32743}{}\doxysubsubsection{With Source\+Node (high level API)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32743}

\begin{DoxyCode}{0}
\DoxyCodeLine{function compile(ast) \{}
\DoxyCodeLine{  switch (ast.type) \{}
\DoxyCodeLine{  case 'BinaryExpression':}
\DoxyCodeLine{    return new SourceNode(}
\DoxyCodeLine{      ast.location.line,}
\DoxyCodeLine{      ast.location.column,}
\DoxyCodeLine{      ast.location.source,}
\DoxyCodeLine{      [compile(ast.left), "{} + "{}, compile(ast.right)]}
\DoxyCodeLine{    );}
\DoxyCodeLine{  case 'Literal':}
\DoxyCodeLine{    return new SourceNode(}
\DoxyCodeLine{      ast.location.line,}
\DoxyCodeLine{      ast.location.column,}
\DoxyCodeLine{      ast.location.source,}
\DoxyCodeLine{      String(ast.value)}
\DoxyCodeLine{    );}
\DoxyCodeLine{  // ...}
\DoxyCodeLine{  default:}
\DoxyCodeLine{    throw new Error("{}Bad AST"{});}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{var ast = parse("{}40 + 2"{}, "{}add.js"{});}
\DoxyCodeLine{console.log(compile(ast).toStringWithSourceMap(\{}
\DoxyCodeLine{  file: 'add.js'}
\DoxyCodeLine{\}));}
\DoxyCodeLine{// \{ code: '40 + 2',}
\DoxyCodeLine{//   map: [object SourceMapGenerator] \} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32744}{}\doxysubsubsection{With Source\+Map\+Generator (low level API)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32744}

\begin{DoxyCode}{0}
\DoxyCodeLine{var map = new SourceMapGenerator(\{}
\DoxyCodeLine{  file: "{}source-\/mapped.js"{}}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{map.addMapping(\{}
\DoxyCodeLine{  generated: \{}
\DoxyCodeLine{    line: 10,}
\DoxyCodeLine{    column: 35}
\DoxyCodeLine{  \},}
\DoxyCodeLine{  source: "{}foo.js"{},}
\DoxyCodeLine{  original: \{}
\DoxyCodeLine{    line: 33,}
\DoxyCodeLine{    column: 2}
\DoxyCodeLine{  \},}
\DoxyCodeLine{  name: "{}christopher"{}}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(map.toString());}
\DoxyCodeLine{// '\{"{}version"{}:3,"{}file"{}:"{}source-\/mapped.js"{},"{}sources"{}:["{}foo.js"{}],"{}names"{}:["{}christopher"{}],"{}mappings"{}:"{};;;;;;;;;mCAgCEA"{}\}' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32745}{}\doxysection{API}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32745}
Get a reference to the module\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{// Node.js}
\DoxyCodeLine{var sourceMap = require('source-\/map');}
\DoxyCodeLine{}
\DoxyCodeLine{// Browser builds}
\DoxyCodeLine{var sourceMap = window.sourceMap;}
\DoxyCodeLine{}
\DoxyCodeLine{// Inside Firefox}
\DoxyCodeLine{const sourceMap = require("{}devtools/toolkit/sourcemap/source-\/map.js"{}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32746}{}\doxysubsection{Source\+Map\+Consumer}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32746}
A Source\+Map\+Consumer instance represents a parsed source map which we can query for information about the original file positions by giving it a file position in the generated source.\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32747}{}\doxysubsubsection{new Source\+Map\+Consumer(raw\+Source\+Map)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32747}
The only parameter is the raw source map (either as a string which can be {\ttfamily JSON.\+parse}\textquotesingle{}d, or an object). According to the spec, source maps have the following attributes\+:


\begin{DoxyItemize}
\item {\ttfamily version}\+: Which version of the source map spec this map is following.
\item {\ttfamily sources}\+: An array of URLs to the original source files.
\item {\ttfamily names}\+: An array of identifiers which can be referenced by individual mappings.
\item {\ttfamily source\+Root}\+: Optional. The URL root from which all sources are relative.
\item {\ttfamily sources\+Content}\+: Optional. An array of contents of the original source files.
\item {\ttfamily mappings}\+: A string of base64 VLQs which contain the actual mappings.
\item {\ttfamily file}\+: Optional. The generated filename this source map is associated with.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var consumer = new sourceMap.SourceMapConsumer(rawSourceMapJsonData); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32748}{}\doxysubsubsection{Source\+Map\+Consumer.\+prototype.\+compute\+Column\+Spans()}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32748}
Compute the last column for each generated mapping. The last column is inclusive.


\begin{DoxyCode}{0}
\DoxyCodeLine{// Before:}
\DoxyCodeLine{consumer.allGeneratedPositionsFor(\{ line: 2, source: "{}foo.coffee"{} \})}
\DoxyCodeLine{// [ \{ line: 2,}
\DoxyCodeLine{//     column: 1 \},}
\DoxyCodeLine{//   \{ line: 2,}
\DoxyCodeLine{//     column: 10 \},}
\DoxyCodeLine{//   \{ line: 2,}
\DoxyCodeLine{//     column: 20 \} ]}
\DoxyCodeLine{}
\DoxyCodeLine{consumer.computeColumnSpans();}
\DoxyCodeLine{}
\DoxyCodeLine{// After:}
\DoxyCodeLine{consumer.allGeneratedPositionsFor(\{ line: 2, source: "{}foo.coffee"{} \})}
\DoxyCodeLine{// [ \{ line: 2,}
\DoxyCodeLine{//     column: 1,}
\DoxyCodeLine{//     lastColumn: 9 \},}
\DoxyCodeLine{//   \{ line: 2,}
\DoxyCodeLine{//     column: 10,}
\DoxyCodeLine{//     lastColumn: 19 \},}
\DoxyCodeLine{//   \{ line: 2,}
\DoxyCodeLine{//     column: 20,}
\DoxyCodeLine{//     lastColumn: Infinity \} ]}

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32749}{}\doxysubsubsection{Source\+Map\+Consumer.\+prototype.\+original\+Position\+For(generated\+Position)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32749}
Returns the original source, line, and column information for the generated source\textquotesingle{}s line and column positions provided. The only argument is an object with the following properties\+:


\begin{DoxyItemize}
\item {\ttfamily line}\+: The line number in the generated source. Line numbers in this library are 1-\/based (note that the underlying source map specification uses 0-\/based line numbers -- this library handles the translation).
\item {\ttfamily column}\+: The column number in the generated source. Column numbers in this library are 0-\/based.
\item {\ttfamily bias}\+: Either {\ttfamily Source\+Map\+Consumer.\+GREATEST\+\_\+\+LOWER\+\_\+\+BOUND} or {\ttfamily Source\+Map\+Consumer.\+LEAST\+\_\+\+UPPER\+\_\+\+BOUND}. Specifies whether to return the closest element that is smaller than or greater than the one we are searching for, respectively, if the exact element cannot be found. Defaults to {\ttfamily Source\+Map\+Consumer.\+GREATEST\+\_\+\+LOWER\+\_\+\+BOUND}.
\end{DoxyItemize}

and an object is returned with the following properties\+:


\begin{DoxyItemize}
\item {\ttfamily source}\+: The original source file, or null if this information is not available.
\item {\ttfamily line}\+: The line number in the original source, or null if this information is not available. The line number is 1-\/based.
\item {\ttfamily column}\+: The column number in the original source, or null if this information is not available. The column number is 0-\/based.
\item {\ttfamily name}\+: The original identifier, or null if this information is not available.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{consumer.originalPositionFor(\{ line: 2, column: 10 \})}
\DoxyCodeLine{// \{ source: 'foo.coffee',}
\DoxyCodeLine{//   line: 2,}
\DoxyCodeLine{//   column: 2,}
\DoxyCodeLine{//   name: null \}}
\DoxyCodeLine{}
\DoxyCodeLine{consumer.originalPositionFor(\{ line: 99999999999999999, column: 999999999999999 \})}
\DoxyCodeLine{// \{ source: null,}
\DoxyCodeLine{//   line: null,}
\DoxyCodeLine{//   column: null,}
\DoxyCodeLine{//   name: null \} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32750}{}\doxysubsubsection{Source\+Map\+Consumer.\+prototype.\+generated\+Position\+For(original\+Position)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32750}
Returns the generated line and column information for the original source, line, and column positions provided. The only argument is an object with the following properties\+:


\begin{DoxyItemize}
\item {\ttfamily source}\+: The filename of the original source.
\item {\ttfamily line}\+: The line number in the original source. The line number is 1-\/based.
\item {\ttfamily column}\+: The column number in the original source. The column number is 0-\/based.
\end{DoxyItemize}

and an object is returned with the following properties\+:


\begin{DoxyItemize}
\item {\ttfamily line}\+: The line number in the generated source, or null. The line number is 1-\/based.
\item {\ttfamily column}\+: The column number in the generated source, or null. The column number is 0-\/based.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{consumer.generatedPositionFor(\{ source: "{}example.js"{}, line: 2, column: 10 \})}
\DoxyCodeLine{// \{ line: 1,}
\DoxyCodeLine{//   column: 56 \} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32751}{}\doxysubsubsection{Source\+Map\+Consumer.\+prototype.\+all\+Generated\+Positions\+For(original\+Position)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32751}
Returns all generated line and column information for the original source, line, and column provided. If no column is provided, returns all mappings corresponding to a either the line we are searching for or the next closest line that has any mappings. Otherwise, returns all mappings corresponding to the given line and either the column we are searching for or the next closest column that has any offsets.

The only argument is an object with the following properties\+:


\begin{DoxyItemize}
\item {\ttfamily source}\+: The filename of the original source.
\item {\ttfamily line}\+: The line number in the original source. The line number is 1-\/based.
\item {\ttfamily column}\+: Optional. The column number in the original source. The column number is 0-\/based.
\end{DoxyItemize}

and an array of objects is returned, each with the following properties\+:


\begin{DoxyItemize}
\item {\ttfamily line}\+: The line number in the generated source, or null. The line number is 1-\/based.
\item {\ttfamily column}\+: The column number in the generated source, or null. The column number is 0-\/based.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{consumer.allGeneratedpositionsfor(\{ line: 2, source: "{}foo.coffee"{} \})}
\DoxyCodeLine{// [ \{ line: 2,}
\DoxyCodeLine{//     column: 1 \},}
\DoxyCodeLine{//   \{ line: 2,}
\DoxyCodeLine{//     column: 10 \},}
\DoxyCodeLine{//   \{ line: 2,}
\DoxyCodeLine{//     column: 20 \} ] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32752}{}\doxysubsubsection{Source\+Map\+Consumer.\+prototype.\+has\+Contents\+Of\+All\+Sources()}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32752}
Return true if we have the embedded source content for every source listed in the source map, false otherwise.

In other words, if this method returns {\ttfamily true}, then {\ttfamily consumer.\+source\+Content\+For(s)} will succeed for every source {\ttfamily s} in {\ttfamily consumer.\+sources}.


\begin{DoxyCode}{0}
\DoxyCodeLine{// ...}
\DoxyCodeLine{if (consumer.hasContentsOfAllSources()) \{}
\DoxyCodeLine{  consumerReadyCallback(consumer);}
\DoxyCodeLine{\} else \{}
\DoxyCodeLine{  fetchSources(consumer, consumerReadyCallback);}
\DoxyCodeLine{\}}
\DoxyCodeLine{// ... }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32753}{}\doxysubsubsection{Source\+Map\+Consumer.\+prototype.\+source\+Content\+For(source\mbox{[}, return\+Null\+On\+Missing\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32753}
Returns the original source content for the source provided. The only argument is the URL of the original source file.

If the source content for the given source is not found, then an error is thrown. Optionally, pass {\ttfamily true} as the second param to have {\ttfamily null} returned instead.


\begin{DoxyCode}{0}
\DoxyCodeLine{consumer.sources}
\DoxyCodeLine{// [ "{}my-\/cool-\/lib.clj"{} ]}
\DoxyCodeLine{}
\DoxyCodeLine{consumer.sourceContentFor("{}my-\/cool-\/lib.clj"{})}
\DoxyCodeLine{// "{}..."{}}
\DoxyCodeLine{}
\DoxyCodeLine{consumer.sourceContentFor("{}this is not in the source map"{});}
\DoxyCodeLine{// Error: "{}this is not in the source map"{} is not in the source map}
\DoxyCodeLine{}
\DoxyCodeLine{consumer.sourceContentFor("{}this is not in the source map"{}, true);}
\DoxyCodeLine{// null }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32754}{}\doxysubsubsection{Source\+Map\+Consumer.\+prototype.\+each\+Mapping(callback, context, order)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32754}
Iterate over each mapping between an original source/line/column and a generated line/column in this source map.


\begin{DoxyItemize}
\item {\ttfamily callback}\+: The function that is called with each mapping. Mappings have the form {\ttfamily \{ source, generated\+Line, generated\+Column, original\+Line, original\+Column, name \}}
\item {\ttfamily context}\+: Optional. If specified, this object will be the value of {\ttfamily this} every time that {\ttfamily callback} is called.
\item {\ttfamily order}\+: Either {\ttfamily Source\+Map\+Consumer.\+GENERATED\+\_\+\+ORDER} or {\ttfamily Source\+Map\+Consumer.\+ORIGINAL\+\_\+\+ORDER}. Specifies whether you want to iterate over the mappings sorted by the generated file\textquotesingle{}s line/column order or the original\textquotesingle{}s source/line/column order, respectively. Defaults to {\ttfamily Source\+Map\+Consumer.\+GENERATED\+\_\+\+ORDER}.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{consumer.eachMapping(function (m) \{ console.log(m); \})}
\DoxyCodeLine{// ...}
\DoxyCodeLine{// \{ source: 'illmatic.js',}
\DoxyCodeLine{//   generatedLine: 1,}
\DoxyCodeLine{//   generatedColumn: 0,}
\DoxyCodeLine{//   originalLine: 1,}
\DoxyCodeLine{//   originalColumn: 0,}
\DoxyCodeLine{//   name: null \}}
\DoxyCodeLine{// \{ source: 'illmatic.js',}
\DoxyCodeLine{//   generatedLine: 2,}
\DoxyCodeLine{//   generatedColumn: 0,}
\DoxyCodeLine{//   originalLine: 2,}
\DoxyCodeLine{//   originalColumn: 0,}
\DoxyCodeLine{//   name: null \}}
\DoxyCodeLine{// ... }

\end{DoxyCode}
 \hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32755}{}\doxysubsection{Source\+Map\+Generator}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32755}
An instance of the Source\+Map\+Generator represents a source map which is being built incrementally.\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32756}{}\doxysubsubsection{new Source\+Map\+Generator(\mbox{[}start\+Of\+Source\+Map\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32756}
You may pass an object with the following properties\+:


\begin{DoxyItemize}
\item {\ttfamily file}\+: The filename of the generated source that this source map is associated with.
\item {\ttfamily source\+Root}\+: A root for all relative URLs in this source map.
\item {\ttfamily skip\+Validation}\+: Optional. When {\ttfamily true}, disables validation of mappings as they are added. This can improve performance but should be used with discretion, as a last resort. Even then, one should avoid using this flag when running tests, if possible.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var generator = new sourceMap.SourceMapGenerator(\{}
\DoxyCodeLine{  file: "{}my-\/generated-\/javascript-\/file.js"{},}
\DoxyCodeLine{  sourceRoot: "{}http://example.com/app/js/"{}}
\DoxyCodeLine{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32757}{}\doxysubsubsection{Source\+Map\+Generator.\+from\+Source\+Map(source\+Map\+Consumer)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32757}
Creates a new {\ttfamily Source\+Map\+Generator} from an existing {\ttfamily Source\+Map\+Consumer} instance.


\begin{DoxyItemize}
\item {\ttfamily source\+Map\+Consumer} The Source\+Map.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var generator = sourceMap.SourceMapGenerator.fromSourceMap(consumer); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32758}{}\doxysubsubsection{Source\+Map\+Generator.\+prototype.\+add\+Mapping(mapping)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32758}
Add a single mapping from original source line and column to the generated source\textquotesingle{}s line and column for this source map being created. The mapping object should have the following properties\+:


\begin{DoxyItemize}
\item {\ttfamily generated}\+: An object with the generated line and column positions.
\item {\ttfamily original}\+: An object with the original line and column positions.
\item {\ttfamily source}\+: The original source file (relative to the source\+Root).
\item {\ttfamily name}\+: An optional original token name for this mapping.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{generator.addMapping(\{}
\DoxyCodeLine{  source: "{}module-\/one.scm"{},}
\DoxyCodeLine{  original: \{ line: 128, column: 0 \},}
\DoxyCodeLine{  generated: \{ line: 3, column: 456 \}}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32759}{}\doxysubsubsection{Source\+Map\+Generator.\+prototype.\+set\+Source\+Content(source\+File, source\+Content)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32759}
Set the source content for an original source file.


\begin{DoxyItemize}
\item {\ttfamily source\+File} the URL of the original source file.
\item {\ttfamily source\+Content} the content of the source file.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{generator.setSourceContent("{}module-\/one.scm"{},}
\DoxyCodeLine{                           fs.readFileSync("{}path/to/module-\/one.scm"{})) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32760}{}\doxysubsubsection{Source\+Map\+Generator.\+prototype.\+apply\+Source\+Map(source\+Map\+Consumer\mbox{[}, source\+File\mbox{[}, source\+Map\+Path\mbox{]}\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32760}
Applies a Source\+Map for a source file to the Source\+Map. Each mapping to the supplied source file is rewritten using the supplied Source\+Map. Note\+: The resolution for the resulting mappings is the minimum of this map and the supplied map.


\begin{DoxyItemize}
\item {\ttfamily source\+Map\+Consumer}\+: The Source\+Map to be applied.
\item {\ttfamily source\+File}\+: Optional. The filename of the source file. If omitted, source\+Map\+Consumer.\+file will be used, if it exists. Otherwise an error will be thrown.
\item {\ttfamily source\+Map\+Path}\+: Optional. The dirname of the path to the Source\+Map to be applied. If relative, it is relative to the Source\+Map.

This parameter is needed when the two Source\+Maps aren\textquotesingle{}t in the same directory, and the Source\+Map to be applied contains relative source paths. If so, those relative source paths need to be rewritten relative to the Source\+Map.

If omitted, it is assumed that both Source\+Maps are in the same directory, thus not needing any rewriting. (Supplying `'.\textquotesingle{}\`{} has the same effect.)
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32761}{}\doxysubsubsection{Source\+Map\+Generator.\+prototype.\+to\+String()}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32761}
Renders the source map being generated to a string.


\begin{DoxyCode}{0}
\DoxyCodeLine{generator.toString()}
\DoxyCodeLine{// '\{"{}version"{}:3,"{}sources"{}:["{}module-\/one.scm"{}],"{}names"{}:[],"{}mappings"{}:"{}...snip..."{},"{}file"{}:"{}my-\/generated-\/javascript-\/file.js"{},"{}sourceRoot"{}:"{}http://example.com/app/js/"{}\}' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32762}{}\doxysubsection{Source\+Node}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32762}
Source\+Nodes provide a way to abstract over interpolating and/or concatenating snippets of generated Java\+Script source code, while maintaining the line and column information associated between those snippets and the original source code. This is useful as the final intermediate representation a compiler might use before outputting the generated JS and source map.\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32763}{}\doxysubsubsection{new Source\+Node(\mbox{[}line, column, source\mbox{[}, chunk\mbox{[}, name\mbox{]}\mbox{]}\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32763}

\begin{DoxyItemize}
\item {\ttfamily line}\+: The original line number associated with this source node, or null if it isn\textquotesingle{}t associated with an original line. The line number is 1-\/based.
\item {\ttfamily column}\+: The original column number associated with this source node, or null if it isn\textquotesingle{}t associated with an original column. The column number is 0-\/based.
\item {\ttfamily source}\+: The original source\textquotesingle{}s filename; null if no filename is provided.
\item {\ttfamily chunk}\+: Optional. Is immediately passed to {\ttfamily Source\+Node.\+prototype.\+add}, see below.
\item {\ttfamily name}\+: Optional. The original identifier.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var node = new SourceNode(1, 2, "{}a.cpp"{}, [}
\DoxyCodeLine{  new SourceNode(3, 4, "{}b.cpp"{}, "{}extern int status;\(\backslash\)n"{}),}
\DoxyCodeLine{  new SourceNode(5, 6, "{}c.cpp"{}, "{}std::string* make\_string(size\_t n);\(\backslash\)n"{}),}
\DoxyCodeLine{  new SourceNode(7, 8, "{}d.cpp"{}, "{}int main(int argc, char** argv) \{\}\(\backslash\)n"{}),}
\DoxyCodeLine{]); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32764}{}\doxysubsubsection{Source\+Node.\+from\+String\+With\+Source\+Map(code, source\+Map\+Consumer\mbox{[}, relative\+Path\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32764}
Creates a Source\+Node from generated code and a Source\+Map\+Consumer.


\begin{DoxyItemize}
\item {\ttfamily code}\+: The generated code
\item {\ttfamily source\+Map\+Consumer} The Source\+Map for the generated code
\item {\ttfamily relative\+Path} The optional path that relative sources in {\ttfamily source\+Map\+Consumer} should be relative to.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var consumer = new SourceMapConsumer(fs.readFileSync("{}path/to/my-\/file.js.map"{}, "{}utf8"{}));}
\DoxyCodeLine{var node = SourceNode.fromStringWithSourceMap(fs.readFileSync("{}path/to/my-\/file.js"{}),}
\DoxyCodeLine{                                              consumer); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32765}{}\doxysubsubsection{Source\+Node.\+prototype.\+add(chunk)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32765}
Add a chunk of generated JS to this source node.


\begin{DoxyItemize}
\item {\ttfamily chunk}\+: A string snippet of generated JS code, another instance of {\ttfamily Source\+Node}, or an array where each member is one of those things.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{node.add("{} + "{});}
\DoxyCodeLine{node.add(otherNode);}
\DoxyCodeLine{node.add([leftHandOperandNode, "{} + "{}, rightHandOperandNode]); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32766}{}\doxysubsubsection{Source\+Node.\+prototype.\+prepend(chunk)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32766}
Prepend a chunk of generated JS to this source node.


\begin{DoxyItemize}
\item {\ttfamily chunk}\+: A string snippet of generated JS code, another instance of {\ttfamily Source\+Node}, or an array where each member is one of those things.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{node.prepend("{}/** Build Id: f783haef86324gf **/\(\backslash\)n\(\backslash\)n"{}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32767}{}\doxysubsubsection{Source\+Node.\+prototype.\+set\+Source\+Content(source\+File, source\+Content)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32767}
Set the source content for a source file. This will be added to the {\ttfamily Source\+Map} in the {\ttfamily sources\+Content} field.


\begin{DoxyItemize}
\item {\ttfamily source\+File}\+: The filename of the source file
\item {\ttfamily source\+Content}\+: The content of the source file
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{node.setSourceContent("{}module-\/one.scm"{},}
\DoxyCodeLine{                      fs.readFileSync("{}path/to/module-\/one.scm"{})) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32768}{}\doxysubsubsection{Source\+Node.\+prototype.\+walk(fn)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32768}
Walk over the tree of JS snippets in this node and its children. The walking function is called once for each snippet of JS and is passed that snippet and the its original associated source\textquotesingle{}s line/column location.


\begin{DoxyItemize}
\item {\ttfamily fn}\+: The traversal function.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var node = new SourceNode(1, 2, "{}a.js"{}, [}
\DoxyCodeLine{  new SourceNode(3, 4, "{}b.js"{}, "{}uno"{}),}
\DoxyCodeLine{  "{}dos"{},}
\DoxyCodeLine{  [}
\DoxyCodeLine{    "{}tres"{},}
\DoxyCodeLine{    new SourceNode(5, 6, "{}c.js"{}, "{}quatro"{})}
\DoxyCodeLine{  ]}
\DoxyCodeLine{]);}
\DoxyCodeLine{}
\DoxyCodeLine{node.walk(function (code, loc) \{ console.log("{}WALK:"{}, code, loc); \})}
\DoxyCodeLine{// WALK: uno \{ source: 'b.js', line: 3, column: 4, name: null \}}
\DoxyCodeLine{// WALK: dos \{ source: 'a.js', line: 1, column: 2, name: null \}}
\DoxyCodeLine{// WALK: tres \{ source: 'a.js', line: 1, column: 2, name: null \}}
\DoxyCodeLine{// WALK: quatro \{ source: 'c.js', line: 5, column: 6, name: null \} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32769}{}\doxysubsubsection{Source\+Node.\+prototype.\+walk\+Source\+Contents(fn)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32769}
Walk over the tree of Source\+Nodes. The walking function is called for each source file content and is passed the filename and source content.


\begin{DoxyItemize}
\item {\ttfamily fn}\+: The traversal function.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var a = new SourceNode(1, 2, "{}a.js"{}, "{}generated from a"{});}
\DoxyCodeLine{a.setSourceContent("{}a.js"{}, "{}original a"{});}
\DoxyCodeLine{var b = new SourceNode(1, 2, "{}b.js"{}, "{}generated from b"{});}
\DoxyCodeLine{b.setSourceContent("{}b.js"{}, "{}original b"{});}
\DoxyCodeLine{var c = new SourceNode(1, 2, "{}c.js"{}, "{}generated from c"{});}
\DoxyCodeLine{c.setSourceContent("{}c.js"{}, "{}original c"{});}
\DoxyCodeLine{}
\DoxyCodeLine{var node = new SourceNode(null, null, null, [a, b, c]);}
\DoxyCodeLine{node.walkSourceContents(function (source, contents) \{ console.log("{}WALK:"{}, source, "{}:"{}, contents); \})}
\DoxyCodeLine{// WALK: a.js : original a}
\DoxyCodeLine{// WALK: b.js : original b}
\DoxyCodeLine{// WALK: c.js : original c }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32770}{}\doxysubsubsection{Source\+Node.\+prototype.\+join(sep)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32770}
Like {\ttfamily Array.\+prototype.\+join} except for Source\+Nodes. Inserts the separator between each of this source node\textquotesingle{}s children.


\begin{DoxyItemize}
\item {\ttfamily sep}\+: The separator.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var lhs = new SourceNode(1, 2, "{}a.rs"{}, "{}my\_copy"{});}
\DoxyCodeLine{var operand = new SourceNode(3, 4, "{}a.rs"{}, "{}="{});}
\DoxyCodeLine{var rhs = new SourceNode(5, 6, "{}a.rs"{}, "{}orig.clone()"{});}
\DoxyCodeLine{}
\DoxyCodeLine{var node = new SourceNode(null, null, null, [ lhs, operand, rhs ]);}
\DoxyCodeLine{var joinedNode = node.join("{} "{}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32771}{}\doxysubsubsection{Source\+Node.\+prototype.\+replace\+Right(pattern, replacement)}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32771}
Call {\ttfamily String.\+prototype.\+replace} on the very right-\/most source snippet. Useful for trimming white space from the end of a source node, etc.


\begin{DoxyItemize}
\item {\ttfamily pattern}\+: The pattern to replace.
\item {\ttfamily replacement}\+: The thing to replace the pattern with.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{// Trim trailing white space.}
\DoxyCodeLine{node.replaceRight(/\(\backslash\)s*\$/, "{}"{}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32772}{}\doxysubsubsection{Source\+Node.\+prototype.\+to\+String()}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32772}
Return the string representation of this source node. Walks over the tree and concatenates all the various snippets together to one string.


\begin{DoxyCode}{0}
\DoxyCodeLine{var node = new SourceNode(1, 2, "{}a.js"{}, [}
\DoxyCodeLine{  new SourceNode(3, 4, "{}b.js"{}, "{}uno"{}),}
\DoxyCodeLine{  "{}dos"{},}
\DoxyCodeLine{  [}
\DoxyCodeLine{    "{}tres"{},}
\DoxyCodeLine{    new SourceNode(5, 6, "{}c.js"{}, "{}quatro"{})}
\DoxyCodeLine{  ]}
\DoxyCodeLine{]);}
\DoxyCodeLine{}
\DoxyCodeLine{node.toString()}
\DoxyCodeLine{// 'unodostresquatro' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32773}{}\doxysubsubsection{Source\+Node.\+prototype.\+to\+String\+With\+Source\+Map(\mbox{[}start\+Of\+Source\+Map\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_source_map_README_autotoc_md32773}
Returns the string representation of this tree of source nodes, plus a Source\+Map\+Generator which contains all the mappings between the generated and original sources.

The arguments are the same as those to {\ttfamily new Source\+Map\+Generator}.


\begin{DoxyCode}{0}
\DoxyCodeLine{var node = new SourceNode(1, 2, "{}a.js"{}, [}
\DoxyCodeLine{  new SourceNode(3, 4, "{}b.js"{}, "{}uno"{}),}
\DoxyCodeLine{  "{}dos"{},}
\DoxyCodeLine{  [}
\DoxyCodeLine{    "{}tres"{},}
\DoxyCodeLine{    new SourceNode(5, 6, "{}c.js"{}, "{}quatro"{})}
\DoxyCodeLine{  ]}
\DoxyCodeLine{]);}
\DoxyCodeLine{}
\DoxyCodeLine{node.toStringWithSourceMap(\{ file: "{}my-\/output-\/file.js"{} \})}
\DoxyCodeLine{// \{ code: 'unodostresquatro',}
\DoxyCodeLine{//   map: [object SourceMapGenerator] \} }

\end{DoxyCode}
 