The item type of the iterator.
Instantiates an IterPlus
from any iterator.
The iterator to wrap around.
The internal iterator that this wraps around.
Makes the iterator work as an iterable.
The same iterator.
Checks if every element in this iterator is equal.
This function is short-circuiting, so it stops on the first inequality.
If every element is equal, or true if the iterator has one or less elements.
Checks if every element in this iterator is equal, using a comparison function.
This function is short-circuiting, so it stops on the first inequality.
A function that checks if elements are equal.
If every element is equal, or true if the iterator has one or less elements.
Checks if every element in this iterator is equal, using a key function.
This function is short-circuiting, so it stops on the first inequality.
The type of the key.
The key function.
If every element is equal, or true if the iterator has one or less elements.
Returns the average of all elements in the iterator.
The average.
Returns an iterator yielding non-overlapping chunks of the iterator.
If there aren't enough elements to fill a chunk, the last chunk will be smaller than the chunk size.
If you want gaps between the chunks,
consider using windows
with the appropriate interval instead.
The chunk size.
An iterator that yields the chunks.
Returns an iterator yielding non-overlapping chunks of the iterator.
If there aren't enough elements to fill a chunk, the extra elements will be omitted.
If you want gaps between the chunks,
consider using windows
with the appropriate interval instead.
The chunk size.
An iterator that yields the chunks.
Collects the items in this iterator into an array.
An array with the items in the iterator.
Lexicographically compares this iterator with another.
This function is short-circuiting, so it stops on the first inequality.
Iterable to compare to.
-1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.
Lexicographically compares this iterator with another using a comparison function.
This function is short-circuiting, so it stops on the first inequality.
The type of the other iterator.
Iterable to compare to.
A function that should return a negative for less than, zero for equal to, and positive for greater than.
-1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.
Lexicographically compares this iterator with another using a key.
This function is short-circuiting, so it stops on the first inequality.
The type of the key.
Iterable to compare to.
Function to generate a key to compare with from an element.
-1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.
Concatenates one or more iterables to this iterator, creating an iterator that yields their elements in sequentual order.
The iterables to chain to this one.
The generated iterator.
Counts the number of items in this iterator.
The number of items in the iterator.
Counts the number of items in this iterator that match a predicate.
The predicate function.
The number of matched items in the iterator.
Removes elements of an iterator that are equal to the previous one.
An iterator with no consecutive duplicates.
Removes elements of an iterator that are equal to the previous one with a comparison function.
A function that checks if elements are equal.
An iterator with no consecutive duplicates.
Removes elements of an iterator that are equal to the previous one with a key.
The type of the key.
The key function.
An iterator with no consecutive duplicates.
Drops elements from the iterator from the end.
This uses memory proportional to the number of elements dropped, as the iterator must look ahead and store elements to know that it has not reached the end.
The number of elements to drop.
An iterator with the specified number of elements removed from the end.
Generates an iterator that yields a 2 element array with the index and the element.
The generated iterator.
Checks if this iterator is equal to another.
This function is short-circuiting, so it stops on the first inequality.
Iterable to compare to.
If the two iterators are equal.
Checks if this iterator is equal to another using a comparison function.
This function is short-circuiting, so it stops on the first inequality.
The type of the other iterable.
Iterable to compare to.
A function that checks if elements are equal.
If the two iterators are equal.
Checks if this iterator is equal to another using a key.
This function is short-circuiting, so it stops on the first inequality.
The type of the key.
Iterable to compare to.
Function to generate a key to compare with from an element.
If the two iterators are equal.
Checks if every element in the iterator matches a predicate.
This function is short-circuiting,
so if any element returns false
,
the function immediately returns false
.
The predicate function.
If every element satisfies the predicate.
Generates an iterator that only yields elements that match a predicate.
The predicate function.
The generated iterator.
Generates a mapped iterator that yields non-null elements.
The resulting type.
The mapping function.
The generated iterator.
Finds an element that satisfies a predicate.
This function is short-circuiting, so it stops on the first match.
The predicate function.
The element, or null if none was found.
Finds the index of an element that satisfies a predicate.
If you want to find the value and the index, consider using enumerate
then using find
.
This function is short-circuiting, so it stops on the first match.
The predicate function.
The index, or -1 if none was found.
Runs a function on every element and returns the first non-null element.
This function is short-circuiting, so it stops on the first match.
The resulting type.
The mapping function.
The element, or null if none was found.
Maps then flattens an iterator.
The resulting type.
The mapping function.
The generated iterator.
Flattens an iterator of iterables, yielding an iterator that sequentially produces their elements.
The internal type.
The generated iterator.
Runs a function on each element of an iterator.
This is equivalent to running a for loop on the iterator.
If you want to obtain the values, consider using .map(func).collect()
instead.
The function to run.
Generates an iterator that is guaranteed to never yield a value after finishing.
The generated iterator.
Globs elements of an iterator together.
An iterator where every element is an array of consecutively equal elements.
Globs elements of an iterator together, with a comparison function.
A function that checks if elements are equal.
An iterator where every element is an array of consecutively equal elements.
Globs elements of an iterator together, with a key function.
The type of the key.
The key function.
An iterator where every element is an array of consecutively equal elements.
Groups elements of an iterator together with a key function.
The type of the key.
An object mapping keys to arrays of matching items.
Checks if this iterator is equal to another, while the second iterator still yields elements.
This function is short-circuiting, so it stops on the first inequality.
Iterable to compare to.
If the first iterator starts with the second iterator.
Checks if this iterator is equal to another, while the second iterator still yields elements, using a comparison function.
This function is short-circuiting, so it stops on the first inequality.
The type of the other iterable.
Iterable to compare to.
A function that checks if elements are equal.
If the first iterator starts with the second iterator.
Checks if this iterator is equal to another, while the second iterator still yields elements, with a key function.
This function is short-circuiting, so it stops on the first inequality.
The type of the key.
Iterable to compare to.
The key function.
If the first iterator starts with the second iterator.
Checks if this iterator is equal to another, while they both yield elements.
This function is short-circuiting, so it stops on the first inequality.
However, if the first iterator terminates,
a value will still be yielded from the second so that headEquals
is commutative.
Iterable to compare to.
If the two iterators are equal.
Checks if this iterator is equal to another, while they both yield elements, using a comparison function.
This function is short-circuiting, so it stops on the first inequality.
However, if the first iterator terminates,
a value will still be yielded from the second so that headEquals
is commutative.
The type of the other iterable.
Iterable to compare to.
A function that checks if elements are equal.
If the two iterators are equal.
Checks if this iterator is equal to another, while they both yield elements, using a key.
This function is short-circuiting, so it stops on the first inequality.
However, if the first iterator terminates,
a value will still be yielded from the second so that headEquals
is commutative.
The type of the key.
Iterable to compare to.
The key function.
If the two iterators are equal.
Lazily runs functions on an iterator, returning a new iterator with unmodified elements.
This function is primarily used as a debugging tool to inspect elements in the middle of an iterator function chain.
The function to call.
The generated iterator.
Interleaves one or more iterables with this iterator.
The iterables to interleave with this one.
The interleaved iterator, yielding elements in the iterators in order.
Intersperses an element between every element of the iterator.
The element to intersperse.
The new iterator.
Intersperses multiple elements between every element of the iterator.
The elements to intersperse.
The new iterator.
Determines if an iterator is partitioned by a predicate (Items that return true come before items that return false).
This function is short-circuiting, so it stops on the first non-partitioned element.
The predicate function.
If the iterator is partitioned.
Determines if an iterator is sorted increasingly.
This function is short-circuiting, so it stops on the first non-sorted element.
If the iterator is sorted.
Determines if an iterator is sorted increasingly by a comparison function.
This function is short-circuiting, so it stops on the first non-sorted element.
A function that should return a negative for less than, zero for equal to, and positive for greater than.
If the iterator is sorted.
Determines if an iterator is sorted increasingly by a key.
This function is short-circuiting, so it stops on the first non-sorted element.
The type of the key.
The key function.
If the iterator is sorted.
Joins an iterator of iterables with an element.
The internal type.
The element to join with.
The joined iterator.
Joins an iterator of iterables with multiple elements.
The internal type.
The elements to intersperse.
The joined iterator.
Finds the last element in an iterator.
The last element of the iterator, or null if the iterator is empty.
Lazily maps an iterator, creating a new iterator where each element has been modified by a function.
If you want to immediately run a function on all elements of the iterator, use forEach
instead.
The resulting type.
The mapping function.
The generated iterator.
Runs a function for every element of the iterator, keeping track of an accumulator.
The type of the accumulator.
The resulting type.
The mapping function.
The initial accumulator.
The mapped iterator.
Lazily maps an iterator until it encounters null.
The resulting type.
The mapping function.
The generated iterator.
Finds the maximum value of an iterator.
If true
, elements will be counted as the new maximum if they are equal to the maximum.
Defaults to false
.
The maximum element, or null if the iterator is empty.
Finds the maximum value of an iterator with a comparison function.
A function that should return a negative for less than, zero for equal to, and positive for greater than.
If true
, elements will be counted as the new maximum if they are equal to the maximum.
Defaults to false
.
The maximum element, or null if the iterator is empty.
Finds the maximum value of an iterator with a key.
The type of the key.
The key function.
If true
, elements will be counted as the new maximum if they are equal to the maximum.
Defaults to false
.
The maximum element, or null if the iterator is empty.
Finds the minimum value of an iterator.
If true
, elements will be counted as the new minimum if they are equal to the minimum.
Defaults to false
.
The minimum element, or null if the iterator is empty.
Finds the minimum value of an iterator with a comparison function.
A function that should return a negative for less than, zero for equal to, and positive for greater than.
If true
, elements will be counted as the new minimum if they are equal to the minimum.
Defaults to false
.
The minimum element, or null if the iterator is empty.
Finds the minimum value of an iterator with a key.
The type of the key.
The key function.
If true
, elements will be counted as the new minimum if they are equal to the minimum.
Defaults to false
.
The minimum element, or null if the iterator is empty.
Yields the next element in the iterator.
The next element.
Returns the next value, or null if the iterator ended.
The next value, or null if the iterator ended.
Finds the nth element in an iterator.
The number element to get.
The nth element of the iterator, or null if the iterator is too short.
Removes duplicates from an iterator, including non-consecutive ones.
The nubbed iterator.
Removes duplicates from an iterator, including non-consecutive ones, with a comparison function.
Unlike nubWith
and nub
, this does not use a set, so it is significantly slower.
A function that checks if elements are equal.
The nubbed iterator.
Removes duplicates from an iterator, including non-consecutive ones, with a key function.
The type of the key.
The key function.
The nubbed iterator.
Partitions an iterator into two groups.
The predicate function.
An array with two elements:
Generates a Peekable
iterator.
The peekable iterator.
Returns the product of all elements in the iterator.
The default value for an empty iterator. Defaults to 1.
The product.
Returns the product of all elements in the iterator.
The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 1n or another bigint.
The product.
Runs a function for every element of the iterator, keeping track of an accumulator.
The type of the accumulator.
The reducing function.
The initial accumulator.
The final accumulator.
Runs a function for every element of the iterator, keeping track of an accumulator.
Uses the first element as the initial accumulator, and it will be skipped over in the reduction.
The reducing function.
The final accumulator.
Creates an iterator that repeats the contents of the current iterator a certain number of times.
The number of times to repeat.
An iterator that repeats itself n times.
Consumes the iterator and reverses it.
This has to immediately resolve every element in the iterator, so it is equivalent to collecting to an array and revsersing the array, so it is very inefficient on memory and should be avoided.
The reversed iterator.
Creates an iterator that's rotated left a certain amount, so elements at the start end up at the end.
This does not handle negative numbers due to right rotation being significantly slower. If you want negatives, please do the checks yourself and use rotateRight when appropriate.
Amount to rotate by.
The rotated iterator.
Creates an iterator that's rotated right a certain amount, so elements at the end end up at the start.
Due to the one-directional nature of iterators, this is not lazy and therefore much slower than rotateLeft
.
This does not handle negative numbers to be consistent with rotateLeft
.
If you want negatives, please do the checks yourself and use rotateRight when appropriate.
Amount to rotate by.
The rotated iterator.
Runs a function for every element of the iterator, keeping track of an accumulator.
The type of the accumulator.
The reducing function.
The initial accumulator.
The iterator containing all intermediate accumulators.
Runs a function for every element of the iterator, keeping track of an accumulator.
Uses the first element as the initial accumulator, and it will be skipped over in the scan.
The reducing function.
The iterator containing all intermediate accumulators.
Skips the first n elements of an iterator.
The number of elements to skip.
The generated iterator.
Skips elements of an iterator while a predicate is met.
The predicate function.
The generated iterator.
Checks if some element in the iterator matches a predicate.
This function is short-circuiting,
so if any element returns true
,
the function immediately returns true
.
The predicate function.
If some element satisfies the predicate.
Splits an iterator on an element.
The maximum number of chunks to make.
The iterator with the split chunks.
Splits an iterator on an element, including the matched element as the last element of the chunk.
Unlike the exclusive split, this does not create an empty chunk on the end when ending with the matched element.
The maximum number of chunks to make.
The iterator with the split chunks.
Splits an iterator on a predicate.
The predicate to split with.
The maximum number of chunks to make.
The iterator with the split chunks.
Splits an iterator on a predicate, including the matched element as the last element of the chunk.
Unlike the exclusive split, this does not create an empty chunk on the end when ending with the matched element.
The predicate to split with.
The maximum number of chunks to make.
The iterator with the split chunks.
Maps an iterator of iterables, and calls a function with the contents of the iterable as the argument.
The iterable type.
The resulting type.
The mapping function.
The generated iterator.
Steps through an iterator by a certain amount, starting from the first.
A step of 2 would yield the first element, then the third, then the fifth, and so on.
The step size.
An iterator that advances by the given step size.
Returns the sum of all elements in the iterator.
The default value for an empty iterator. Defaults to 0.
The sum.
Returns the sum of all elements in the iterator.
The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 0n or another bigint.
The sum.
Returns the sum of all elements in the iterator.
The default value for an empty iterator. For string iterators it's advised to explicitly set this to "" or another string.
The sum.
Takes the first n elements of an iterator.
The number of elements to take.
The generated iterator.
Takes elements of an iterator while a predicate is met.
The predicate function.
The generated iterator.
Tallies elements of an iterator together.
An object mapping keys to the number of times they appeared.
Tallies elements of an iterator together with a key function.
The type of the key.
The key function.
An object mapping keys to the number of times they appeared.
Splits an iterator into multiple, where advancing one iterator does not advance the others.
Functions by storing old values and removing when no longer needed, so only tee as many iterators as you need in order for memory to be cleaned properly.
The original iterator will still be advanced,
so only used the iterators returned by tee
.
The number of iterators to split into.
An array of length count
with separate iterators.
Converts an iterator into an array.
The generated array.
Converts an iterator of key-value pairs into a map.
The key type.
The value type.
How to handle duplicate keys.
"overwrite"
replaces values with the new value.
"maintain"
maintains the old value.
"error"
throws an error.
Defaults to "overwrite"
.
The generated map.
Converts an iterator of key-value pairs into an object.
The key type.
The value type.
How to handle duplicate keys.
"overwrite"
replaces values with the new value.
"maintain"
maintains the old value.
"error"
throws an error.
Defaults to "overwrite"
.
The generated object.
Converts an iterator into a set.
The generated set.
"Unzips" an iterator of tuples into a tuple of arrays.
The tuple type.
A tuple with the individual elements.
Returns an iterator yielding overlapping windows of the iterator.
If there aren't enough elements to fill a window, no windows will be yielded.
The window size.
The increment between the starts of windows. Defaults to 1.
An iterator that yields the windows.
Zips one or more iterables with this iterator.
The types of the other iterables.
The iterables to zip with this one.
The generated iterator.
Zips one or more iterables with this iterator using a function.
Stops once any one of the iterators stop.
The types of the other iterables.
The resulting value.
The function to use when zipping.
The iterables to zip with this one.
The generated iterator.
Generates an iterator that iterates through lexicographically sorted combinations without repetition of a dataset.
The item type of the iterator.
The data to generate combinations from.
The number of elements in each combination.
The generated iterator.
Generates an iterator that iterates through lexicographically sorted combinations with repetition of a dataset.
The item type of the iterator.
The data to generate combinations from.
The number of elements in each combination.
The generated iterator.
Generates an iterator that cycles through an iterable.
While this does work on infinite iterators, it should be avoided as it stores all elements, leading to an ever-growing memory usage.
The item type of the iterator.
The iterable to cycle through.
The generated iterator.
Generates an empty iterator.
The item yielded by the iterator.
The generated iterator.
Generates an iterator that yields values from a function and ends once the function returns null.
The item type of the iterator.
The function to yield values, or null to end the iterator.
The generated iterator.
Generates an iterator that yields a single value.
The item type of the iterator.
The value to yield.
The generated iterator.
Generates an iterator that lazily yields a single value.
The item type of the iterator.
The function to generate a single value.
The generated iterator.
Generates an iterator that iterates through lexicographically sorted permutations without repetition of a dataset.
The item type of the iterator.
The data to generate permutations from.
The number of elements in each permutations.
The generated iterator.
Generates an iterator that iterates through lexicographically sorted permutations with repetition of a dataset.
The item type of the iterator.
The data to generate permutations from.
The number of elements in each permutations.
The generated iterator.
Generates an iterator that iterates through the lexicographically sorted powerset of a dataset.
The item type of the iterator.
The data to get the powerset of.
The generated iterator.
Generates an iterator that generates a lexicographically sorted cartesian product.
The item type of the iterator.
The iterators to take the product of.
The generated iterator.
Generates an iterator that endlessly repeats a value.
The item type of the iterator.
The value to yield.
The generated iterator.
Generates an iterator that endlessly calls a function.
The item type of the iterator.
The function to generate values.
The generated iterator.
Generates an iterator that generates values based on the previous value.
The item type of the iterator.
The initial value.
The function to generate new values.
The generated iterator.
Generated using TypeDoc
A wrapper around an iterator to add additional functionality. The types intentionally ignore return value.
Many of the methods consume elements of the iterator, so use
tee
the iterator into two first if you want to preserve elements.