Type Parameters
Properties
Methods
Returns all entries but the last.
Returns
A new map.
Removes every entry.
Returns
An empty map, or this one when it is already empty.
An alias of
includes.Parameters
valueVThe value to look for.
Returns
booleantruewhen an equal value is present.
Reports whether
otheris an unordered keyed collection, such as a map, holding equal keys and values, comparing asis()does.Parameters
otherunknownThe value to compare against.
Returns
booleantruewhenotheris an unordered keyed collection with equal entries.
- every<F>(
predicate: (
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => value is F,
context?: unknown,
): this is NutrientViewer.Immutable.Map<K, F>Reports whether the predicate accepts every entry, narrowing the collection to the type
predicateguards.Type Parameters
FParameters
Returns
this is NutrientViewer.Immutable.Map<K, F>truewhen it returns truthy for every entry, and for an empty map. - every(
predicate: (
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => boolean,
context?: unknown,
): booleanReports whether the predicate accepts every entry.
- find<F>(
predicate: (
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => value is F,
context?: unknown,
): F | undefinedReturns the first value the predicate accepts, narrowed to the type
predicateguards. - find<N>(
predicate: (
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => boolean,
context: unknown,
notSetValue: N,
): V | NReturns the first value the predicate accepts.
- find(
predicate: (
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => boolean,
context?: unknown,
notSetValue?: V,
): V | undefinedReturns the first value the predicate accepts.
Parameters
Returns
V | undefinedThe first accepted value, or
notSetValue.
- findLast<F>(
predicate: (
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => value is F,
context?: unknown,
): F | undefinedReturns the last value the predicate accepts, narrowed to the type
predicateguards. - findLast<N>(
predicate: (
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => boolean,
context: unknown,
notSetValue: N,
): V | NReturns the last value the predicate accepts.
- findLast(
predicate: (
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => boolean,
context?: unknown,
notSetValue?: V,
): V | undefinedReturns the last value the predicate accepts.
Parameters
Returns
V | undefinedThe last accepted value, or
notSetValue.
Returns the first value in iteration order.
Returns
V | undefinedThe first value, or
undefinedfor an empty map.
- flatMap<KM, VM>(
mapper: (
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => Iterable<[KM, VM]>,
context?: unknown,
): NutrientViewer.Immutable.Map<KM, VM>Returns a map of the entries of the collections
mapperreturns.Type Parameters
KMVMParameters
Returns
A new map. Entries that share a key keep the last value.
Flattens nested collections, merging their entries by key.
Parameters
depthnumberOptionalHow many levels to flatten; omitted for all.
Returns
NutrientViewer.Immutable.Map<unknown, unknown>A new map.
Flattens nested collections, merging their entries by key.
Parameters
shallowbooleanOptionaltrueto flatten one level; omitted orfalsefor all.Returns
NutrientViewer.Immutable.Map<unknown, unknown>A new map.
Returns a map with keys and values swapped.
Returns
A new map. Values that are equal keep the last key.
Reads a value deep inside nested collections.
Parameters
searchKeyPathIterable<unknown>The keys to follow, from this map inwards.
notSetValueunknownOptionalReturned when the path does not exist.
Returns
unknownThe value at the path, or
notSetValue.
Reports whether the map has
key, even when its value isundefined.Parameters
keyKThe key to look for.
Returns
booleantruewhen the map has an entry forkey.
Computes a hash of this map from its contents, the same way Immutable.js does. Equal maps have equal hashes; maps with equal hashes are not necessarily equal. Plain objects, functions and symbols hash by identity, so a hash is only meaningful within the page that computed it.
Returns
numberAn integer hash.
Reports whether a path exists inside nested collections.
Parameters
searchKeyPathIterable<unknown>The keys to follow, from this map inwards.
Returns
booleantruewhen every key on the path exists.
Reports whether the map holds a value equal to
value, comparing asis()does.Parameters
valueVThe value to look for.
Returns
booleantruewhen an equal value is present.
Reports whether the map has no entries.
Returns
booleantruefor an empty map.
Joins the values into a string.
Parameters
separatorstringOptionalPlaced between values; defaults to
,.Returns
stringThe joined string, with
nullandundefinedas empty strings.
Returns an iterator over the keys.
Returns
IterableIterator<K>A new iterator.
Returns the last value in iteration order.
Returns
V | undefinedThe last value, or
undefinedfor an empty map.
- mapEntries<KM, VM>(
mapper: (
entry: [K, V],
index: number,
map: NutrientViewer.Immutable.Map<K, V>,
) => [KM, VM] | undefined,
context?: unknown,
): NutrientViewer.Immutable.Map<KM, VM>Returns a map with each entry replaced by the pair
mapperreturns.Type Parameters
KMVMParameters
Returns
A new map. Pairs that share a key keep the last value;
undefinedresults are skipped.
- mergeDeepWith(
merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
...collections: (Iterable<[K, V], any, any> | { [key: string]: V })[],
): NutrientViewer.Immutable.Map<K, V>Adds the entries of the collections, merging collections found under the same key and combining other values with
merger.Parameters
Returns
A new map, or this one when nothing changes.
- partition<F, C>(
predicate: (
this: C,
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => value is F,
context?: C,
): [NutrientViewer.Immutable.Map<K, V>, NutrientViewer.Immutable.Map<K, F>]Splits the entries into those the predicate rejects and those it accepts.
Type Parameters
FCParameters
Returns
[NutrientViewer.Immutable.Map<K, V>, NutrientViewer.Immutable.Map<K, F>]A pair of maps: the rejected entries, then the accepted entries.
- reduceRight(
reducer: (
reduction: V,
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => V,
): VReduces the values to one, from the last value to the first, starting from the last value.
- reduceRight<R>(
reducer: (
reduction: R,
value: V,
key: K,
map: NutrientViewer.Immutable.Map<K, V>,
) => R,
initialReduction: R,
context?: unknown,
): RReduces the values to one, from the last value to the first.
Returns all entries but the first.
Returns
A new map.
Returns the entries in reverse iteration order.
Returns
A new map.
Returns the entries after the first
amount.Parameters
amountnumberHow many entries to skip.
Returns
A new map.
Returns the entries before the last
amount.Parameters
amountnumberHow many entries to skip from the end.
Returns
A new map.
Returns the entries from
beginup to, not including,end, in iteration order. A negative index counts from the end.Parameters
beginnumberOptionalThe first position to keep; defaults to the start.
endnumberOptionalThe position to stop before; defaults to the end.
Returns
A new map, or this one when
beginis given and the range covers every entry.
Returns the first
amountentries.Parameters
amountnumberHow many entries to keep.
Returns
A new map.
Returns the last
amountentries.Parameters
amountnumberHow many entries to keep.
Returns
A new map.
Converts the map to plain values all the way down: nested collections, records, arrays and plain objects become plain arrays and objects.
Returns
PlainObjectOf<V>A new plain object.
Converts the map to a list of its values.
Returns
A new list.
Copies the map.
Returns
A new map with the same entries.
Converts the map to an object, leaving nested collections as they are. Keys become strings.
Returns
{ [key: string]: V }A new object.
Converts the map to an ordered set of its values, dropping duplicates.
Returns
OrderedSet<V>A new ordered set.
Converts the map to a set of its values, dropping duplicates.
Returns
A new set.
Prints the map, for example
Map { "a": 1 }.Returns
stringThe printed map.
- updateIn(
keyPath: Iterable<unknown>,
notSetValue: unknown,
updater: (value: unknown) => unknown,
): NutrientViewer.Immutable.Map<K, V>Replaces a value deep inside nested collections with the result of
updater.Parameters
keyPathIterable<unknown>The keys to follow, from this map inwards.
notSetValueunknownPassed to
updaterwhen the path does not exist.updater(value: unknown) => unknownReturns the new value from the current one.
Returns
A new map, or this one when
updaterreturns its argument.
Returns an iterator over the values.
Returns
IterableIterator<V>A new iterator.
- withMutations(
mutator: (mutable: NutrientViewer.Immutable.Map<K, V>) => unknown,
): NutrientViewer.Immutable.Map<K, V>Applies several changes in one batch. The mutator receives a draft map whose changing methods modify it in place and return it.
Parameters
mutator(mutable: NutrientViewer.Immutable.Map<K, V>) => unknownCalled once with the draft.
Returns
A new map holding the changes, or this one when the mutator changed nothing.
An immutable, unordered map of keys to values. Every change returns a new map and leaves the original untouched; a change that would not alter the map returns the same map. Keys are compared as
is()does, so collections and records with equal values are the same key.