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 ofsizebefore passing them further. Thepullversion isn't very useful.befferAll()-- beffers all items into an array before passing them further. Thepullversion isn't very useful.chunk(size)-- groups items in the sequence into arrays ofsizeitems.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 ofcollectresulting into anArray.collectMap()-- a predefined version ofcollectresulting into aMap. Items must be entries[key, value].collectObject()-- a predefined version ofcollectresulting into anObject. Items must be entries[key, value].collectSet()-- a predefined version ofcollectresulting into aSet.compact()-- removes all falsy items from the sequence.concatEnd(source)-- adds items from thesourceto the end of the sequence.concatStart(source)-- adds items from thesourceto 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 theselectedvalue.every(predicate)-- reduces the sequence into a boolean by calculating if thepredicatereturnstruefor every item.filter(predicate)-- removes all items from the sequence for which thepredicatereturnsfalse.find(predicate)-- reduces the sequence to the first item for whichpredicatehave returnedtrue.findIndex(predicate)-- reduces the sequence to the index of the first item for which thepredicatehave returnedtrue.first()-- removes all items from the sequence, but the first one.flatten(predicate, depth = 1)-- flattens iterable itemsdepthlevels deep.predicatesdecides wheter the item can/should be flattened.depthcan beInfinity.flattenArrays(depth = 1)-- flattens all nested arraysdepthlevels deep.depthcan beInfinity.flattenIterables(depth = 1)-- flattens all nested iterablesdepthlevels deep.depthcan beInfinity.forEach(action)-- executes theactionfor 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 thevaluewas 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 theselectedvalue.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 bymappingall 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 thenth one.orderBy(...comparators)-- reorders items in the sequence special comparators built with theascanddescutilities.prepend(...items)-- adds its arguments to the beginning of the sequence.reduce(reducer, initial = undefined)-- reduces the sequence into a value starting with theinitialone and executing thereducerfor every item.remove(predicate)-- removes all items from the sequence for which thepredicatereturnstrue.reverse()-- reverses the order of the items in the sequence.skip(count)-- removes the firstcountitems from the sequence.skipWhile(predicate)-- removes the first items from the sequence for which thepredicateconsequently have returnedtrue.some()-- reduces the sequence into a boolean by calculating if thepredicatereturnstrueat 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 theselectedvalue.take(count)-- reduces the sequence the the firstcountitems.takeWhile(predicate)-- reduces the sequence the the firstcountitems for which thepredicateconsequently 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 theselectedvalue.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 theselectedvalue.unzip()-- reverse to thezipproducing a sequence of sources.unzipWith(itemsExtractor)-- reverse to thezipproducing 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.