Returns true if the predicate returns true for all the elements in the collection.
Returns true if there the predicate returns true for any element in the collection.
Matches each element with a unique key that you extract from it. If the same key is present twice, the function will return None.
also see Collection.groupBy
Returns true if the item is in the collection, false otherwise.
Two objects are equal if they represent the same value, regardless of whether they are the same object physically in memory.
Call a predicate for each element in the collection, build a new collection holding only the elements for which the predicate returned true.
Reduces the collection to a single value using the associative binary function you give. Since the function is associative, order of application doesn't matter.
Example:
HashSet.of(1,2,3).fold(0, (a,b) => a + b);
=> 6
Reduces the collection to a single value. Left-associative.
Example:
Vector.of("a", "b", "c").foldLeft("!", (xs,x) => x+xs);
=> "cba!"
The initial value
A function taking the previous value and the current collection item, and returning an updated value.
Reduces the collection to a single value. Right-associative.
Example:
Vector.of("a", "b", "c").foldRight("!", (x,xs) => xs+x)
=> "!cba"
The initial value
A function taking the current collection item and the previous value , and returning an updated value.
Group elements in the collection using a classifier function. Elements are then organized in a map. The key is the value of the classifier, and in value we get the list of elements matching that value.
also see Collection.arrangeBy
Get a number for that object. Two different values may get the same number, but one value must always get the same number. The formula can impact performance.
true if the collection is empty, false otherwise.
Get the length of the collection.
Compare values in the collection and return the largest element. Returns Option.none if the collection is empty.
also see Collection.maxOn
Call the function you give for each value in the collection and return the element for which the result was the largest. Returns Option.none if the collection is empty.
Vector.of({name:"Joe", age:12}, {name:"Paula", age:6}).maxOn(x=>x.age)
=> Option.of({name:"Joe", age:12})
also see Collection.maxBy
Compare values in the collection and return the smallest element. Returns Option.none if the collection is empty.
also see Collection.minOn
Call the function you give for each value in the collection and return the element for which the result was the smallest. Returns Option.none if the collection is empty.
Vector.of({name:"Joe", age:12}, {name:"Paula", age:6}).minOn(x=>x.age)
=> Option.of({name:"Paula", age:6})
also see Collection.minBy
Returns a pair of two collections; the first one will only contain the items from this collection for which the predicate you give returns true, the second will only contain the items from this collection where the predicate returns false.
Vector.of(1,2,3,4).partition(x => x%2===0)
=> [Vector.of(2,4), Vector.of(1,3)]
Reduces the collection to a single value by repeatedly calling the combine function. No starting value. The order in which the elements are passed to the combining function is undetermined.
If the collection contains a single element, return Some of its value, otherwise return None.
Call the function you give for each element in the collection and sum all the numbers, return that sum. Will return 0 if the collection is empty.
Vector.of(1,2,3).sumOn(x=>x)
=> 6
Convert to array.
Get a human-friendly string representation of that value.
Generated using TypeDoc
Used by the node REPL to display values. Most of the time should be the same as toString()