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

StepMap

A map describing the deletions and insertions made by a step, which can be used to find the correspondence between positions in the pre-step version of a document and the same position in the post-step version.

class StepMap implements Mappable {
constructor(ranges: readonly number[], inverted?: boolean);
forEach(f: (
oldStart: number,
oldEnd: number,
newStart: number,
newEnd: number,
) => void
): void;
invert(): StepMap;
map(pos: number, assoc?: number): number;
mapResult(pos: number, assoc?: number): MapResult;
 
static empty: StepMap;
 
static offset(n: number): StepMap;
}

§Implements

§Constructors

§
new StepMap(ranges: readonly number[], inverted?: boolean)
[src]

Create a position map. The modifications to the document are represented as an array of numbers, in which each group of three represents a modified chunk as [start, oldSize, newSize].

§Methods

§
forEach(f: (oldStart: number, oldEnd: number, newStart: number, newEnd: number) => void): void
[src]

Calls the given function on each of the changed ranges included in this map.

§
invert(): StepMap
[src]

Create an inverted version of this map. The result can be used to map positions in the post-step document to the pre-step document.

§
map(pos: number, assoc?: number): number
[src]
§
mapResult(pos: number, assoc?: number): MapResult
[src]

§Static Properties

§

A StepMap that contains no changed ranges.

§Static Methods

§
offset(n: number): StepMap
[src]

Create a map that moves all positions by offset n (which may be negative). This can be useful when applying steps meant for a sub-document to a larger document, or vice-versa.