Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/source_map/source-map.d.ts>SourceMapConsumer

Port of mozilla / source-map to deno.
Latest
interface SourceMapConsumer
import { type SourceMapConsumer } from "https://deno.land/x/source_map@0.8.0-beta.1/source-map.d.ts";

Methods

computeColumnSpans(): void

Compute the last column for each generated mapping. The last column is inclusive.

originalPositionFor(generatedPosition: Position & { bias?: number; }): NullableMappedPosition

Returns the original source, line, and column information for the generated source's line and column positions provided. The only argument is an object with the following properties:

  • line: The line number in the generated source.
  • column: The column number in the generated source.
  • bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the closest element that is smaller than or greater than the one we are searching for, respectively, if the exact element cannot be found. Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.

and an object is returned with the following properties:

  • source: The original source file, or null.
  • line: The line number in the original source, or null.
  • column: The column number in the original source, or null.
  • name: The original identifier, or null.
generatedPositionFor(originalPosition: MappedPosition & { bias?: number; }): NullablePosition

Returns the generated line and column information for the original source, line, and column positions provided. The only argument is an object with the following properties:

  • source: The filename of the original source.
  • line: The line number in the original source.
  • column: The column number in the original source.
  • bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the closest element that is smaller than or greater than the one we are searching for, respectively, if the exact element cannot be found. Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.

and an object is returned with the following properties:

  • line: The line number in the generated source, or null.
  • column: The column number in the generated source, or null.
allGeneratedPositionsFor(originalPosition: MappedPosition): NullablePosition[]

Returns all generated line and column information for the original source, line, and column provided. If no column is provided, returns all mappings corresponding to a either the line we are searching for or the next closest line that has any mappings. Otherwise, returns all mappings corresponding to the given line and either the column we are searching for or the next closest column that has any offsets.

The only argument is an object with the following properties:

  • source: The filename of the original source.
  • line: The line number in the original source.
  • column: Optional. the column number in the original source.

and an array of objects is returned, each with the following properties:

  • line: The line number in the generated source, or null.
  • column: The column number in the generated source, or null.
hasContentsOfAllSources(): boolean

Return true if we have the source content for every source in the source map, false otherwise.

sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null

Returns the original source content. The only argument is the url of the original source file. Returns null if no original source content is available.

eachMapping(
callback: (mapping: MappingItem) => void,
context?: any,
order?: number,
): void

Iterate over each mapping between an original source/line/column and a generated line/column in this source map.

destroy(): void

Free this source map consumer's associated wasm data that is manually-managed. Alternatively, you can use SourceMapConsumer.with to avoid needing to remember to call destroy.

variable SourceMapConsumer
import { SourceMapConsumer } from "https://deno.land/x/source_map@0.8.0-beta.1/source-map.d.ts";