High-performance VLQ source map codec powered by Rust via NAPI.
Drop-in replacement for @jridgewell/sourcemap-codec. Encodes and decodes source map mappings strings as specified in ECMA-426.
npm install @srcmap/codecPrebuilt binaries are available for:
- macOS (x64, arm64)
- Linux (x64, arm64, glibc + musl)
- Windows (x64)
import { decode, encode } from '@srcmap/codec';
const decoded = decode('AAAA;AACA,EAAE');
// [
// [[0, 0, 0, 0]],
// [[0, 0, 1, 0], [2, 0, 0, 2]]
// ]
const encoded = encode(decoded);
// 'AAAA;AACA,EAAE'Decode a VLQ-encoded mappings string into an array of lines, each containing an array of segments. Each segment is an array of 1, 4, or 5 numbers.
Encode decoded mappings back into a VLQ string.
| Fields | Meaning |
|---|---|
[genCol] |
Generated column only |
[genCol, srcIdx, origLine, origCol] |
With source mapping |
[genCol, srcIdx, origLine, origCol, nameIdx] |
With source mapping and name |
API-compatible with @jridgewell/sourcemap-codec — same function signatures, same output format. Can be used as a drop-in replacement.
Part of srcmap
High-performance source map tooling written in Rust. See also:
-
@srcmap/sourcemap- Source map parser (NAPI) -
@srcmap/sourcemap-wasm- Source map parser (WASM)
MIT