@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
Interface | Description |
---|---|
Peekable | - |
Type Aliases
Type alias | Description |
---|---|
IterableResolvable | - |
IterableResolved | - |
NumberResolvable | - |
StarMapParameters | - |
UnzipIterable | - |
ZipIterators | - |
Functions
Function | Description |
---|---|
append | Appends 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] . |
at | Advances the iterable to the n th element and returns it. If the iterable is exhausted before reaching the n th element, it returns undefined . |
average | Consumes the iterable and returns the average value of all the elements. If the iterable is empty, it returns null . |
chain | Similar to append , but takes an iterable of iterables and chains them together. |
chunk | Chunks the iterable into arrays of at most size elements. |
compact | Creates a new iterable that yields all the non-nullish values (null and undefined ) from the iterable. |
compress | Creates a new iterable of the first iterable based on the truthiness of the corresponding element in the second iterable. |
contains | Advances the iterable until it finds the element, returning true if it's found and false otherwise. |
count | Consumes the iterable and returns the number of elements. |
cycle | Creates an infinite iterable by cycling through the elements of the input iterable. |
difference | Creates an iterable with the elements of the first iterable that are not in the second iterable. |
drop | Advances the iterable by count elements from the iterable. |
dropLast | Consumes the iterable, creating a new iterator without the last count elements from the iterable. |
dropWhile | Creates a new iterator without the elements that satisfy the specified test. |
empty | Creates an empty iterator. |
enumerate | Creates a new iterable that yields the index and value of each element. |
every | Tests whether all elements in the iterable pass the test implemented by the provided function. |
filter | Creates an iterable with the elements that pass the test implemented by the provided function. |
find | Advances the iterable until it finds the element, returning it if it's found and undefined otherwise. |
findIndex | Advances the iterable until it finds the element, returning its index if it's found and -1 otherwise. |
first | Consumes the first element of the iterable, returning it if it's found and undefined otherwise. |
flat | Creates an iterable that yields the elements of each iterable in the input iterable. |
flatMap | Creates an iterable that yields the elements of each iterable returned by the provided function on each element of the input iterable. |
forEach | Executes a provided function once for each iterable element. |
from | Resolves an iterable from an iterable or iterator-like object. |
indexOf | Advances the iterable until it finds the element, returning its index if it's found and -1 otherwise. |
intersect | Creates an iterable with the elements that are in both input iterables. |
isEmpty | Advances the iterable once, returning true if it's exhausted and false otherwise. |
last | Consumes the iterable until it's exhausted, returning the last element. |
map | Creates an iterable with the results of calling a provided function on each element. |
max | Consumes the iterable and returns the highest number element. If the iterable is empty, or contains only non-number values, it returns null . |
min | Consumes the iterable and returns the lowest number element. If the iterable is empty, or contains only non-number values, it returns null . |
partition | Consumes the iterable and creates two arrays, one with the elements that pass the test and another with the elements that don't. |
peekable | Creates an iterator that allows you to peek at the next element without advancing the iterator. |
prepend | Creates an iterator with the provided iterables prepended to the first iterable. |
product | Consumes the iterable and returns the product of all the elements. If the iterable is empty, it returns 1 . |
range | Creates an iterable with the numbers from start to stop (exclusive) with an optional step. |
reduce | Consumes the iterable and reduces it to the reducer function's result. |
repeat | Creates an iterable that repeats the input iterable count times. |
reverse | Consumes the iterable and returns a new iterable with the elements in reverse order. |
slice | Produces an iterable with the elements from the start index to the end index (exclusive). |
some | Advances the iterable until it finds a matching element, returning true if it's found and false otherwise. |
sorted | Consumes the iterable and returns a new iterable with the elements sorted. |
starMap | Creates an iterable with the results of calling a provided function on each element of the input iterables as the function's parameters. |
sum | Consumes the iterable and returns the sum of all the elements. |
take | Creates an iterable with the first count elements. |
takeLast | Consumes the iterable and returns a new iterable with the last count elements. |
tee | Creates count independent iterators from the input iterable. |
toArray | Consumes the iterable and returns an array with all the elements. |
toIterableIterator | Creates an iterable iterator from an iterable or iterator-like object. |
union | Creates an iterable with the elements that are in either input iterable. |
unique | Creates an iterable with the unique elements of the input iterable. Under the hood, it calls union with the iterable itself. |
unzip | Creates an array for each element of the input iterable, transposing the input iterable. The opposite of zip . |
zip | Creates an iterable with the elements of the input iterables zipped together. The opposite of unzip . |