Type Parameters
Properties
Methods
Iterates the values.
Returns
IterableIterator<T>An iterator of the values.
Adds
value.Parameters
valueTThe value to add.
Returns
A new set, or this one when it already has
value.
Returns every value but the last.
Returns
A new set.
Removes every value.
Returns
An empty set.
An alias of
includes.Parameters
valueTThe value to look for.
Returns
booleantruewhen the set hasvalue.
Removes
value.Parameters
valueTThe value to remove.
Returns
A new set, or this one when it has no such value.
Compares this set with another collection by value.
Parameters
otherunknownThe value to compare with.
Returns
booleantruewhenotheris a set of equal values. A set is never equal to an ordered set.
- every<F>(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => value is F,
context?: unknown,
): this is NutrientViewer.Immutable.Set<F>Reports whether the predicate accepts every value, narrowing the collection to the type
predicateguards.Type Parameters
FParameters
Returns
this is NutrientViewer.Immutable.Set<F>truewhen every value is accepted, including for an empty set. - every(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context?: unknown,
): booleanReports whether the predicate accepts every value.
- filter<F>(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => value is F,
context?: unknown,
): NutrientViewer.Immutable.Set<F>Returns the values the predicate accepts.
- filter(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => unknown,
context?: unknown,
): NutrientViewer.Immutable.Set<T>Parameters
Returns
- filterNot(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context?: unknown,
): NutrientViewer.Immutable.Set<T>Returns the values the predicate rejects.
Parameters
Returns
A new set.
- find<F>(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => value is F,
context?: unknown,
): F | undefinedReturns the first value the predicate accepts, narrowed to the type
predicateguards. - find<N>(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context: unknown,
notSetValue: N,
): T | NReturns the first value the predicate accepts.
Type Parameters
NParameters
- find(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context?: unknown,
notSetValue?: T,
): T | undefinedReturns the first value the predicate accepts.
Parameters
Returns
T | undefinedThe first accepted value, or
notSetValue.
- findLast<F>(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => value is F,
context?: unknown,
): F | undefinedReturns the last value the predicate accepts, narrowed to the type
predicateguards. - findLast<N>(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context: unknown,
notSetValue: N,
): T | NReturns the last value the predicate accepts.
Type Parameters
NParameters
- findLast(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context?: unknown,
notSetValue?: T,
): T | undefinedReturns the last value the predicate accepts.
Parameters
Returns
T | undefinedThe last accepted value, or
notSetValue.
Returns the first value in iteration order.
Returns
T | undefinedThe first value, or
undefinedfor an empty set.
Returns a set of the values of the collections nested in this set, at every depth or down to
depth.Parameters
depthnumberOptionalHow many levels to flatten; every level when omitted.
Returns
NutrientViewer.Immutable.Set<unknown>A new set.
Returns a set of the values of the collections nested in this set, one level deep when
shallowistrueand at every depth otherwise.Parameters
shallowbooleanOptionalWhether to flatten one level only.
Returns
NutrientViewer.Immutable.Set<unknown>A new set.
Reads a value deep inside nested collections.
Parameters
searchKeyPathIterable<unknown>The keys to follow, from this set inwards.
notSetValueunknownOptionalReturned when the path does not exist.
Returns
unknownThe value at the path, or
notSetValue.
Reports whether the set has
value.Parameters
valueTThe value to look for.
Returns
booleantruewhen the set hasvalue.
Computes a hash of this set from its contents, the same way Immutable.js does. Equal sets have equal hashes; sets 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 set inwards.
Returns
booleantruewhen every key on the path exists.
Reports whether the set has
value.Parameters
valueTThe value to look for.
Returns
booleantruewhen the set hasvalue.
Reports whether the set is empty.
Returns
booleantruewhen the set has no values.
Joins the values into a string, printing
nullandundefinedas nothing.Parameters
separatorstringOptionalPlaced between values; defaults to a comma.
Returns
stringThe joined string.
Iterates the values.
Returns
IterableIterator<T>An iterator of the values.
Returns the last value in iteration order.
Returns
T | undefinedThe last value, or
undefinedfor an empty set.
- map<M>(
mapper: (value: T, key: T, set: NutrientViewer.Immutable.Set<T>) => M,
context?: unknown,
): NutrientViewer.Immutable.Set<M>Returns a set of the results of
mapper. Results that are equal collapse into one value.Type Parameters
MParameters
Returns
A new set, or this one when every result is the value it came from.
- partition<F, C>(
predicate: (
this: C,
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => value is F,
context?: C,
): [NutrientViewer.Immutable.Set<T>, NutrientViewer.Immutable.Set<F>]Splits the values into those the predicate rejects and those it accepts.
Type Parameters
FCParameters
Returns
A pair of sets: the rejected values, then the accepted values.
- reduceRight(
reducer: (
reduction: T,
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => T,
): TReduces the values to one, from the last value to the first, starting from the last value.
- reduceRight<R>(
reducer: (
reduction: R,
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => R,
initialReduction: R,
context?: unknown,
): RReduces the values to one, from the last value to the first.
An alias of
delete.Parameters
valueTThe value to remove.
Returns
A new set, or this one when it has no such value.
Returns every value but the first.
Returns
A new set.
Returns the values in the opposite order.
Returns
A new set.
Skips values from the start.
Parameters
amountnumberHow many values to skip.
Returns
A new set, or this one when
amountis0.
Skips values from the end.
Parameters
amountnumberHow many values to skip.
Returns
A new set, or this one when
amountis0.
- skipUntil(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context?: unknown,
): NutrientViewer.Immutable.Set<T>Skips values from the start until the predicate accepts one.
Parameters
Returns
A new set.
- skipWhile(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context?: unknown,
): NutrientViewer.Immutable.Set<T>Skips values from the start while the predicate accepts them.
Parameters
Returns
A new set.
Returns the values from
beginup to, but not including,end.Parameters
beginnumberOptionalThe first position to keep; negative counts from the end.
endnumberOptionalThe position to stop before; negative counts from the end.
Returns
A new set, or this one when
beginis given and the range covers every value.
Keeps values from the start.
Parameters
amountnumberHow many values to keep.
Returns
A new set, or this one when it has no more than
amountvalues.
Keeps values from the end.
Parameters
amountnumberHow many values to keep.
Returns
A new set, or this one when it has no more than
amountvalues.
- takeUntil(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context?: unknown,
): NutrientViewer.Immutable.Set<T>Keeps values from the start until the predicate accepts one.
Parameters
Returns
A new set.
- takeWhile(
predicate: (
value: T,
key: T,
set: NutrientViewer.Immutable.Set<T>,
) => boolean,
context?: unknown,
): NutrientViewer.Immutable.Set<T>Keeps values from the start while the predicate accepts them.
Parameters
Returns
A new set.
Converts the set to plain values all the way down: nested collections, records, arrays and plain objects become plain arrays and objects.
Returns
CollectionPlainValue<T>[]A new array.
Converts the set to an array of its values, leaving nested collections as they are.
Returns
T[]A new array.
Converts the set to a list of its values.
Returns
A new list.
Converts the set to a map from each value to itself.
Returns
A new map.
Converts the set to an object keyed by each value, with the value stored under it.
Returns
{ [key: string]: T }A new object.
Converts the set to an ordered set in iteration order.
Returns
OrderedSet<T>A new ordered set.
Converts the set to a set.
Returns
This set, or a new set when this is an ordered set.
Returns a readable description of the set.
Returns
stringA string such as
Set { 1, 2 }.
Iterates the values.
Returns
IterableIterator<T>An iterator of the values.
- withMutations(
mutator: (mutable: NutrientViewer.Immutable.Set<T>) => unknown,
): NutrientViewer.Immutable.Set<T>Applies several changes in one batch. The mutator receives a draft set whose changing methods modify it in place and return it.
Parameters
mutator(mutable: NutrientViewer.Immutable.Set<T>) => unknownCalled once with the draft.
Returns
A new set holding the changes, or this one when the mutator changed nothing.
An immutable, unordered collection of unique values. Every change returns a new set and leaves the original untouched; a change that would not alter the set returns the same set. Values are compared as
is()does, so collections and records with equal values are the same member.