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 | 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
§
prototype: SourceMapConsumer
[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 | RawIndexMap | string, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer | IndexedSourceMapConsumer>
[src]§
with<T>(
[src]rawSourceMap: RawSourceMap | RawIndexMap | string,
sourceMapUrl: SourceMapUrl | null | undefined,
callback: (consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer) => Promise<T> | T,
): Promise<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);