# source-map-index-generator

> Generate source-maps from index mappings

Latest version **0.1.2** (published 2013-06-19) · 0 weekly downloads

## Install

```sh
npm install source-map-index-generator
pnpm add source-map-index-generator
yarn add source-map-index-generator
bun add source-map-index-generator
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2013-06-19 |
| First published | 2013-02-06 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.6.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Todd Wolfson |
| Maintainers | twolfson |
| Keywords | source-map, sourcemap, char, charAt, index, generator |

## Links

- npm: https://www.npmjs.com/package/source-map-index-generator
- Repository: https://github.com/twolfson/source-map-index-generator
- Issues: https://github.com/twolfson/source-map-index-generator/issues
- npm.io page: https://npm.io/package/source-map-index-generator

## Dependencies (2)

- [char-props](https://npm.io/package/char-props.md) ~0.1.3
- [source-map](https://npm.io/package/source-map.md) ~0.1.8

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2013-06-19
- 0.1.1 — 2013-02-06
- 0.1.0 — 2013-02-06

## README

# source-map-index-generator [![Donate on Gittip](http://badgr.co/gittip/twolfson.png)](https://www.gittip.com/twolfson/)

Generate [source-maps][sourcemap] from index mappings.

[sourcemap]: https://github.com/mozilla/source-map

## Getting Started
Install the module with: `npm install source-map-index-generator`

```javascript
// Load in SourceMapIndexGenerator
var SourceMapIndexGenerator = require('source-map-index-generator');

// Data output by node-jsmin2
var input = [
      '// First line comment',
      'var test = {',
      '  a: "b"',
      '};'
    ].join('\n'),
    output = 'var test={a:"b"};',
    srcFile = 'input.js',
    coordmap = {"22":0,"23":1,"24":2,"25":3,"26":4,"27":5,"28":6,"29":7,"31":8,"33":9,"37":10,"38":11,"40":12,"41":13,"42":14,"44":15,"45":16};

// Generate source map via SourceMapIndexGenerator
var generator = new SourceMapIndexGenerator(generatorProps);

// Add the index coordinate mapping
generator.addIndexMapping({
  src: srcFile,
  input: input,
  output: output,
  map: coordmap
});

// Collect our source-map
generator.toString(); // {"version":3,"file":"min.js","sources":["input.js"],"names":[],"mappings":"AACA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAE,CACT,CAAC,CAAE,CAAC,CAAC,CACP,CAAC"}
```

## Documentation
This module returns a constructor for `SourceMapIndexGenerator`.

### new SourceMapIndexGenerator(startOfSourceMap)

To create a new one, you must pass an object with the following properties:

* `file`: The filename of the generated source that this source map is
  associated with.

* `sourceRoot`: An optional root for all relative URLs in this source map.

### SourceMapIndexGenerator.prototype.addIndexMapping(mapping)

Add code with an index based mapping to the file collection.

The mapping object
should have the following properties:

* `src`: Filepath to original src.

* `input`: Unminified JavaScript.

* `output`: Minified JavaScript.

* `map`: Map of character index to character index (number -> number)

* `lineOffset`: An optional line offset to add to mappings.

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/gruntjs/grunt).

## License
Copyright (c) 2013 Todd Wolfson
Licensed under the MIT license.

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