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

x/source_map/lib/source-node.js>default

Port of mozilla / source-map to deno.
Latest
class default
import { default } from "https://deno.land/x/source_map@0.8.0-beta.1/lib/source-node.js";

SourceNodes provide a way to abstract over interpolating/concatenating snippets of generated JavaScript source code while maintaining the line and column information associated with the original source code.

Constructors

new
default(
aLine,
aColumn,
aSource,
aChunks,
aName,
)

Methods

add(aChunk)

Add a chunk of generated JS to this source node.

join(aSep)

Like String.prototype.join except for SourceNodes. Inserts aStr between each of this.children.

prepend(aChunk)

Add a chunk of generated JS to the beginning of this source node.

replaceRight(aPattern, aReplacement)

Call String.prototype.replace on the very right-most source snippet. Useful for trimming whitespace from the end of a source node, etc.

setSourceContent(aSourceFile, aSourceContent)

Set the source content for a source file. This will be added to the SourceMapGenerator in the sourcesContent field.

Return the string representation of this source node. Walks over the tree and concatenates all the various snippets together to one string.

Returns the string representation of this source node along with a source map.

walk(aFn)

Walk over the tree of JS snippets in this node and its children. The walking function is called once for each snippet of JS and is passed that snippet and the its original associated source's line/column location.

Walk over the tree of SourceNodes. The walking function is called for each source file content and is passed the filename and source content.

Static Methods

fromStringWithSourceMap(
aGeneratedCode,
aSourceMapConsumer,
aRelativePath,
)

Creates a SourceNode from generated code and a SourceMapConsumer.