# source-list-map

> Fast line to line SourceMap generator.

Latest version **2.0.1** (published 2018-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install source-list-map
pnpm add source-list-map
yarn add source-list-map
bun add source-list-map
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2018-10-10 |
| First published | 2015-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/source-list-map) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 41 |
| Author | Tobias Koppers @sokra |
| Maintainers | sokra |
| Keywords | source-map |

## Links

- npm: https://www.npmjs.com/package/source-list-map
- Repository: https://github.com/webpack/source-list-map
- Issues: https://github.com/webpack/source-list-map/issues
- npm.io page: https://npm.io/package/source-list-map

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2018-10-10
- 2.0.0 — 2017-06-03
- 1.1.2 — 2017-05-04
- 1.1.1 — 2017-03-24
- 1.1.0 — 2017-03-24
- 1.0.1 — 2017-03-07
- 1.0.0 — 2017-03-07
- 0.1.8 — 2017-01-11
- 0.1.7 — 2016-12-02
- 0.1.6 — 2016-03-24
- 0.1.5 — 2015-04-13
- 0.1.4 — 2015-04-08
- 0.1.3 — 2015-04-08
- 0.1.2 — 2015-04-07
- 0.1.1 — 2015-04-07
- … 1 more at https://npm.io/package/source-list-map/versions

## README

# source-list-map

## API

### Example

``` js
var SourceListMap = require("source-list-map").SourceListMap;

// Create a new map
var map = new SourceListMap();

// Add generated code that is map line to line to some soure
map.add("Generated\ncode1\n", "source-code.js", "Orginal\nsource");

// Add generated code that isn't mapped
map.add("Generated\ncode2\n");

// Get SourceMap and generated source
map.toStringWithSourceMap({ file: "generated-code.js" });
// {
//   source: 'Generated\ncode1\nGenerated\ncode2\n',
//   map: {
//      version: 3,
//      file: 'generated-code.js',
//      sources: [ 'source-code.js' ],
//      sourcesContent: [ 'Orginal\nsource' ],
//      mappings: 'AAAA;AACA;;;'
//    }
// }

// Convert existing SourceMap into SourceListMap
// (Only the first mapping per line is preserved)
var fromStringWithSourceMap = require("source-list-map").fromStringWithSourceMap;
var map = fromStringWithSourceMap("Generated\ncode", { version: 3, ... });

```

### `new SourceListMap()`

### `SourceListMap.prototype.add`

``` js
SourceListMap.prototype.add(generatedCode: string)
SourceListMap.prototype.add(generatedCode: string, source: string, originalSource: string)
SourceListMap.prototype.add(sourceListMap: SourceListMap)
```

Append some stuff.

### `SourceListMap.prototype.prepend`

``` js
SourceListMap.prototype.prepend(generatedCode: string)
SourceListMap.prototype.prepend(generatedCode: string, source: string, originalSource: string)
SourceListMap.prototype.prepend(sourceListMap: SourceListMap)
```

Prepend some stuff.

### `SourceListMap.prototype.toString()`

Get generated code.

### `SourceListMap.prototype.toStringWithSourceMap`

``` js
SourceListMap.prototype.toStringWithSourceMap(options: object)
```

Get generated code and SourceMap. `options` can contains `file` property which defines the `file` property of the SourceMap.

### `SourceListMap.prototype.mapGeneratedCode`

``` js
SourceListMap.prototype.mapGeneratedCode(fn: function) : SourceListMap
```

Applies `fn` to each generated code block (per line). The returned value is set as new generated code. Returns a new SourceListMap.

Removing and adding lines is supported. The SourceMap complexity will increase when doing this.

## Test

[![Build Status](https://travis-ci.org/webpack/source-list-map.svg)](https://travis-ci.org/webpack/source-list-map)

## License

Copyright (c) 2017 JS Foundation

MIT (http://www.opensource.org/licenses/mit-license.php)

---
_Source: https://npm.io/package/source-list-map · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
