function decodeMappings
decodeMappings(mappings: string): Segment[][]

Parses the compact mappings string from a source-map V3 object into a per-line array of segments, sorted by generatedCol (esbuild always emits them in order).

Source-coordinate deltas (sourceIndex, sourceLine, sourceCol) are cumulative across the entire string; only generatedCol resets to 0 at each new line.

mappings.length is read into a local because V8 won't reliably hoist string-length accesses out of a hot loop containing further string ops. Branches are ordered by descending frequency: the VLQ default fires for every segment (~64K calls per real bundle), , fires N − L times, ; only L − 1 times.

import * as SourceMap from './source-map.ts';

SourceMap.decodeMappings('AAAA;AACA');
// [ [{ generatedCol: 0, sourceIndex: 0, sourceLine: 0, sourceCol: 0 }],
//   [{ generatedCol: 0, sourceIndex: 0, sourceLine: 1, sourceCol: 0 }] ] — deltas accumulate

Parameters

mappings: string

Return Type

Usage

import { decodeMappings } from "lib/utils/source-map.ts";