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

x/source_map/mod.js>SourceMapConsumer.with

Port of mozilla / source-map to deno.
Latest
method SourceMapConsumer.with
import { SourceMapConsumer } from "https://deno.land/x/source_map@0.8.0-beta.1/mod.js";

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);

Parameters

rawSourceMap
sourceMapUrl
f