Skip to main content

@sapphire/iterator-utilities

References

concat

Renames and re-exports append


except

Renames and re-exports difference


omit

Renames and re-exports difference


position

Renames and re-exports indexOf


skip

Renames and re-exports drop


skipLast

Renames and re-exports dropLast


skipWhile

Renames and re-exports dropWhile


takeWhile

Renames and re-exports filter

Interfaces

InterfaceDescription
Peekable-

Type Aliases

Type aliasDescription
IterableResolvable-
IterableResolved-
NumberResolvable-
StarMapParameters-
UnzipIterable-
ZipIterators-

Functions

FunctionDescription
appendAppends iterables to the end of the first iterable, returning a new iterable combining all of them. It's similar to concatenating arrays or doing [...a, ...b, ...c].
atAdvances the iterable to the nth element and returns it. If the iterable is exhausted before reaching the nth element, it returns undefined.
averageConsumes the iterable and returns the average value of all the elements. If the iterable is empty, it returns null.
chainSimilar to append, but takes an iterable of iterables and chains them together.
chunkChunks the iterable into arrays of at most size elements.
compactCreates a new iterable that yields all the non-nullish values (null and undefined) from the iterable.
compressCreates a new iterable of the first iterable based on the truthiness of the corresponding element in the second iterable.
containsAdvances the iterable until it finds the element, returning true if it's found and false otherwise.
countConsumes the iterable and returns the number of elements.
cycleCreates an infinite iterable by cycling through the elements of the input iterable.
differenceCreates an iterable with the elements of the first iterable that are not in the second iterable.
dropAdvances the iterable by count elements from the iterable.
dropLastConsumes the iterable, creating a new iterator without the last count elements from the iterable.
dropWhileCreates a new iterator without the elements that satisfy the specified test.
emptyCreates an empty iterator.
enumerateCreates a new iterable that yields the index and value of each element.
everyTests whether all elements in the iterable pass the test implemented by the provided function.
filterCreates an iterable with the elements that pass the test implemented by the provided function.
findAdvances the iterable until it finds the element, returning it if it's found and undefined otherwise.
findIndexAdvances the iterable until it finds the element, returning its index if it's found and -1 otherwise.
firstConsumes the first element of the iterable, returning it if it's found and undefined otherwise.
flatCreates an iterable that yields the elements of each iterable in the input iterable.
flatMapCreates an iterable that yields the elements of each iterable returned by the provided function on each element of the input iterable.
forEachExecutes a provided function once for each iterable element.
fromResolves an iterable from an iterable or iterator-like object.
indexOfAdvances the iterable until it finds the element, returning its index if it's found and -1 otherwise.
intersectCreates an iterable with the elements that are in both input iterables.
isEmptyAdvances the iterable once, returning true if it's exhausted and false otherwise.
lastConsumes the iterable until it's exhausted, returning the last element.
mapCreates an iterable with the results of calling a provided function on each element.
maxConsumes the iterable and returns the highest number element. If the iterable is empty, or contains only non-number values, it returns null.
minConsumes the iterable and returns the lowest number element. If the iterable is empty, or contains only non-number values, it returns null.
partitionConsumes the iterable and creates two arrays, one with the elements that pass the test and another with the elements that don't.
peekableCreates an iterator that allows you to peek at the next element without advancing the iterator.
prependCreates an iterator with the provided iterables prepended to the first iterable.
productConsumes the iterable and returns the product of all the elements. If the iterable is empty, it returns 1.
rangeCreates an iterable with the numbers from start to stop (exclusive) with an optional step.
reduceConsumes the iterable and reduces it to the reducer function's result.
repeatCreates an iterable that repeats the input iterable count times.
reverseConsumes the iterable and returns a new iterable with the elements in reverse order.
sliceProduces an iterable with the elements from the start index to the end index (exclusive).
someAdvances the iterable until it finds a matching element, returning true if it's found and false otherwise.
sortedConsumes the iterable and returns a new iterable with the elements sorted.
starMapCreates an iterable with the results of calling a provided function on each element of the input iterables as the function's parameters.
sumConsumes the iterable and returns the sum of all the elements.
takeCreates an iterable with the first count elements.
takeLastConsumes the iterable and returns a new iterable with the last count elements.
teeCreates count independent iterators from the input iterable.
toArrayConsumes the iterable and returns an array with all the elements.
toIterableIteratorCreates an iterable iterator from an iterable or iterator-like object.
unionCreates an iterable with the elements that are in either input iterable.
uniqueCreates an iterable with the unique elements of the input iterable. Under the hood, it calls union with the iterable itself.
unzipCreates an array for each element of the input iterable, transposing the input iterable. The opposite of zip.
zipCreates an iterable with the elements of the input iterables zipped together. The opposite of unzip.