import { type SourceMapConsumerConstructor } from "https://deno.land/x/source_map@0.8.0-beta.1/source-map.d.ts";
Properties
prototype: SourceMapConsumer
Methods
new(rawSourceMap: RawSourceMap, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>
new(rawSourceMap: RawIndexMap, sourceMapUrl?: SourceMapUrl): Promise<IndexedSourceMapConsumer>
new(rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer | IndexedSourceMapConsumer>
fromSourceMap(sourceMap: SourceMapGenerator, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>
Create a BasicSourceMapConsumer from a SourceMapGenerator.
with<T>(): Promise<T>
rawSourceMap: RawSourceMap | RawIndexMap | string,
sourceMapUrl: SourceMapUrl | null | undefined,
callback: (consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer) => Promise<T> | T,
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);