srcmap-codec 0.1.1

High-performance VLQ source map codec
Documentation

High-performance VLQ source map codec.

Encodes and decodes source map mappings using the Base64 VLQ format as specified in the Source Map v3 specification (ECMA-426).

Features

  • parallel — enables [encode_parallel] for multi-threaded encoding via rayon. ~1.5x faster for large maps (5K+ lines).

Examples

Decode and re-encode a mappings string:

use srcmap_codec::{decode, encode};

let mappings = decode("AAAA;AACA,EAAE").unwrap();
assert_eq!(mappings.len(), 2); // 2 lines
assert_eq!(mappings[0][0], vec![0, 0, 0, 0]); // first segment

let encoded = encode(&mappings);
assert_eq!(encoded, "AAAA;AACA,EAAE");

Low-level VLQ primitives:

use srcmap_codec::{vlq_decode, vlq_encode};

let mut buf = Vec::new();
vlq_encode(&mut buf, 42);

let (value, bytes_read) = vlq_decode(&buf, 0).unwrap();
assert_eq!(value, 42);