Skip to main content
import { SourceMap } from 'voltaire-effect/primitives'
import * as Schema from 'effect/Schema'
import { Effect } from 'effect'

// Parse source map string
const sm = Effect.runSync(SourceMap.from('0:10:0:-;10:5:0:i'))

// Get entries
const entries = SourceMap.toEntries(sm)
console.log(entries[0]) // { start: 0, length: 10, fileIndex: 0, jump: '-' }

// Get specific entry
const entry = SourceMap.getEntryAt(sm, 1)
console.log(entry?.jump) // 'i' (into function)

// Back to string
const raw = SourceMap.toString(sm)

Entry Fields

FieldDescription
startByte offset in source
lengthSource range length
fileIndexSource file index
jump'i' (into), 'o' (out), '-' (regular)
modifierDepthOptional modifier depth

API

FunctionType
SchemaSchema<SourceMapType, string>
from(raw: string) => Effect<SourceMapType, SourceMapError>
toEntries(sm: SourceMapType) => SourceMapEntry[]
getEntryAt(sm: SourceMapType, index: number) => SourceMapEntry | undefined
toString(sm: SourceMapType) => string