> For the complete documentation index, see [llms.txt](https://bryan-guner.gitbook.io/my-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bryan-guner.gitbook.io/my-docs/redux/repos/examples/real-world/node_modules/source-map-url.md).

# source-map-url

## Overview [![Build Status](https://travis-ci.org/lydell/source-map-url.png?branch=master)](https://travis-ci.org/lydell/source-map-url)

[![browser support](https://ci.testling.com/lydell/source-map-url.png)](https://ci.testling.com/lydell/source-map-url)

Tools for working with sourceMappingURL comments.

```js
var sourceMappingURL = require("source-map-url")

var code = [
  "!function(){...}();",
  "/*# sourceMappingURL=foo.js.map */"
].join("\n")

sourceMappingURL.existsIn(code)
// true

sourceMappingURL.getFrom(code)
// foo.js.map

code = sourceMappingURL.insertBefore(code, "// License: MIT\n")
// !function(){...}();
// // License: MIT
// /*# sourceMappingURL=foo.js.map */

code = sourceMappingURL.removeFrom(code)
// !function(){...}();
// // License: MIT

sourceMappingURL.existsIn(code)
// false

sourceMappingURL.getFrom(code)
// null

code += "//# sourceMappingURL=/other/file.js.map"
// !function(){...}();
// // License: MIT
// //# sourceMappingURL=/other/file.js.map
```

## Installation

* `npm install source-map-url`
* `bower install source-map-url`
* `component install lydell/source-map-url`

Works with CommonJS, AMD and browser globals, through UMD.

## Usage

#### `sourceMappingURL.getFrom(code)`

Returns the url of the sourceMappingURL comment in `code`. Returns `null` if there is no such comment.

#### `sourceMappingURL.existsIn(code)`

Returns `true` if there is a sourceMappingURL comment in `code`, or `false` otherwise.

#### `sourceMappingURL.removeFrom(code)`

Removes the sourceMappingURL comment in `code`. Does nothing if there is no such comment. Returns the updated `code`.

#### `sourceMappingURL.insertBefore(code, string)`

Inserts `string` before the sourceMappingURL comment in `code`. Appends `string` to `code` if there is no such comment.

Lets you append something to a file without worrying about burying the sourceMappingURL comment (by keeping it at the end of the file).

#### `sourceMappingURL.regex`

The regex that is used to match sourceMappingURL comments. It matches both `//` and `/**/` comments, thus supporting both JavaScript and CSS.

## Tests

Start by running `npm test`, which lints the code and runs the test suite in Node.js.

To run the tests in a browser, run `testling` (`npm install -g testling`) or `testling -u`.

## License

[The X11 (“MIT”) License](https://github.com/bgoonz/Learning-Redux/blob/master/repos/examples/real-world/node_modules/source-map-url/LICENSE/README.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://bryan-guner.gitbook.io/my-docs/redux/repos/examples/real-world/node_modules/source-map-url.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
