Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

SourceMapConsumerConstructor

interface SourceMapConsumerConstructor {
GENERATED_ORDER: number;
GREATEST_LOWER_BOUND: number;
LEAST_UPPER_BOUND: number;
ORIGINAL_ORDER: number;
prototype: SourceMapConsumer;
fromSourceMap(sourceMap: SourceMapGenerator, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>;
new (rawSourceMap: RawSourceMap, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>;
new (rawSourceMap: RawIndexMap, sourceMapUrl?: SourceMapUrl): Promise<IndexedSourceMapConsumer>;
new (rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer | IndexedSourceMapConsumer>;
with<T>(
rawSourceMap: RawSourceMap | RawIndexMap | string,
sourceMapUrl: SourceMapUrl | null | undefined,
callback: (consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer) => Promise<T> | T,
): Promise<T>;
}

§Properties

§
GENERATED_ORDER: number
[src]
§
GREATEST_LOWER_BOUND: number
[src]
§
LEAST_UPPER_BOUND: number
[src]
§
ORIGINAL_ORDER: number
[src]

§Methods

§
fromSourceMap(sourceMap: SourceMapGenerator, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>
[src]

Create a BasicSourceMapConsumer from a SourceMapGenerator.

@param sourceMap

The source map that will be consumed.

§
new (rawSourceMap: RawSourceMap, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>
[src]
§
new (rawSourceMap: RawIndexMap, sourceMapUrl?: SourceMapUrl): Promise<IndexedSourceMapConsumer>
[src]
§
new (rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer | IndexedSourceMapConsumer>
[src]
§
with<T>(
rawSourceMap: RawSourceMap | RawIndexMap | string,
sourceMapUrl: SourceMapUrl | null | undefined,
callback: (consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer) => Promise<T> | T,
): Promise<T>
[src]

Construct a new SourceMapConsumer from rawSourceMap and sourceMapUrl (see the SourceMapConsumer constructor for details. Then, invoke the async function f(SourceMapConsumer) -> T with the newly constructed consumer, wait for f to complete, call destroy on the consumer, and return f's return value.

You must not use the consumer after f completes!

By using with, you do not have to remember to manually call destroy on the consumer, since it will be called automatically once f completes.

const xSquared = await SourceMapConsumer.with(
  myRawSourceMap,
  null,
  async function (consumer) {
    // Use `consumer` inside here and don't worry about remembering
    // to call `destroy`.

    const x = await whatever(consumer);
    return x * x;
  }
);

// You may not use that `consumer` anymore out here; it has
// been destroyed. But you can use `xSquared`.
console.log(xSquared);