1 Overview [![Build Status](https://travis-ci.org/lydell/source-map-url.png?branch=master)](https://travis-ci.org/lydell/source-map-url)
4 [![browser support](https://ci.testling.com/lydell/source-map-url.png)](https://ci.testling.com/lydell/source-map-url)
6 Tools for working with sourceMappingURL comments.
9 var sourceMappingURL = require("source-map-url")
12 "!function(){...}();",
13 "/*# sourceMappingURL=foo.js.map */"
16 sourceMappingURL.existsIn(code)
19 sourceMappingURL.getFrom(code)
22 code = sourceMappingURL.insertBefore(code, "// License: MIT\n")
23 // !function(){...}();
25 // /*# sourceMappingURL=foo.js.map */
27 code = sourceMappingURL.removeFrom(code)
28 // !function(){...}();
31 sourceMappingURL.existsIn(code)
34 sourceMappingURL.getFrom(code)
37 code += "//# sourceMappingURL=/other/file.js.map"
38 // !function(){...}();
40 // //# sourceMappingURL=/other/file.js.map
47 - `npm install source-map-url`
48 - `bower install source-map-url`
49 - `component install lydell/source-map-url`
51 Works with CommonJS, AMD and browser globals, through UMD.
57 ### `sourceMappingURL.getFrom(code)` ###
59 Returns the url of the sourceMappingURL comment in `code`. Returns `null` if
60 there is no such comment.
62 ### `sourceMappingURL.existsIn(code)` ###
64 Returns `true` if there is a sourceMappingURL comment in `code`, or `false`
67 ### `sourceMappingURL.removeFrom(code)` ###
69 Removes the sourceMappingURL comment in `code`. Does nothing if there is no
70 such comment. Returns the updated `code`.
72 ### `sourceMappingURL.insertBefore(code, string)` ###
74 Inserts `string` before the sourceMappingURL comment in `code`. Appends
75 `string` to `code` if there is no such comment.
77 Lets you append something to a file without worrying about burying the
78 sourceMappingURL comment (by keeping it at the end of the file).
80 ### `sourceMappingURL.regex` ###
82 The regex that is used to match sourceMappingURL comments. It matches both `//`
83 and `/**/` comments, thus supporting both JavaScript and CSS.
89 Start by running `npm test`, which lints the code and runs the test suite in Node.js.
91 To run the tests in a browser, run `testling` (`npm install -g testling`) or `testling -u`.
97 [The X11 (“MIT”) License](LICENSE).