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

Mapping

A mapping represents a pipeline of zero or more step maps. It has special provisions for losslessly handling mapping positions through a series of steps in which some steps are inverted versions of earlier steps. (This comes up when ‘rebasing’ steps for collaboration or history management.)

class Mapping implements Mappable {
constructor(
maps?: StepMap[],
mirror?: number[] | undefined,
from?: number,
to?: number,
);
from: number;
readonly maps: StepMap[];
to: number;
 
appendMap(map: StepMap, mirrors?: number): void;
appendMapping(mapping: Mapping): void;
appendMappingInverted(mapping: Mapping): void;
getMirror(n: number): number | undefined;
invert(): Mapping;
map(pos: number, assoc?: number): number;
mapResult(pos: number, assoc?: number): MapResult;
slice(from?: number, to?: number): Mapping;
}

§Implements

§Constructors

§
new Mapping(maps?: StepMap[], mirror?: number[] | undefined, from?: number, to?: number)
[src]

Create a new mapping with the given position maps.

§Properties

§
from: number
[src]

The starting position in the maps array, used when map or mapResult is called.

§
maps: StepMap[]
[src]

The step maps in this mapping.

§
to: number
[src]

The end position in the maps array.

§Methods

§
appendMap(map: StepMap, mirrors?: number): void
[src]

Add a step map to the end of this mapping. If mirrors is given, it should be the index of the step map that is the mirror image of this one.

§
appendMapping(mapping: Mapping): void
[src]

Add all the step maps in a given mapping to this one (preserving mirroring information).

§
appendMappingInverted(mapping: Mapping): void
[src]

Append the inverse of the given mapping to this one.

§
getMirror(n: number): number | undefined
[src]

Finds the offset of the step map that mirrors the map at the given offset, in this mapping (as per the second argument to appendMap).

§
invert(): Mapping
[src]

Create an inverted version of this mapping.

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

Map a position through this mapping.

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

Map a position through this mapping, returning a mapping result.

§
slice(from?: number, to?: number): Mapping
[src]

Create a mapping that maps only through a part of this one.