\href{https://ci.testling.com/lydell/source-map-url}{\texttt{ }}

Tools for working with source\+Mapping\+URL comments.


\begin{DoxyCode}{0}
\DoxyCodeLine{var sourceMappingURL = require("{}source-\/map-\/url"{})}
\DoxyCodeLine{}
\DoxyCodeLine{var code = [}
\DoxyCodeLine{  "{}!function()\{...\}();"{},}
\DoxyCodeLine{  "{}/*\# sourceMappingURL=foo.js.map */"{}}
\DoxyCodeLine{].join("{}\(\backslash\)n"{})}
\DoxyCodeLine{}
\DoxyCodeLine{sourceMappingURL.existsIn(code)}
\DoxyCodeLine{// true}
\DoxyCodeLine{}
\DoxyCodeLine{sourceMappingURL.getFrom(code)}
\DoxyCodeLine{// foo.js.map}
\DoxyCodeLine{}
\DoxyCodeLine{code = sourceMappingURL.insertBefore(code, "{}// License: MIT\(\backslash\)n"{})}
\DoxyCodeLine{// !function()\{...\}();}
\DoxyCodeLine{// // License: MIT}
\DoxyCodeLine{// /*\# sourceMappingURL=foo.js.map */}
\DoxyCodeLine{}
\DoxyCodeLine{code = sourceMappingURL.removeFrom(code)}
\DoxyCodeLine{// !function()\{...\}();}
\DoxyCodeLine{// // License: MIT}
\DoxyCodeLine{}
\DoxyCodeLine{sourceMappingURL.existsIn(code)}
\DoxyCodeLine{// false}
\DoxyCodeLine{}
\DoxyCodeLine{sourceMappingURL.getFrom(code)}
\DoxyCodeLine{// null}
\DoxyCodeLine{}
\DoxyCodeLine{code += "{}//\# sourceMappingURL=/other/file.js.map"{}}
\DoxyCodeLine{// !function()\{...\}();}
\DoxyCodeLine{// // License: MIT}
\DoxyCodeLine{// //\# sourceMappingURL=/other/file.js.map }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_source_map_url_readme_autotoc_md28571}{}\doxysection{Installation}\label{md_sfcode_node_modules_source_map_url_readme_autotoc_md28571}

\begin{DoxyItemize}
\item {\ttfamily npm install source-\/map-\/url}
\item {\ttfamily bower install source-\/map-\/url}
\item {\ttfamily component install lydell/source-\/map-\/url}
\end{DoxyItemize}

Works with Common\+JS, AMD and browser globals, through UMD.\hypertarget{md_sfcode_node_modules_source_map_url_readme_autotoc_md28572}{}\doxysection{Usage}\label{md_sfcode_node_modules_source_map_url_readme_autotoc_md28572}
\hypertarget{md_sfcode_node_modules_source_map_url_readme_autotoc_md28573}{}\doxysubsubsection{$<$tt$>$source\+Mapping\+URL.\+get\+From(code)$<$/tt$>$}\label{md_sfcode_node_modules_source_map_url_readme_autotoc_md28573}
Returns the url of the source\+Mapping\+URL comment in {\ttfamily code}. Returns {\ttfamily null} if there is no such comment.\hypertarget{md_sfcode_node_modules_source_map_url_readme_autotoc_md28574}{}\doxysubsubsection{$<$tt$>$source\+Mapping\+URL.\+exists\+In(code)$<$/tt$>$}\label{md_sfcode_node_modules_source_map_url_readme_autotoc_md28574}
Returns {\ttfamily true} if there is a source\+Mapping\+URL comment in {\ttfamily code}, or {\ttfamily false} otherwise.\hypertarget{md_sfcode_node_modules_source_map_url_readme_autotoc_md28575}{}\doxysubsubsection{$<$tt$>$source\+Mapping\+URL.\+remove\+From(code)$<$/tt$>$}\label{md_sfcode_node_modules_source_map_url_readme_autotoc_md28575}
Removes the source\+Mapping\+URL comment in {\ttfamily code}. Does nothing if there is no such comment. Returns the updated {\ttfamily code}.\hypertarget{md_sfcode_node_modules_source_map_url_readme_autotoc_md28576}{}\doxysubsubsection{$<$tt$>$source\+Mapping\+URL.\+insert\+Before(code, string)$<$/tt$>$}\label{md_sfcode_node_modules_source_map_url_readme_autotoc_md28576}
Inserts {\ttfamily string} before the source\+Mapping\+URL comment in {\ttfamily code}. Appends {\ttfamily string} to {\ttfamily code} if there is no such comment.

Lets you append something to a file without worrying about burying the source\+Mapping\+URL comment (by keeping it at the end of the file).\hypertarget{md_sfcode_node_modules_source_map_url_readme_autotoc_md28577}{}\doxysubsubsection{$<$tt$>$source\+Mapping\+URL.\+regex$<$/tt$>$}\label{md_sfcode_node_modules_source_map_url_readme_autotoc_md28577}
The regex that is used to match source\+Mapping\+URL comments. It matches both {\ttfamily //} and {\ttfamily /$\ast$$\ast$/} comments, thus supporting both Java\+Script and CSS.\hypertarget{md_sfcode_node_modules_source_map_url_readme_autotoc_md28578}{}\doxysection{Tests}\label{md_sfcode_node_modules_source_map_url_readme_autotoc_md28578}
Start by running {\ttfamily npm test}, which lints the code and runs the test suite in Node.\+js.

To run the tests in a browser, run {\ttfamily testling} ({\ttfamily npm install -\/g testling}) or {\ttfamily testling -\/u}.\hypertarget{md_sfcode_node_modules_source_map_url_readme_autotoc_md28579}{}\doxysection{License}\label{md_sfcode_node_modules_source_map_url_readme_autotoc_md28579}
\mbox{[}The X11 (“\+MIT”) License\mbox{]}(LICENSE). 