Skip to main content

Class: Mapping

Defined in: mapping.d.ts:4

Constructors

Constructor

new Mapping(): Mapping;

Defined in: mapping.d.ts:8

Creates an empty mapping.

Returns

Mapping

Constructor

new Mapping(record): Mapping;

Defined in: mapping.d.ts:14

Creates a mapping with the given key and value pairs. If a value contains a newline character, its style will be set to literal. Otherwise, the style will be set to double quoted.

Parameters

ParameterType
recordRecord<string, string>

Returns

Mapping

Constructor

new Mapping(object): Mapping;

Defined in: mapping.d.ts:20

Creates a mapping with the given object. Object keys will be converted to scalars and object values will be converted to scalars, sequences or mappings.

Parameters

ParameterType
objectObject

Returns

Mapping

Methods

clear()

clear(): void;

Defined in: mapping.d.ts:144

Clears all the contents of the mapping.

Returns

void


clone()

clone(): Mapping;

Defined in: mapping.d.ts:150

Returns a deep clone of the mapping.

Returns

Mapping


containsKey()

containsKey(key): boolean;

Defined in: mapping.d.ts:95

Returns true if the key exists in the keys list.

Parameters

ParameterType
keystring

Returns

boolean


ensureMapping()

Call Signature

ensureMapping(key): Mapping;

Defined in: mapping.d.ts:102

Ensures that the given key corresponds to a Mapping and returns it. Creates an empty Mapping if the key doesn't exist or it exists but correspond to an empty Scalar. Throws if the key exists but corresponds to a Sequence or a non-empty Scalar.

Parameters
ParameterType
keystring
Returns

Mapping

Call Signature

ensureMapping(keys): Mapping;

Defined in: mapping.d.ts:109

Ensures that the last key corresponds to a Mapping and returns it. Expects that each intermediate node is a Mapping. Creates an empty Mapping if the key doesn't exist or it exists but correspond to an empty Scalar. Throws if the last node exists but corresponds to a Sequence or a non-empty Scalar.

Parameters
ParameterType
keysstring[]
Returns

Mapping


ensureSequence()

Call Signature

ensureSequence(key): Sequence;

Defined in: mapping.d.ts:116

Ensures that the given key corresponds to a Sequence and returns it. Creates an empty Sequence if the key doesn't exist or it exists but correspond to an empty Scalar. Throws if the key exists but corresponds to a Mapping or a non-empty Scalar.

Parameters
ParameterType
keystring
Returns

Sequence

Call Signature

ensureSequence(keys): Sequence;

Defined in: mapping.d.ts:123

Ensures that the last key corresponds to a Sequence and returns it. Expects that each intermediate node is a Mapping. Creates an empty Sequence if the key doesn't exist or it exists but correspond to an empty Scalar. Throws if the last node exists but corresponds to a Mapping or a non-empty Scalar.

Parameters
ParameterType
keysstring[]
Returns

Sequence


getMapping()

Call Signature

getMapping(key): Mapping;

Defined in: mapping.d.ts:26

Returns the Mapping corresponding to the given key. Returns null if the key doesn't exist or it doesn't correspond to a Mapping.

Parameters
ParameterType
keystring
Returns

Mapping

Call Signature

getMapping(keys): Mapping;

Defined in: mapping.d.ts:32

Returns a Mapping by following each one of the keys. Expects that each intermediate node is a Mapping, and last node is a Mapping, otherwise returns null. Returns null if a key doesn't exist at any point in the chain.

Parameters
ParameterType
keysstring[]
Returns

Mapping


getScalar()

Call Signature

getScalar(key): Scalar;

Defined in: mapping.d.ts:50

Returns the Scalar corresponding to the given key. Returns null if the key doesn't exist or it doesn't correspond to a Scalar.

Parameters
ParameterType
keystring
Returns

Scalar

Call Signature

getScalar(keys): Scalar;

Defined in: mapping.d.ts:56

Returns a Scalar by following each one of the keys. Expects that each intermediate node is a Mapping, and last node is a Scalar, otherwise returns null. Returns null if a key doesn't exist at any point in the chain.

Parameters
ParameterType
keysstring[]
Returns

Scalar


getSequence()

Call Signature

getSequence(key): Sequence;

Defined in: mapping.d.ts:38

Returns the Sequence corresponding to the given key. Returns null if the key doesn't exist or it doesn't correspond to a Sequence.

Parameters
ParameterType
keystring
Returns

Sequence

Call Signature

getSequence(keys): Sequence;

Defined in: mapping.d.ts:44

Returns a Sequence by following each one of the keys. Expects that each intermediate node is a Mapping, and last node is a Sequence, otherwise returns null. Returns null if a key doesn't exist at any point in the chain.

Parameters
ParameterType
keysstring[]
Returns

Sequence


getValue()

Call Signature

getValue(key): string;

Defined in: mapping.d.ts:62

Returns the value of the given key as a string. Returns null if the key doesn't exist or it doesn't correspond to a Scalar.

Parameters
ParameterType
keystring
Returns

string

Call Signature

getValue(keys): string;

Defined in: mapping.d.ts:68

Returns the value as a string by following each one of the keys. Expects that each intermediate node is a Mapping, and last node is a Scalar, otherwise returns null. Returns null if a key doesn't exist at any point in the chain.

Parameters
ParameterType
keysstring[]
Returns

string


indexOfKey()

indexOfKey(key): number;

Defined in: mapping.d.ts:126

Returns the index of the key, or -1 if it doesn't exist.

Parameters

ParameterType
keystring

Returns

number


insert()

Call Signature

insert(
index,
key,
value): void;

Defined in: mapping.d.ts:83

Inserts the given key value pair at the given index.

Parameters
ParameterType
indexnumber
keystring
valueMapping
Returns

void

Call Signature

insert(
index,
key,
value): void;

Defined in: mapping.d.ts:86

Inserts the given key value pair at the given index.

Parameters
ParameterType
indexnumber
keystring
valueScalar
Returns

void

Call Signature

insert(
index,
key,
value): void;

Defined in: mapping.d.ts:89

Inserts the given key value pair at the given index.

Parameters
ParameterType
indexnumber
keystring
valueSequence
Returns

void

Call Signature

insert(
index,
key,
value): Scalar;

Defined in: mapping.d.ts:92

Inserts the given key value pair at the given index and returns the created Scalar.

Parameters
ParameterType
indexnumber
keystring
valuestring
Returns

Scalar


keyAt()

keyAt(index): Scalar;

Defined in: mapping.d.ts:129

Returns the key at given index as a Scalar.

Parameters

ParameterType
indexnumber

Returns

Scalar


keys()

keys(): Scalar[];

Defined in: mapping.d.ts:132

Returns the keys as an array of Scalar.

Returns

Scalar[]


length()

length(): number;

Defined in: mapping.d.ts:135

Returns the number of children.

Returns

number


move()

move(key, index): void;

Defined in: mapping.d.ts:138

Moves the key and corresponding value to the given index.

Parameters

ParameterType
keystring
indexnumber

Returns

void


remove()

remove(key): void;

Defined in: mapping.d.ts:141

Removes the key and corresponding value.

Parameters

ParameterType
keystring

Returns

void


set()

Call Signature

set(key, value): void;

Defined in: mapping.d.ts:71

Sets the given key to the given Mapping or Object.

Parameters
ParameterType
keystring
valueObject | Mapping
Returns

void

Call Signature

set(key, value): void;

Defined in: mapping.d.ts:74

Sets the given key to the given Scalar.

Parameters
ParameterType
keystring
valueScalar
Returns

void

Call Signature

set(key, value): void;

Defined in: mapping.d.ts:77

Sets the given key to the given Sequence or array.

Parameters
ParameterType
keystring
valueany[] | Sequence
Returns

void

Call Signature

set(key, value): Scalar;

Defined in: mapping.d.ts:80

Sets the given key to the given string as a Scalar and returns the created Scalar.

Parameters
ParameterType
keystring
valuestring
Returns

Scalar


sortByKey()

sortByKey(): void;

Defined in: mapping.d.ts:147

Sorts the child nodes by their keys.

Returns

void