Operations
Currently all operations exist in both pull
and push
versions:
append(...items)
-- adds its arguments to the end of the sequence.average()
-- reduces the sequence into a number by calculating the average of it.beffer(size)
-- buffers items into an array ofsize
before passing them further. Thepull
version isn't very useful.befferAll()
-- beffers all items into an array before passing them further. Thepull
version isn't very useful.chunk(size)
-- groups items in the sequence into arrays ofsize
items.collect(collector, collectionFactory)
-- collects items into a mutable collection. Is very similar toreduce
,b ut no need to return a value.collectArray()
-- a predefined version ofcollect
resulting into anArray
.collectMap()
-- a predefined version ofcollect
resulting into aMap
. Items must be entries[key, value]
.collectObject()
-- a predefined version ofcollect
resulting into anObject
. Items must be entries[key, value]
.collectSet()
-- a predefined version ofcollect
resulting into aSet
.compact()
-- removes all falsy items from the sequence.concatEnd(source)
-- adds items from thesource
to the end of the sequence.concatStart(source)
-- adds items from thesource
to the beginning of the sequence.count()
-- reduces the sequence into a number by countint items in it.difference(...sources)
-- removes sources' items from the sequence matching by their identity.differenceBy(selector, ...sources)
-- removes sources' items from the sequence matching by theselected
value.every(predicate)
-- reduces the sequence into a boolean by calculating if thepredicate
returnstrue
for every item.filter(predicate)
-- removes all items from the sequence for which thepredicate
returnsfalse
.find(predicate)
-- reduces the sequence to the first item for whichpredicate
have returnedtrue
.findIndex(predicate)
-- reduces the sequence to the index of the first item for which thepredicate
have returnedtrue
.first()
-- removes all items from the sequence, but the first one.flatten(predicate, depth = 1)
-- flattens iterable itemsdepth
levels deep.predicates
decides wheter the item can/should be flattened.depth
can beInfinity
.flattenArrays(depth = 1)
-- flattens all nested arraysdepth
levels deep.depth
can beInfinity
.flattenIterables(depth = 1)
-- flattens all nested iterablesdepth
levels deep.depth
can beInfinity
.forEach(action)
-- executes theaction
for every item in the sequence, used for side effects.groupBy(keySelector)
-- groups items of the sequence into the new[key, items]
items matching by theselected key
.includes(value)
-- reduces the sequence into a boolean depending on whether thevalue
was found in it.interleave(...sources)
-- interleaves sources' items into the sequence in round-robin fashion.intersection(...sources)
-- reduces the sequence to items to which have identicals in every source.intersectionBy(selector, ...sources)
-- reduces the sequence to items to which have identicals in every source matching by theselected
value.join(separator = ",")
-- reduces the sequence into a string, works the same asArray.prototype.join()
.last()
-- removes all items from the sequence, but the last one.map(mapper)
-- transforms the sequence into a new one bymapping
all its items.max()
-- reduces the sequence into a number by finding maximum value.min()
-- reduces the sequence into a number by finding minimum value.nth(n)
-- removes all items from the sequence, but then
th one.orderBy(...comparators)
-- reorders items in the sequence special comparators built with theasc
anddesc
utilities.prepend(...items)
-- adds its arguments to the beginning of the sequence.reduce(reducer, initial = undefined)
-- reduces the sequence into a value starting with theinitial
one and executing thereducer
for every item.remove(predicate)
-- removes all items from the sequence for which thepredicate
returnstrue
.reverse()
-- reverses the order of the items in the sequence.skip(count)
-- removes the firstcount
items from the sequence.skipWhile(predicate)
-- removes the first items from the sequence for which thepredicate
consequently have returnedtrue
.some()
-- reduces the sequence into a boolean by calculating if thepredicate
returnstrue
at least for one item.sort(comparator, order = asc)
-- sorts the items in the sequence using thecomparator
.sortNumbers(order = asc)
-- sorts the items as numbers in the sequence.sortStrings(order = asc)
-- sorts the items as strings in the sequence.sum()
-- reduces the sequence into a number by summing all items.symmetricDifference(...sources)
-- reduces the sequence by applying Symmetric difference with sources' items matching by their identity.symmetricDifferenceBy(selector, ...sources)
-- reduces the sequence by applying Symmetric difference with sources' items matching by theselected
value.take(count)
-- reduces the sequence the the firstcount
items.takeWhile(predicate)
-- reduces the sequence the the firstcount
items for which thepredicate
consequently have returnedtrue
.union(...sources)
-- reduces the sequence by combining it with sources an leaving only unique items matching by their identity.unionBy(selector, ...sources)
-- reduces the sequence by combining it with sources an leaving only unique items matching by theselected
value.unique()
-- educes the sequence by leaving only unique items matching by their identity.uniqueBy(selector)
-- reduces the sequence by combining it with sources an leaving only unique items matching by theselected
value.unzip()
-- reverse to thezip
producing a sequence of sources.unzipWith(itemsExtractor)
-- reverse to thezip
producing a sequence of sources by getting their items from theextractor
.zip(...sources)
-- transforms the sequence into a new one by combining by one item from it and the sources into an array.zipWith(itemFactory, ...sources)
-- transforms the sequence into a new one by combining by one item from it and the source into a value returned by theitemFactory
.