A callback function that accepts an argument. The method calls the predicate
one time for each element in object.
An object to which the this
keyword can refer in the predicate
. If thisArg
is omitted, null
is used as the this
value.
Returns the first element yielding the largest value of the given function or throws KoconutNoSuchElementException if there are no elements.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
Returns the first element yielding the largest value of the given function or null if there are no elements.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
Returns the largest value among all values produced by selector
function applied to each element in the collection or
throws KoconutNoSuchElementException if there are no elements.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
Returns the largest value among all values produced by selector
function applied to each element in the collection or
null if there are no elements.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
Returns the largest value according to the provided comparator
among all values
produced by selector
function applied to each element in the collection all throws KoconutNoSuchElementException
if elements are empty.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
A callback function that accepts two arguements. The method calls the comparator
to compare two selected values.
In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
An object to which the this
keyword can refer in the comparator
. If thisArg
is omitted, null
is used as the this
value.
Returns the largest value according to the provided comparator
among all values
produced by selector
function applied to each element in the collection or null
if elements are empty.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
A callback function that accepts two arguements. The method calls the comparator
to compare two selected values.
In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
An object to which the this
keyword can refer in the comparator
. If thisArg
is omitted, null
is used as the this
value.
Returns the first element having the largest value according to the provided comparator
or throws KoconutNoSuchElementException
if elements are empty.
A callback function that accepts two arguements. The method calls the comparator
to compare two selected values.
In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.
An object to which the this
keyword can refer in the comparator
. If thisArg
is omitted, null
is used as the this
value.
Returns the first element having the largest value according to the provided comparator
or null
if elements are empty.
A callback function that accepts two arguements. The method calls the comparator
to compare two selected values.
In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.
An object to which the this
keyword can refer in the comparator
. If thisArg
is omitted, null
is used as the this
value.
Returns the first element yielding the samllest value of the given function or throws KoconutNoSuchElementException if there are no elements.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
Returns the first element yielding the samllest value of the given function or null
if there are no elements.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
Returns the smallest value among all values produced by selector
function applied to each element in the collection or
throws KoconutNoSuchElementException if there are no elements.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
Returns the smallest value among all values produced by selector
function applied to each element in the collection or
null
if there are no elements.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
Returns the smallest value according to the provided comparator
among all values
produced by selector
function applied to each element in the collection all throws KoconutNoSuchElementException
if elements are empty.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
A callback function that accepts two arguements. The method calls the comparator
to compare two selected values.
In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
An object to which the this
keyword can refer in the comparator
. If thisArg
is omitted, null
is used as the this
value.
Returns the smallest value according to the provided comparator
among all values
produced by selector
function applied to each element in the collection all null
if elements are empty.
A callback function that accepts an argument. The method calls the selector
one time for each element in object.
A callback function that accepts two arguements. The method calls the comparator
to compare two selected values.
In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.
An object to which the this
keyword can refer in the selector
. If thisArg
is omitted, null
is used as the this
value.
An object to which the this
keyword can refer in the comparator
. If thisArg
is omitted, null
is used as the this
value.
Returns the first element having the smallest value according to the provided comparator
or throws KoconutNoSuchElementException
if elements are empty.
A callback function that accepts two arguements. The method calls the comparator
to compare two selected values.
In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.
An object to which the this
keyword can refer in the comparator
. If thisArg
is omitted, null
is used as the this
value.
Returns the first element having the smallest value according to the provided comparator
or null
if elements are empty.
A callback function that accepts two arguements. The method calls the comparator
to compare two selected values.
In case the result is larger than 0, front is bigger than rear, and if it's less than 0 judge vice versa.
An object to which the this
keyword can refer in the comparator
. If thisArg
is omitted, null
is used as the this
value.
Creates an KoconutArray instance that wraps original data.
Creates an KoconutSet instance that wraps original data.
Return true
if all elements match te given predicate
.
A callback function that accepts an argument. The method calls the predicate
one time for each element in object.
An object to which the this
keyword can refer in the predicate
. If thisArg
is omitted, null
is used as the this
value.
Returns true
if the collection has at least one element matches the given predicate
.
A callback function that accepts an argument. The method calls the predicate
one time for each element in object.
An object to which the this
keyword can refer in the predicate
. If thisArg
is omitted, null
is used as the this
value.
Returns true
if the collection is empty (contains no elements), false
otherwise.
Returns true
if the collection is not empty.
Returns true
if this nullable collection is either null or empty.
predicate
callback function is optional. If it's omitted the method returns true
if the collection has no elements.
Otherwise, returns true
if no elements match the given predicate
.
A callback function that accepts an argument. The method calls the predicate
one time for each element in object.
An object to which the this
keyword can refer in the predicate
. If thisArg
is omitted, null
is used as the this
value.
Performs the given action
on each element.
When you want to stop iteration in the meantime return
false
or KoconutLoopSignal.BREAK.
A callback function that accepts an argument. The method calls the action
one time for each element in object.
An object to which the this
keyword can refer in the action
. If thisArg
is omitted, null
is used as the this
value.
Processes all the chained objects and calls the specified function
block
with the result value as its argument and returns the original result.
A callback function that accepts an argument.
Processes all the chained objects and calls the specified function
block
with the result value as its argument and returns the final result
of the block
.
A callback function that accepts an argument. The method calls the block
and returns its result.
Processes all the chained objects ane returns Promise<void>
.
Returns a single list of all elements yielded from results of transform
function being invoked on each element of original collection.
A callback function that accepts an argument. The method calls the transform
one time for each element in object.
An object to which the this
keyword can refer in the transform
. If thisArg
is omitted, null
is used as the this
value.
Returns a list containing the results of applying the given transform
function
to each element in the original collection.
A callback function that accepts an argument. The method calls the transform
one time for each element in object.
An object to which the this
keyword can refer in the transform
. If thisArg
is omitted, null
is used as the this
value.
Returns a list containing results that are not null
nor undefined
of applying
the given transfrom
function to each element in the original collection. You can use this method as filter
then map
.
A callback function that accepts an argument. The method calls the transform
one time for each element in object.
An object to which the this
keyword can refer in the transform
. If thisArg
is omitted, null
is used as the this
value.
Generated using TypeDoc
Returns the number of the elements matching the given
predicate
. If thepredicate
is ommitted it'll returns the whole number of elements.1.0.10
// Case 1 -- KoconutArray const koconutArray = KoconutArray.of(1,2,3,4,5) const numberOfAllArrayElements = await koconutArray .count() .yield() console.log(numberOfAllArrayElements) // ↑ 5 const numberOfArrayElementsHigherThan2 = await koconutArray .count(eachNumber => eachNumber > 2) .yield() console.log(numberOfArrayElementsHigherThan2) // ↑ 3 -- i.e. [3, 4, 5] // Case 2 -- KoconutSet const koconutSet = KoconutSet.of(1,2,3,4,5) const numberOfAllSetElements = await koconutSet .count() .yield() console.log(numberOfAllSetElements) // ↑ 5 const numberOfOddSetElements = await koconutSet .count(eachNumber => eachNumber % 2 == 1) .yield() console.log(numberOfOddSetElements) // ↑ 3 -- i.e. [1, 3, 5] // Case 3 -- KoconutMap const koconutMap = KoconutArray.of(1,2,3) .associateWith(eachNumber => eachNumber * 2) // ↑ Map { 1 => 2, // 2 => 4, // 3 => 6 } const numberOfAllMapEntries = await koconutMap .count() .yield() console.log(numberOfAllMapEntries) // ↑ 3 const numberOfMapEntriesValueHigherThan5 = await koconutMap .count(eachEntry => eachEntry.value > 5) .yield() console.log(numberOfMapEntriesValueHigherThan5) // ↑ 1 -- i.e. Entry { 3, 6 } // Case 4 -- You can also do it asynchronously const koconutArray2 = KoconutArray.of(1,2,3,4,5) const numberOfArrayElementsLessThan3 = await koconutArray2 .count(async eachNumber => eachNumber < 3) .yield() console.log(numberOfArrayElementsLessThan3) // ↑ 2 -- i.e. [1, 2] const numberOfEvenArrayElements = await koconutArray2 .count(eachNumber => new Promise(resolve => { resolve(eachNumber % 2 == 0) })) .yield() console.log(numberOfEvenArrayElements) // ↑ 2 -- i.e. [2, 4]