Save class

The Save class extends the NodeJS built-in Map class.

const save = new Save(data?: Map | ValueSaver | [{key: string, value: string}] | object);

constructor

In the constructor there is one optional argument, which is a Save data type. A Save data type can be one of:

Properties

The Save class has no properties besides from the default Map properties

Functions

first

save.first() : any;

Returns the first value in the Save.

last

save.last() : any;

Returns the last value in the Save.

firstKey

save.firstKey() : any;

Returns the first key in the Save.

lastKey

save.lastKey() : any;

Returns the last key in the Save.

filter

save.filter(item => item.key === "Some value" || item.value === "Some value") : Save;

Returns a new Save matching the criteria given in the filter function:

ArgumentDescription

filter

A function which gives criteria where the key or value must meet. The argument of the filter function returns an object with two items. One item has the key named key and has as its value the specified key of the item. The other item has the key named value and has as its value the specified value of the item.

toObject

save.toObject() : object;

Returns an object based on the Save:

{"[KEY]": "[VALUE]"}

toArray

save.toArray() : [object];

Returns an array based on the Save:

[{"[KEY]": "[VALUE]"}]

toReadableArray

save.toReadableArray() : [{key: any, value: any}];

Returns an array with the readable array structure of the ValueSaver based on the Save:

[{"key": "[KEY]", "value": "[VALUE]"}]

Last updated