From fe588b854d662f96c2d3ea3f438abfd0eb31cd5a Mon Sep 17 00:00:00 2001 From: Aplet123 Date: Sat, 5 Feb 2022 11:26:20 -0500 Subject: [PATCH] rebundle --- docs/classes/AsyncIterPlus.html | 248 +++++++++++++++--------------- docs/classes/AsyncPeekable.html | 254 +++++++++++++++---------------- docs/classes/CircularBuffer.html | 42 ++--- docs/classes/IterPlus.html | 248 +++++++++++++++--------------- docs/classes/Peekable.html | 254 +++++++++++++++---------------- docs/modules.html | 30 ++-- 6 files changed, 538 insertions(+), 538 deletions(-) diff --git a/docs/classes/AsyncIterPlus.html b/docs/classes/AsyncIterPlus.html index 194a0de..db70897 100644 --- a/docs/classes/AsyncIterPlus.html +++ b/docs/classes/AsyncIterPlus.html @@ -4,28 +4,28 @@ so use tee the iterator into two first if you want to preserve elements.

Type parameters

Hierarchy

Implements

Index

Constructors

  • new AsyncIterPlus<T>(iter: AsyncIterator<T, any, undefined>): AsyncIterPlus<T>

Hierarchy

Implements

  • CurIter<T>
  • AsyncIterable<T>

Index

Constructors

  • new AsyncIterPlus<T>(iter: AsyncIterator<T, any, undefined>): AsyncIterPlus<T>
  • Instantiates an IterPlus from any iterator.

    Type parameters

    • T

    Parameters

    • iter: AsyncIterator<T, any, undefined>

      The iterator to wrap around.

      -

    Returns AsyncIterPlus<T>

Properties

internal: AsyncIterator<T, any, undefined>
+

Returns AsyncIterPlus<T>

Properties

internal: AsyncIterator<T, any, undefined>

The internal iterator that this wraps around.

-

Methods

  • [asyncIterator](): AsyncIterator<T, any, undefined>

Methods

  • [asyncIterator](): AsyncIterator<T, any, undefined>
  • Makes the iterator work as an iterable.

    Returns AsyncIterator<T, any, undefined>

    The same iterator.

    -
  • allEqual(): Promise<boolean>
  • allEqual(): Promise<boolean>
  • Checks if every element in this iterator is equal.

    This function is short-circuiting, so it stops on the first inequality.

    Returns Promise<boolean>

    If every element is equal, or true if the iterator has one or less elements.

    -
  • allEqualBy(cmp: (first: T, second: T) => PromiseOrValue<boolean>): Promise<boolean>
  • allEqualBy(cmp: (first: T, second: T) => PromiseOrValue<boolean>): Promise<boolean>
  • 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.

    Parameters

    Returns Promise<boolean>

    If every element is equal, or true if the iterator has one or less elements.

    -
  • allEqualWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • allEqualWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • 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.

    @@ -34,11 +34,11 @@

Parameters

Returns Promise<boolean>

If every element is equal, or true if the iterator has one or less elements.

-
  • average(): Promise<T>
  • average(): Promise<T>
  • Returns the average of all elements in the iterator.

    throws

    A RangeError on an empty iterator.

    Returns Promise<T>

    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.

    @@ -47,7 +47,7 @@

    Parameters

    • chunkSize: number

      The chunk size.

    Returns AsyncIterPlus<T[]>

    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.

    @@ -56,22 +56,22 @@

    Parameters

    • chunkSize: number

      The chunk size.

    Returns AsyncIterPlus<T[]>

    An iterator that yields the chunks.

    -
  • collect(): Promise<T[]>
  • collect(): Promise<T[]>
  • Collects the items in this iterator into an array.

    Returns Promise<T[]>

    An array with the items in the iterator.

    -
  • Calls a specified collector function with this iterator as its only argument.

    Type parameters

    • R

    Parameters

    Returns R

    The return value of the collector.

    -
  • compare(other: AsyncIterable<T>): Promise<number>
  • compare(other: AsyncIterable<T>): Promise<number>
  • Lexicographically compares this iterator with another.

    This function is short-circuiting, so it stops on the first inequality.

    Parameters

    • other: AsyncIterable<T>

      Iterable to compare to.

    Returns Promise<number>

    -1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

    -
  • compareBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<number>): Promise<number>
  • compareBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<number>): Promise<number>
  • Lexicographically compares this iterator with another using a comparison function.

    This function is short-circuiting, so it stops on the first inequality.

    @@ -83,7 +83,7 @@

    A function that should return a negative for less than, zero for equal to, and positive for greater than.

Returns Promise<number>

-1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

-
  • compareWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<number>
  • compareWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<number>
  • Lexicographically compares this iterator with another using a key.

    This function is short-circuiting, so it stops on the first inequality.

    @@ -94,58 +94,58 @@
  • key: (elem: T) => PromiseOrValue<K>

    Function to generate a key to compare with from an element.

Returns Promise<number>

-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.

    Parameters

    • Rest ...iters: AsyncIterable<T>[]

      The iterables to chain to this one.

    Returns AsyncIterPlus<T>

    The generated iterator.

    -
  • Calls a specified constructor with this iterator as its only argument.

    Type parameters

    • R

    Parameters

    Returns R

    The constructed value.

    -
  • count(): Promise<number>
  • count(): Promise<number>
  • Counts the number of items in this iterator.

    Returns Promise<number>

    The number of items in the iterator.

    -
  • Counts the number of items in this iterator that match a predicate.

    Parameters

    Returns Promise<number>

    The number of matched items in the iterator.

    -
  • Removes elements of an iterator that are equal to the previous one.

    Returns AsyncIterPlus<T>

    An iterator with no consecutive duplicates.

    -
  • Removes elements of an iterator that are equal to the previous one with a comparison function.

    Parameters

    Returns AsyncIterPlus<T>

    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.

    Parameters

    • n: number

      The number of elements to drop.

    Returns AsyncIterPlus<T>

    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.

    Returns AsyncIterPlus<[number, T]>

    The generated iterator.

    -
  • equals(other: AsyncIterable<T>): Promise<boolean>
  • equals(other: AsyncIterable<T>): Promise<boolean>
  • Checks if this iterator is equal to another.

    This function is short-circuiting, so it stops on the first inequality.

    Parameters

    • other: AsyncIterable<T>

      Iterable to compare to.

    Returns Promise<boolean>

    If the two iterators are equal.

    -
  • equalsBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • equalsBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • Checks if this iterator is equal to another using a comparison function.

    This function is short-circuiting, so it stops on the first inequality.

    @@ -156,7 +156,7 @@
  • cmp: (first: T, second: O) => PromiseOrValue<boolean>

    A function that checks if elements are equal.

Returns Promise<boolean>

If the two iterators are equal.

-
  • equalsWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • equalsWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • Checks if this iterator is equal to another using a key.

    This function is short-circuiting, so it stops on the first inequality.

    @@ -167,7 +167,7 @@
  • key: (elem: T) => PromiseOrValue<K>

    Function to generate a key to compare with from an element.

Returns Promise<boolean>

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, @@ -175,26 +175,26 @@

    Parameters

    Returns Promise<boolean>

    If every element satisfies the predicate.

    -
  • Finds an element that satisfies a predicate.

    This function is short-circuiting, so it stops on the first match.

    Parameters

    Returns Promise<null | T>

    The element, or null if none was found.

    -
  • findIndex(pred: (elem: T) => PromiseOrValue<boolean>): Promise<number>
  • findIndex(pred: (elem: T) => PromiseOrValue<boolean>): Promise<number>
  • 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.

    @@ -203,7 +203,7 @@

    Parameters

    Returns Promise<number>

    The index, or -1 if none was found.

    -
  • findMap<K>(func: (elem: T) => PromiseOrValue<null | K>): Promise<null | K>
  • findMap<K>(func: (elem: T) => PromiseOrValue<null | K>): Promise<null | K>
  • 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.

    @@ -212,49 +212,49 @@

Parameters

Returns Promise<null | K>

The element, or null if none was found.

-
  • flatMap<K>(func: (elem: T) => Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>): AsyncIterPlus<K>
  • flatMap<K>(func: (elem: T) => Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>): AsyncIterPlus<K>
  • Maps then flattens an iterator.

    Type parameters

    • K

      The resulting type.

    Parameters

    • func: (elem: T) => Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>

      The mapping function.

        • (elem: T): Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>
        • Parameters

          • elem: T

          Returns Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>

    Returns AsyncIterPlus<K>

    The generated iterator.

    -
  • Flattens an iterator of iterables, yielding an iterator that sequentially produces their elements.

    Type parameters

    • K

      The internal type.

    Returns AsyncIterPlus<K>

    The generated iterator.

    -
  • forEach(func: (elem: T) => unknown): Promise<void>
  • forEach(func: (elem: T) => unknown): Promise<void>
  • 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.

    Parameters

    • func: (elem: T) => unknown

      The function to run.

      -
        • (elem: T): unknown
        • Parameters

          • elem: T

          Returns unknown

    Returns Promise<void>

Returns Promise<void>

  • Globs elements of an iterator together.

    Returns AsyncIterPlus<T[]>

    An iterator where every element is an array of consecutively equal elements.

    -
  • Globs elements of an iterator together, with a comparison function.

    Parameters

    Returns AsyncIterPlus<T[]>

    An iterator where every element is an array of consecutively equal elements.

    -
  • group<K>(key: (elem: T) => PromiseOrValue<K>): Promise<Record<K, T[]>>
  • group<K>(key: (elem: T) => PromiseOrValue<K>): Promise<Record<K, T[]>>
  • Groups elements of an iterator together with a key function.

    Type parameters

    • K: string | number | symbol

      The type of the key.

    Parameters

    Returns Promise<Record<K, T[]>>

    An object mapping keys to arrays of matching items.

    -
  • hasPrefix(other: AsyncIterable<T>): Promise<boolean>
  • hasPrefix(other: AsyncIterable<T>): Promise<boolean>
  • Checks if this iterator is equal to another, while the second iterator still yields elements.

    This function is short-circuiting, @@ -262,7 +262,7 @@

    Parameters

    • other: AsyncIterable<T>

      Iterable to compare to.

    Returns Promise<boolean>

    If the first iterator starts with the second iterator.

    -
  • hasPrefixBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • hasPrefixBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • Checks if this iterator is equal to another, while the second iterator still yields elements, using a comparison function.

    This function is short-circuiting, @@ -274,7 +274,7 @@

  • cmp: (first: T, second: O) => PromiseOrValue<boolean>

    A function that checks if elements are equal.

Returns Promise<boolean>

If the first iterator starts with the second iterator.

-
  • hasPrefixWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • hasPrefixWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • Checks if this iterator is equal to another, while the second iterator still yields elements, with a key function.

    This function is short-circuiting, @@ -286,7 +286,7 @@

  • key: (elem: T) => PromiseOrValue<K>

    The key function.

Returns Promise<boolean>

If the first iterator starts with the second iterator.

-
  • headEquals(other: AsyncIterable<T>): Promise<boolean>
  • headEquals(other: AsyncIterable<T>): Promise<boolean>
  • Checks if this iterator is equal to another, while they both yield elements.

    This function is short-circuiting, @@ -296,7 +296,7 @@

    Parameters

    • other: AsyncIterable<T>

      Iterable to compare to.

    Returns Promise<boolean>

    If the two iterators are equal.

    -
  • headEqualsBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • headEqualsBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • Checks if this iterator is equal to another, while they both yield elements, using a comparison function.

    This function is short-circuiting, @@ -310,7 +310,7 @@

  • cmp: (first: T, second: O) => PromiseOrValue<boolean>

    A function that checks if elements are equal.

Returns Promise<boolean>

If the two iterators are equal.

-
  • headEqualsWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • headEqualsWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>

Returns Promise<boolean>

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.

    Parameters

    • func: (elem: T) => unknown

      The function to call.

        • (elem: T): unknown
        • Parameters

          • elem: T

          Returns unknown

    Returns AsyncIterPlus<T>

    The generated iterator.

    -
  • Interleaves one or more iterables with this iterator.

    Parameters

    • Rest ...iters: AsyncIterable<T>[]

      The iterables to interleave with this one.

    Returns AsyncIterPlus<T>

    The interleaved iterator, yielding elements in the iterators in order.

    -
  • Intersperses multiple elements between every element of the iterator.

    Parameters

    • elems: AsyncIterable<T>

      The elements to intersperse.

    Returns AsyncIterPlus<T>

    The new iterator.

    -
  • isPartitioned(pred: (elem: T) => PromiseOrValue<boolean>): Promise<boolean>
  • isPartitioned(pred: (elem: T) => PromiseOrValue<boolean>): Promise<boolean>
  • Determines if an iterator is partitioned by a predicate (Items that return true come before items that return false).

    This function is short-circuiting, @@ -353,12 +353,12 @@

    Parameters

    Returns Promise<boolean>

    If the iterator is partitioned.

    -
  • isSorted(): Promise<boolean>
  • isSorted(): Promise<boolean>
  • Determines if an iterator is sorted increasingly.

    This function is short-circuiting, so it stops on the first non-sorted element.

    Returns Promise<boolean>

    If the iterator is sorted.

    -
  • isSortedBy(cmp: (first: T, second: T) => PromiseOrValue<number>): Promise<boolean>
  • isSortedBy(cmp: (first: T, second: T) => PromiseOrValue<number>): Promise<boolean>
  • 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.

    @@ -366,7 +366,7 @@

    A function that should return a negative for less than, zero for equal to, and positive for greater than.

Returns Promise<boolean>

If the iterator is sorted.

-
  • isSortedWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • isSortedWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • Determines if an iterator is sorted increasingly by a key.

    This function is short-circuiting, so it stops on the first non-sorted element.

    @@ -375,24 +375,24 @@

Parameters

Returns Promise<boolean>

If the iterator is sorted.

-
  • Joins an iterator of iterables with multiple elements.

    Type parameters

    • K

      The internal type.

    Parameters

    • elems: AsyncIterable<K>

      The elements to intersperse.

    Returns AsyncIterPlus<K>

    The joined iterator.

    -
  • last(): Promise<null | T>
  • last(): Promise<null | T>
  • Finds the last element in an iterator.

    Returns Promise<null | T>

    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.

    Type parameters

    • K

      @@ -400,7 +400,7 @@

    Parameters

    Returns AsyncIterPlus<K>

    The generated iterator.

    -
  • Runs a function for every element of the iterator, keeping track of an accumulator.

    Type parameters

    • A

      The type of the accumulator.

      @@ -411,20 +411,20 @@
    • initializer: A

      The initial accumulator.

    Returns AsyncIterPlus<V>

    The mapped iterator.

    -
  • max(overwrite?: boolean): Promise<null | T>
  • max(overwrite?: boolean): Promise<null | T>
  • Finds the maximum value of an iterator.

    Parameters

    • overwrite: boolean = false

      If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

    Returns Promise<null | T>

    The maximum element, or null if the iterator is empty.

    -
  • maxBy(cmp: (first: T, second: T) => PromiseOrValue<number>, overwrite?: boolean): Promise<null | T>
  • maxBy(cmp: (first: T, second: T) => PromiseOrValue<number>, overwrite?: boolean): Promise<null | T>
  • Finds the maximum value of an iterator with a comparison function.

    Parameters

    • cmp: (first: T, second: T) => PromiseOrValue<number>

      A function that should return a negative for less than, zero for equal to, @@ -433,7 +433,7 @@

      If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

    Returns Promise<null | T>

    The maximum element, or null if the iterator is empty.

    -
  • maxWith<K>(key: (elem: T) => PromiseOrValue<K>, overwrite?: boolean): Promise<null | T>
  • maxWith<K>(key: (elem: T) => PromiseOrValue<K>, overwrite?: boolean): Promise<null | T>
  • Finds the maximum value of an iterator with a key.

    Type parameters

    • K

      The type of the key.

      @@ -443,13 +443,13 @@

      If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

    Returns Promise<null | T>

    The maximum element, or null if the iterator is empty.

    -
  • min(overwrite?: boolean): Promise<null | T>
  • min(overwrite?: boolean): Promise<null | T>
  • Finds the minimum value of an iterator.

    Parameters

    • overwrite: boolean = false

      If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

    Returns Promise<null | T>

    The minimum element, or null if the iterator is empty.

    -
  • minBy(cmp: (first: T, second: T) => PromiseOrValue<number>, overwrite?: boolean): Promise<null | T>
  • minBy(cmp: (first: T, second: T) => PromiseOrValue<number>, overwrite?: boolean): Promise<null | T>
  • Finds the minimum value of an iterator with a comparison function.

    Parameters

    • cmp: (first: T, second: T) => PromiseOrValue<number>

      A function that should return a negative for less than, zero for equal to, @@ -458,7 +458,7 @@

      If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

    Returns Promise<null | T>

    The minimum element, or null if the iterator is empty.

    -
  • minWith<K>(key: (elem: T) => PromiseOrValue<K>, overwrite?: boolean): Promise<null | T>
  • minWith<K>(key: (elem: T) => PromiseOrValue<K>, overwrite?: boolean): Promise<null | T>
  • Finds the minimum value of an iterator with a key.

    Type parameters

    • K

      The type of the key.

      @@ -468,34 +468,34 @@

      If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

    Returns Promise<null | T>

    The minimum element, or null if the iterator is empty.

    -
  • next(): Promise<IteratorResult<T, any>>
  • next(): Promise<IteratorResult<T, any>>
  • Yields the next element in the iterator.

    Returns Promise<IteratorResult<T, any>>

    The next element.

    -
  • nextVal(): Promise<null | T>
  • nextVal(): Promise<null | T>
  • Returns the next value, or null if the iterator ended.

    Returns Promise<null | T>

    The next value, or null if the iterator ended.

    -
  • nth(n: number): Promise<null | T>
  • nth(n: number): Promise<null | T>
  • Finds the nth element in an iterator.

    Parameters

    • n: number

      The number element to get.

    Returns Promise<null | T>

    The nth element of the iterator, or null if the iterator is too short.

    -
  • 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.

    Parameters

    Returns AsyncIterPlus<T>

    The nubbed iterator.

    -
  • partition(pred: (elem: T) => PromiseOrValue<boolean>): Promise<[T[], T[]]>
  • partition(pred: (elem: T) => PromiseOrValue<boolean>): Promise<[T[], T[]]>
  • Partitions an iterator into two groups.

    Parameters

    • pred: (elem: T) => PromiseOrValue<boolean>

      The predicate function.

      @@ -504,21 +504,21 @@
    • The elements where the predicate returned true.
    • The elements where the predicate returned false.
    -
  • product(empty?: number): Promise<number>
  • product(empty: bigint): Promise<bigint>
  • product(empty?: number): Promise<number>
  • product(empty: bigint): Promise<bigint>
  • Returns the product of all elements in the iterator.

    Parameters

    • Optional empty: number

      The default value for an empty iterator. Defaults to 1.

    Returns Promise<number>

    The product.

    -
  • +
  • Returns the product of all elements in the iterator.

    Parameters

    • empty: bigint

      The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 1n or another bigint.

    Returns Promise<bigint>

    The product.

    -
  • reduce<A>(func: (accum: A, elem: T) => PromiseOrValue<A>, initializer: A): Promise<A>
  • reduce(func: (accum: T, elem: T) => PromiseOrValue<T>): Promise<T>
  • reduce<A>(func: (accum: A, elem: T) => PromiseOrValue<A>, initializer: A): Promise<A>
  • reduce(func: (accum: T, elem: T) => PromiseOrValue<T>): Promise<T>
  • Runs a function for every element of the iterator, keeping track of an accumulator.

    Type parameters

    • A

      The type of the accumulator.

      @@ -527,7 +527,7 @@
    • initializer: A

      The initial accumulator.

    Returns Promise<A>

    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.

    @@ -536,18 +536,18 @@

    Parameters

    Returns Promise<T>

    The final accumulator.

    -
  • Creates an iterator that repeats the contents of the current iterator a certain number of times.

    Parameters

    • n: number

      The number of times to repeat.

    Returns AsyncIterPlus<T>

    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.

    Returns Promise<IterPlus<T>>

    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. @@ -556,7 +556,7 @@

    Parameters

    • amount: number

      Amount to rotate by.

    Returns AsyncIterPlus<T>

    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.

    @@ -566,7 +566,7 @@

    Parameters

    • amount: number

      Amount to rotate by.

    Returns AsyncIterPlus<T>

    The rotated iterator.

    -
  • Runs a function for every element of the iterator, keeping track of an accumulator.

    Type parameters

    • A

      The type of the accumulator.

      @@ -575,7 +575,7 @@
    • initializer: A

      The initial accumulator.

    Returns AsyncIterPlus<A>

    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.

    @@ -584,17 +584,17 @@

    Parameters

    Returns AsyncIterPlus<T>

    The iterator containing all intermediate accumulators.

    -
  • Skips the first n elements of an iterator.

    Parameters

    • n: number

      The number of elements to skip.

    Returns AsyncIterPlus<T>

    The generated iterator.

    -
  • Checks if some element in the iterator matches a predicate.

    This function is short-circuiting, so if any element returns true, @@ -602,12 +602,12 @@

    Parameters

    Returns Promise<boolean>

    If some element satisfies the predicate.

    -
  • Splits an iterator on an element, including the matched element as the last element of the chunk.

    Unlike the exclusive split, @@ -615,14 +615,14 @@

    Parameters

    • elem: PromiseOrValue<T>
    • limit: number = Infinity

      The maximum number of chunks to make.

    Returns AsyncIterPlus<T[]>

    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, @@ -632,7 +632,7 @@

  • limit: number = Infinity

    The maximum number of chunks to make.

Returns AsyncIterPlus<T[]>

The iterator with the split chunks.

-
  • Maps an iterator of iterables, and calls a function with the contents of the iterable as the argument.

    Type parameters

    • K

      @@ -642,50 +642,50 @@

    Parameters

    Returns AsyncIterPlus<R>

    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.

    Parameters

    • step: number

      The step size.

    Returns AsyncIterPlus<T>

    An iterator that advances by the given step size.

    -
  • sum(empty?: number): Promise<number>
  • sum(empty: bigint): Promise<bigint>
  • sum(empty: string): Promise<string>
  • sum(empty?: number): Promise<number>
  • sum(empty: bigint): Promise<bigint>
  • sum(empty: string): Promise<string>
  • Returns the sum of all elements in the iterator.

    Parameters

    • Optional empty: number

      The default value for an empty iterator. Defaults to 0.

    Returns Promise<number>

    The sum.

    -
  • +
  • Returns the sum of all elements in the iterator.

    Parameters

    • empty: bigint

      The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 0n or another bigint.

    Returns Promise<bigint>

    The sum.

    -
  • +
  • Returns the sum of all elements in the iterator.

    Parameters

    • empty: string

      The default value for an empty iterator. For string iterators it's advised to explicitly set this to "" or another string.

    Returns Promise<string>

    The sum.

    -
  • Takes the first n elements of an iterator.

    Parameters

    • n: number

      The number of elements to take.

    Returns AsyncIterPlus<T>

    The generated iterator.

    -
  • tally(): Promise<Record<string, number>>
  • tally(): Promise<Record<string, number>>
  • Tallies elements of an iterator together.

    Returns Promise<Record<string, number>>

    An object mapping keys to the number of times they appeared.

    -
  • tallyWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<Record<K, number>>
  • tallyWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<Record<K, number>>
  • Tallies elements of an iterator together with a key function.

    Type parameters

    • K: string | number | symbol

      The type of the key.

    Parameters

    Returns Promise<Record<K, number>>

    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.

    @@ -694,10 +694,10 @@

    Parameters

    • count: number = 2

      The number of iterators to split into.

    Returns AsyncIterPlus<T>[]

    An array of length count with separate iterators.

    -
  • toArray(): Promise<T[]>
  • toArray(): Promise<T[]>
  • Converts an iterator into an array.

    Returns Promise<T[]>

    The generated array.

    -
  • toMap<K, V>(duplicate: "overwrite" | "maintain" | "error"): Promise<Map<K, V>>
  • toMap<K, V>(duplicate: "overwrite" | "maintain" | "error"): Promise<Map<K, V>>
  • Converts an iterator of key-value pairs into a map.

    throws

    A RangeError if duplicate is "error" and a duplicate key is encountered.

    Type parameters

    • K

      @@ -711,7 +711,7 @@ "error" throws an error. Defaults to "overwrite".

    Returns Promise<Map<K, V>>

    The generated map.

    -
  • toObject<K, V>(duplicate: "overwrite" | "maintain" | "error"): Promise<{}>
  • toObject<K, V>(duplicate: "overwrite" | "maintain" | "error"): Promise<{}>
  • Converts an iterator of key-value pairs into an object.

    throws

    A RangeError if duplicate is "error" and a duplicate key is encountered.

    Type parameters

    • K

      @@ -725,15 +725,15 @@ "error" throws an error. Defaults to "overwrite".

    Returns Promise<{}>

    The generated object.

    -
  • toSet(): Promise<Set<T>>
  • toSet(): Promise<Set<T>>
  • Converts an iterator into a set.

    Returns Promise<Set<T>>

    The generated set.

    -
  • unzip<K>(): Promise<ArrayMap<K>>
  • unzip<K>(): Promise<ArrayMap<K>>
  • "Unzips" an iterator of tuples into a tuple of arrays.

    Type parameters

    • K: unknown[]

      The tuple type.

    Returns Promise<ArrayMap<K>>

    A tuple with the individual elements.

    -
  • windows(windowSize: number, interval?: number): AsyncIterPlus<T[]>
  • windows(windowSize: number, interval?: number): AsyncIterPlus<T[]>
  • Returns an iterator yielding overlapping windows of the iterator.

    If there aren't enough elements to fill a window, no windows will be yielded.

    @@ -742,14 +742,14 @@
  • interval: number = 1

    The increment between the starts of windows. Defaults to 1.

Returns AsyncIterPlus<T[]>

An iterator that yields the windows.

-
  • zip<K>(...iters: AsyncIterableMap<K>): AsyncIterPlus<[T, ...K[]]>
  • zip<K>(...iters: AsyncIterableMap<K>): AsyncIterPlus<[T, ...K[]]>
  • Zips one or more iterables with this iterator.

    Type parameters

    • K: unknown[]

      The types of the other iterables.

    Parameters

    • Rest ...iters: AsyncIterableMap<K>

      The iterables to zip with this one.

    Returns AsyncIterPlus<[T, ...K[]]>

    The generated iterator.

    -
  • Zips one or more iterables with this iterator using a function.

    Stops once any one of the iterators stop.

    Type parameters

    • K: unknown[]

      @@ -761,7 +761,7 @@
    • Rest ...iters: AsyncIterableMap<K>

      The iterables to zip with this one.

    Returns AsyncIterPlus<R>

    The generated iterator.

    -
  • Generates an iterator that iterates through lexicographically sorted combinations without repetition of a dataset.

    Type parameters

    • T

      The item type of the iterator.

      @@ -770,7 +770,7 @@
    • count: number = data.length

      The number of elements in each combination.

    Returns AsyncIterPlus<T[]>

    The generated iterator.

    -
  • combinationsWithRepetition<T>(data: T[], count?: number): AsyncIterPlus<T[]>
  • combinationsWithRepetition<T>(data: T[], count?: number): AsyncIterPlus<T[]>
  • Generates an iterator that iterates through lexicographically sorted combinations with repetition of a dataset.

    Type parameters

    • T

      The item type of the iterator.

      @@ -779,7 +779,7 @@
    • count: number = data.length

      The number of elements in each combination.

    Returns AsyncIterPlus<T[]>

    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, @@ -789,33 +789,33 @@

Parameters

  • data: AsyncIterable<T>

    The iterable to cycle through.

Returns AsyncIterPlus<T>

The generated iterator.

-
  • Generates an iterator that yields values from a function and ends once the function returns null.

    Type parameters

    • T

      The item type of the iterator.

    Parameters

    Returns AsyncIterPlus<T>

    The generated iterator.

    -
  • Generates an iterator that iterates through lexicographically sorted permutations without repetition of a dataset.

    Type parameters

    • T

      The item type of the iterator.

      @@ -824,7 +824,7 @@
    • count: number = data.length

      The number of elements in each permutations.

    Returns AsyncIterPlus<T[]>

    The generated iterator.

    -
  • permutationsWithRepetition<T>(data: T[], count?: number): AsyncIterPlus<T[]>
  • permutationsWithRepetition<T>(data: T[], count?: number): AsyncIterPlus<T[]>
  • Generates an iterator that iterates through lexicographically sorted permutations with repetition of a dataset.

    Type parameters

    • T

      The item type of the iterator.

      @@ -833,35 +833,35 @@
    • count: number = data.length

      The number of elements in each permutations.

    Returns AsyncIterPlus<T[]>

    The generated iterator.

    -
  • Generates an iterator that iterates through the lexicographically sorted powerset of a dataset.

    Type parameters

    • T

      The item type of the iterator.

    Parameters

    • data: T[]

      The data to get the powerset of.

    Returns AsyncIterPlus<T[]>

    The generated iterator.

    -
  • Generates an iterator that generates a lexicographically sorted cartesian product.

    Type parameters

    • T: unknown[]

      The item type of the iterator.

    Parameters

    • Rest ...data: ArrayMap<T>

      The iterators to take the product of.

    Returns AsyncIterPlus<T>

    The generated iterator.

    -
  • Generates an iterator that endlessly repeats a value.

    Type parameters

    • T

      The item type of the iterator.

    Parameters

    Returns AsyncIterPlus<T>

    The generated iterator.

    -
  • Generates an iterator that generates values based on the previous value.

    Type parameters

    • T

      The item type of the iterator.

      @@ -870,4 +870,4 @@
    • func: (prev: T) => PromiseOrValue<null | T>

      The function to generate new values.

    Returns AsyncIterPlus<T>

    The generated iterator.

    -

Legend

  • Private property
  • Private method
  • Method
  • Inherited method
  • Protected property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/classes/AsyncPeekable.html b/docs/classes/AsyncPeekable.html index 1bada04..36beead 100644 --- a/docs/classes/AsyncPeekable.html +++ b/docs/classes/AsyncPeekable.html @@ -3,26 +3,26 @@

Do not instantiate this directly, instead use the peekable method in IterPlus or AsyncIterPlus.

Type parameters

Hierarchy

Index

Constructors

  • new AsyncPeekable<T>(iter: AsyncIterator<T, any, undefined>): AsyncPeekable<T>

Hierarchy

Index

Constructors

  • new AsyncPeekable<T>(iter: AsyncIterator<T, any, undefined>): AsyncPeekable<T>

Properties

internal: AsyncIterator<T, any, undefined>
+

Type parameters

  • T

Parameters

  • iter: AsyncIterator<T, any, undefined>

Returns AsyncPeekable<T>

Properties

internal: AsyncIterator<T, any, undefined>

The internal iterator that this wraps around.

-
storedVal: { has: true; val: IteratorResult<T, any> } | { has: false; val: unknown }

Methods

  • [asyncIterator](): AsyncIterator<T, any, undefined>
storedVal: { has: true; val: IteratorResult<T, any> } | { has: false; val: unknown }

Methods

  • [asyncIterator](): AsyncIterator<T, any, undefined>
  • allEqual(): Promise<boolean>
  • allEqual(): Promise<boolean>
  • Checks if every element in this iterator is equal.

    This function is short-circuiting, so it stops on the first inequality.

    Returns Promise<boolean>

    If every element is equal, or true if the iterator has one or less elements.

    -
  • allEqualBy(cmp: (first: T, second: T) => PromiseOrValue<boolean>): Promise<boolean>
  • allEqualBy(cmp: (first: T, second: T) => PromiseOrValue<boolean>): Promise<boolean>
  • 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.

    Parameters

    Returns Promise<boolean>

    If every element is equal, or true if the iterator has one or less elements.

    -
  • allEqualWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • allEqualWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • 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.

    @@ -31,11 +31,11 @@

Parameters

Returns Promise<boolean>

If every element is equal, or true if the iterator has one or less elements.

-
  • average(): Promise<T>
  • average(): Promise<T>
  • 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.

    @@ -44,7 +44,7 @@

    Parameters

    • chunkSize: number

      The chunk size.

    Returns AsyncIterPlus<T[]>

    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.

    @@ -53,22 +53,22 @@

    Parameters

    • chunkSize: number

      The chunk size.

    Returns AsyncIterPlus<T[]>

    An iterator that yields the chunks.

    -
  • collect(): Promise<T[]>
  • collect(): Promise<T[]>
  • compare(other: AsyncIterable<T>): Promise<number>
  • compare(other: AsyncIterable<T>): Promise<number>
  • Lexicographically compares this iterator with another.

    This function is short-circuiting, so it stops on the first inequality.

    Parameters

    • other: AsyncIterable<T>

      Iterable to compare to.

    Returns Promise<number>

    -1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

    -
  • compareBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<number>): Promise<number>
  • compareBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<number>): Promise<number>
  • Lexicographically compares this iterator with another using a comparison function.

    This function is short-circuiting, so it stops on the first inequality.

    @@ -80,7 +80,7 @@

    A function that should return a negative for less than, zero for equal to, and positive for greater than.

Returns Promise<number>

-1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

-
  • compareWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<number>
  • compareWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<number>

Returns Promise<number>

-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.

    Parameters

    • Rest ...iters: AsyncIterable<T>[]

      The iterables to chain to this one.

    Returns AsyncIterPlus<T>

    The generated iterator.

    -
  • count(): Promise<number>
  • count(): Promise<number>
  • 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.

    Parameters

    • n: number

      The number of elements to drop.

    Returns AsyncIterPlus<T>

    An iterator with the specified number of elements removed from the end.

    -
  • equals(other: AsyncIterable<T>): Promise<boolean>
  • equals(other: AsyncIterable<T>): Promise<boolean>
  • Checks if this iterator is equal to another.

    This function is short-circuiting, so it stops on the first inequality.

    Parameters

    • other: AsyncIterable<T>

      Iterable to compare to.

    Returns Promise<boolean>

    If the two iterators are equal.

    -
  • equalsBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • equalsBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • Checks if this iterator is equal to another using a comparison function.

    This function is short-circuiting, so it stops on the first inequality.

    @@ -153,7 +153,7 @@
  • cmp: (first: T, second: O) => PromiseOrValue<boolean>

    A function that checks if elements are equal.

Returns Promise<boolean>

If the two iterators are equal.

-
  • equalsWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • equalsWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>

Returns Promise<boolean>

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, @@ -172,26 +172,26 @@

    Parameters

    Returns Promise<boolean>

    If every element satisfies the predicate.

    -
  • Finds an element that satisfies a predicate.

    This function is short-circuiting, so it stops on the first match.

    Parameters

    Returns Promise<null | T>

    The element, or null if none was found.

    -
  • findIndex(pred: (elem: T) => PromiseOrValue<boolean>): Promise<number>
  • findIndex(pred: (elem: T) => PromiseOrValue<boolean>): Promise<number>
  • 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.

    @@ -200,7 +200,7 @@

    Parameters

    Returns Promise<number>

    The index, or -1 if none was found.

    -
  • findMap<K>(func: (elem: T) => PromiseOrValue<null | K>): Promise<null | K>
  • findMap<K>(func: (elem: T) => PromiseOrValue<null | K>): Promise<null | K>
  • 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.

    @@ -209,53 +209,53 @@

Parameters

Returns Promise<null | K>

The element, or null if none was found.

-
  • flatMap<K>(func: (elem: T) => Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>): AsyncIterPlus<K>
  • flatMap<K>(func: (elem: T) => Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>): AsyncIterPlus<K>
  • Maps then flattens an iterator.

    Type parameters

    • K

      The resulting type.

    Parameters

    • func: (elem: T) => Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>

      The mapping function.

        • (elem: T): Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>
        • Parameters

          • elem: T

          Returns Iterable<K> | AsyncIterable<K> | Promise<Iterable<K> | AsyncIterable<K>>

    Returns AsyncIterPlus<K>

    The generated iterator.

    -
  • forEach(func: (elem: T) => unknown): Promise<void>
  • forEach(func: (elem: T) => unknown): Promise<void>
  • 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.

    Parameters

    • func: (elem: T) => unknown

      The function to run.

      -
        • (elem: T): unknown
        • Parameters

          • elem: T

          Returns unknown

    Returns Promise<void>

Returns Promise<void>

  • group<K>(key: (elem: T) => PromiseOrValue<K>): Promise<Record<K, T[]>>
  • group<K>(key: (elem: T) => PromiseOrValue<K>): Promise<Record<K, T[]>>
  • hasCached(): boolean
  • hasCached(): boolean
  • Checks if there's a value cached from a previous peek.

    Will return true even if the cached value is the end of the iterator.

    Returns boolean

    If there's a value cached.

    -
  • hasPrefix(other: AsyncIterable<T>): Promise<boolean>
  • hasPrefix(other: AsyncIterable<T>): Promise<boolean>
  • Checks if this iterator is equal to another, while the second iterator still yields elements.

    This function is short-circuiting, @@ -263,7 +263,7 @@

    Parameters

    • other: AsyncIterable<T>

      Iterable to compare to.

    Returns Promise<boolean>

    If the first iterator starts with the second iterator.

    -
  • hasPrefixBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • hasPrefixBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • Checks if this iterator is equal to another, while the second iterator still yields elements, using a comparison function.

    This function is short-circuiting, @@ -275,7 +275,7 @@

  • cmp: (first: T, second: O) => PromiseOrValue<boolean>

    A function that checks if elements are equal.

Returns Promise<boolean>

If the first iterator starts with the second iterator.

-
  • hasPrefixWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • hasPrefixWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>

Returns Promise<boolean>

If the first iterator starts with the second iterator.

-
  • headEquals(other: AsyncIterable<T>): Promise<boolean>
  • headEquals(other: AsyncIterable<T>): Promise<boolean>
  • Checks if this iterator is equal to another, while they both yield elements.

    This function is short-circuiting, @@ -297,7 +297,7 @@

    Parameters

    • other: AsyncIterable<T>

      Iterable to compare to.

    Returns Promise<boolean>

    If the two iterators are equal.

    -
  • headEqualsBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>
  • headEqualsBy<O>(other: AsyncIterable<O>, cmp: (first: T, second: O) => PromiseOrValue<boolean>): Promise<boolean>

Returns Promise<boolean>

If the two iterators are equal.

-
  • headEqualsWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • headEqualsWith<K>(other: AsyncIterable<T>, key: (elem: T) => PromiseOrValue<K>): Promise<boolean>

Returns Promise<boolean>

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.

    Parameters

    • func: (elem: T) => unknown

      The function to call.

        • (elem: T): unknown
        • Parameters

          • elem: T

          Returns unknown

    Returns AsyncIterPlus<T>

    The generated iterator.

    -
  • Interleaves one or more iterables with this iterator.

    Parameters

    • Rest ...iters: AsyncIterable<T>[]

      The iterables to interleave with this one.

    Returns AsyncIterPlus<T>

    The interleaved iterator, yielding elements in the iterators in order.

    -
  • isPartitioned(pred: (elem: T) => PromiseOrValue<boolean>): Promise<boolean>
  • isPartitioned(pred: (elem: T) => PromiseOrValue<boolean>): Promise<boolean>
  • Determines if an iterator is partitioned by a predicate (Items that return true come before items that return false).

    This function is short-circuiting, @@ -354,12 +354,12 @@

    Parameters

    Returns Promise<boolean>

    If the iterator is partitioned.

    -
  • isSorted(): Promise<boolean>
  • isSorted(): Promise<boolean>
  • Determines if an iterator is sorted increasingly.

    This function is short-circuiting, so it stops on the first non-sorted element.

    Returns Promise<boolean>

    If the iterator is sorted.

    -
  • isSortedBy(cmp: (first: T, second: T) => PromiseOrValue<number>): Promise<boolean>
  • isSortedBy(cmp: (first: T, second: T) => PromiseOrValue<number>): Promise<boolean>
  • 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.

    @@ -367,7 +367,7 @@

    A function that should return a negative for less than, zero for equal to, and positive for greater than.

Returns Promise<boolean>

If the iterator is sorted.

-
  • isSortedWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • isSortedWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<boolean>
  • Determines if an iterator is sorted increasingly by a key.

    This function is short-circuiting, so it stops on the first non-sorted element.

    @@ -376,24 +376,24 @@

Parameters

Returns Promise<boolean>

If the iterator is sorted.

-
  • last(): Promise<null | T>
  • last(): Promise<null | T>
  • Finds the last element in an iterator.

    Returns Promise<null | T>

    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.

    Type parameters

    • K

      @@ -401,7 +401,7 @@

    Parameters

    Returns AsyncIterPlus<K>

    The generated iterator.

    -
  • max(overwrite?: boolean): Promise<null | T>
  • max(overwrite?: boolean): Promise<null | T>
  • Finds the maximum value of an iterator.

    Parameters

    • overwrite: boolean = false

      If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

    Returns Promise<null | T>

    The maximum element, or null if the iterator is empty.

    -
  • maxBy(cmp: (first: T, second: T) => PromiseOrValue<number>, overwrite?: boolean): Promise<null | T>
  • maxBy(cmp: (first: T, second: T) => PromiseOrValue<number>, overwrite?: boolean): Promise<null | T>
  • Finds the maximum value of an iterator with a comparison function.

    Parameters

    • cmp: (first: T, second: T) => PromiseOrValue<number>

      A function that should return a negative for less than, zero for equal to, @@ -434,7 +434,7 @@

      If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

    Returns Promise<null | T>

    The maximum element, or null if the iterator is empty.

    -
  • maxWith<K>(key: (elem: T) => PromiseOrValue<K>, overwrite?: boolean): Promise<null | T>
  • maxWith<K>(key: (elem: T) => PromiseOrValue<K>, overwrite?: boolean): Promise<null | T>
  • Finds the maximum value of an iterator with a key.

    Type parameters

    • K

      The type of the key.

      @@ -444,13 +444,13 @@

      If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

    Returns Promise<null | T>

    The maximum element, or null if the iterator is empty.

    -
  • min(overwrite?: boolean): Promise<null | T>
  • min(overwrite?: boolean): Promise<null | T>
  • Finds the minimum value of an iterator.

    Parameters

    • overwrite: boolean = false

      If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

    Returns Promise<null | T>

    The minimum element, or null if the iterator is empty.

    -
  • minBy(cmp: (first: T, second: T) => PromiseOrValue<number>, overwrite?: boolean): Promise<null | T>
  • minBy(cmp: (first: T, second: T) => PromiseOrValue<number>, overwrite?: boolean): Promise<null | T>
  • Finds the minimum value of an iterator with a comparison function.

    Parameters

    • cmp: (first: T, second: T) => PromiseOrValue<number>

      A function that should return a negative for less than, zero for equal to, @@ -459,7 +459,7 @@

      If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

    Returns Promise<null | T>

    The minimum element, or null if the iterator is empty.

    -
  • minWith<K>(key: (elem: T) => PromiseOrValue<K>, overwrite?: boolean): Promise<null | T>
  • minWith<K>(key: (elem: T) => PromiseOrValue<K>, overwrite?: boolean): Promise<null | T>
  • Finds the minimum value of an iterator with a key.

    Type parameters

    • K

      The type of the key.

      @@ -469,34 +469,34 @@

      If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

    Returns Promise<null | T>

    The minimum element, or null if the iterator is empty.

    -
  • next(): Promise<IteratorResult<T, any>>
  • next(): Promise<IteratorResult<T, any>>
  • nextVal(): Promise<null | T>
  • nextVal(): Promise<null | T>
  • nth(n: number): Promise<null | T>
  • nth(n: number): Promise<null | T>
  • Finds the nth element in an iterator.

    Parameters

    • n: number

      The number element to get.

    Returns Promise<null | T>

    The nth element of the iterator, or null if the iterator is too short.

    -
  • 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.

    Parameters

    Returns AsyncIterPlus<T>

    The nubbed iterator.

    -
  • partition(pred: (elem: T) => PromiseOrValue<boolean>): Promise<[T[], T[]]>
  • partition(pred: (elem: T) => PromiseOrValue<boolean>): Promise<[T[], T[]]>
  • Partitions an iterator into two groups.

    Parameters

    • pred: (elem: T) => PromiseOrValue<boolean>

      The predicate function.

      @@ -505,28 +505,28 @@
    • The elements where the predicate returned true.
    • The elements where the predicate returned false.
    -
  • peek(): Promise<IteratorResult<T, any>>
  • peek(): Promise<IteratorResult<T, any>>
  • Peeks the next element in the iterator and does not consume it.

    Returns Promise<IteratorResult<T, any>>

    The next element as an iterator result.

    -
  • peekVal(): Promise<null | T>
  • peekVal(): Promise<null | T>
  • Peeks the next element in the iterator and does not consume it.

    Nullable version of peek.

    Returns Promise<null | T>

    The next element, or null if the iterator is finished.

    -
  • product(empty?: number): Promise<number>
  • product(empty: bigint): Promise<bigint>
  • product(empty?: number): Promise<number>
  • product(empty: bigint): Promise<bigint>
  • Returns the product of all elements in the iterator.

    Parameters

    • Optional empty: number

      The default value for an empty iterator. Defaults to 1.

    Returns Promise<number>

    The product.

    -
  • +
  • Returns the product of all elements in the iterator.

    Parameters

    • empty: bigint

      The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 1n or another bigint.

    Returns Promise<bigint>

    The product.

    -
  • reduce<A>(func: (accum: A, elem: T) => PromiseOrValue<A>, initializer: A): Promise<A>
  • reduce(func: (accum: T, elem: T) => PromiseOrValue<T>): Promise<T>
  • reduce<A>(func: (accum: A, elem: T) => PromiseOrValue<A>, initializer: A): Promise<A>
  • reduce(func: (accum: T, elem: T) => PromiseOrValue<T>): Promise<T>
  • Creates an iterator that repeats the contents of the current iterator a certain number of times.

    Parameters

    • n: number

      The number of times to repeat.

    Returns AsyncIterPlus<T>

    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.

    Returns Promise<IterPlus<T>>

    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. @@ -564,7 +564,7 @@

    Parameters

    • amount: number

      Amount to rotate by.

    Returns AsyncIterPlus<T>

    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.

    @@ -574,7 +574,7 @@

    Parameters

    • amount: number

      Amount to rotate by.

    Returns AsyncIterPlus<T>

    The rotated iterator.

    -
  • Checks if some element in the iterator matches a predicate.

    This function is short-circuiting, so if any element returns true, @@ -610,12 +610,12 @@

    Parameters

    Returns Promise<boolean>

    If some element satisfies the predicate.

    -
  • Splits an iterator on an element, including the matched element as the last element of the chunk.

    Unlike the exclusive split, @@ -623,14 +623,14 @@

    Parameters

    • elem: PromiseOrValue<T>
    • limit: number = Infinity

      The maximum number of chunks to make.

    Returns AsyncIterPlus<T[]>

    The iterator with the split chunks.

    -

Returns AsyncIterPlus<T[]>

The iterator with the split chunks.

-
  • 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.

    Parameters

    • step: number

      The step size.

    Returns AsyncIterPlus<T>

    An iterator that advances by the given step size.

    -
  • sum(empty?: number): Promise<number>
  • sum(empty: bigint): Promise<bigint>
  • sum(empty: string): Promise<string>
  • sum(empty?: number): Promise<number>
  • sum(empty: bigint): Promise<bigint>
  • sum(empty: string): Promise<string>
  • Returns the sum of all elements in the iterator.

    Parameters

    • Optional empty: number

      The default value for an empty iterator. Defaults to 0.

    Returns Promise<number>

    The sum.

    -
  • +
  • Returns the sum of all elements in the iterator.

    Parameters

    • empty: bigint

      The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 0n or another bigint.

    Returns Promise<bigint>

    The sum.

    -
  • +
  • Returns the sum of all elements in the iterator.

    Parameters

    • empty: string

      The default value for an empty iterator. For string iterators it's advised to explicitly set this to "" or another string.

    Returns Promise<string>

    The sum.

    -
  • tally(): Promise<Record<string, number>>
  • tally(): Promise<Record<string, number>>
  • Tallies elements of an iterator together.

    Returns Promise<Record<string, number>>

    An object mapping keys to the number of times they appeared.

    -
  • tallyWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<Record<K, number>>
  • tallyWith<K>(key: (elem: T) => PromiseOrValue<K>): Promise<Record<K, number>>
  • Tallies elements of an iterator together with a key function.

    Type parameters

    • K: string | number | symbol

      The type of the key.

    Parameters

    Returns Promise<Record<K, number>>

    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.

    @@ -702,10 +702,10 @@

    Parameters

    • count: number = 2

      The number of iterators to split into.

    Returns AsyncIterPlus<T>[]

    An array of length count with separate iterators.

    -
  • toArray(): Promise<T[]>
  • toArray(): Promise<T[]>
  • toMap<K, V>(duplicate: "overwrite" | "maintain" | "error"): Promise<Map<K, V>>
  • toMap<K, V>(duplicate: "overwrite" | "maintain" | "error"): Promise<Map<K, V>>
  • Converts an iterator of key-value pairs into a map.

    throws

    A RangeError if duplicate is "error" and a duplicate key is encountered.

    Type parameters

    • K

      @@ -719,7 +719,7 @@ "error" throws an error. Defaults to "overwrite".

    Returns Promise<Map<K, V>>

    The generated map.

    -
  • toObject<K, V>(duplicate: "overwrite" | "maintain" | "error"): Promise<{}>
  • toObject<K, V>(duplicate: "overwrite" | "maintain" | "error"): Promise<{}>
  • Converts an iterator of key-value pairs into an object.

    throws

    A RangeError if duplicate is "error" and a duplicate key is encountered.

    Type parameters

    • K

      @@ -733,15 +733,15 @@ "error" throws an error. Defaults to "overwrite".

    Returns Promise<{}>

    The generated object.

    -
  • toSet(): Promise<Set<T>>
  • toSet(): Promise<Set<T>>
  • unzip<K>(): Promise<ArrayMap<K>>
  • unzip<K>(): Promise<ArrayMap<K>>
  • "Unzips" an iterator of tuples into a tuple of arrays.

    Type parameters

    • K: unknown[]

      The tuple type.

    Returns Promise<ArrayMap<K>>

    A tuple with the individual elements.

    -
  • windows(windowSize: number, interval?: number): AsyncIterPlus<T[]>
  • windows(windowSize: number, interval?: number): AsyncIterPlus<T[]>
  • Returns an iterator yielding overlapping windows of the iterator.

    If there aren't enough elements to fill a window, no windows will be yielded.

    @@ -750,14 +750,14 @@
  • interval: number = 1

    The increment between the starts of windows. Defaults to 1.

Returns AsyncIterPlus<T[]>

An iterator that yields the windows.

-
  • zip<K>(...iters: AsyncIterableMap<K>): AsyncIterPlus<[T, ...K[]]>
  • zip<K>(...iters: AsyncIterableMap<K>): AsyncIterPlus<[T, ...K[]]>
  • Zips one or more iterables with this iterator.

    Type parameters

    • K: unknown[]

      The types of the other iterables.

    Parameters

    • Rest ...iters: AsyncIterableMap<K>

      The iterables to zip with this one.

    Returns AsyncIterPlus<[T, ...K[]]>

    The generated iterator.

    -
  • Zips one or more iterables with this iterator using a function.

    Stops once any one of the iterators stop.

    Type parameters

    • K: unknown[]

      @@ -769,7 +769,7 @@
    • Rest ...iters: AsyncIterableMap<K>

      The iterables to zip with this one.

    Returns AsyncIterPlus<R>

    The generated iterator.

    -
  • Generates an iterator that iterates through lexicographically sorted combinations without repetition of a dataset.

    Type parameters

    • T

      The item type of the iterator.

      @@ -778,7 +778,7 @@
    • count: number = data.length

      The number of elements in each combination.

    Returns AsyncIterPlus<T[]>

    The generated iterator.

    -
  • combinationsWithRepetition<T>(data: T[], count?: number): AsyncIterPlus<T[]>
  • combinationsWithRepetition<T>(data: T[], count?: number): AsyncIterPlus<T[]>
  • Generates an iterator that iterates through lexicographically sorted combinations with repetition of a dataset.

    Type parameters

    • T

      The item type of the iterator.

      @@ -787,7 +787,7 @@
    • count: number = data.length

      The number of elements in each combination.

    Returns AsyncIterPlus<T[]>

    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, @@ -797,33 +797,33 @@

Parameters

  • data: AsyncIterable<T>

    The iterable to cycle through.

Returns AsyncIterPlus<T>

The generated iterator.

-
  • Generates an iterator that iterates through lexicographically sorted permutations without repetition of a dataset.

    Type parameters

    • T

      The item type of the iterator.

      @@ -832,7 +832,7 @@
    • count: number = data.length

      The number of elements in each permutations.

    Returns AsyncIterPlus<T[]>

    The generated iterator.

    -
  • permutationsWithRepetition<T>(data: T[], count?: number): AsyncIterPlus<T[]>
  • permutationsWithRepetition<T>(data: T[], count?: number): AsyncIterPlus<T[]>
  • Generates an iterator that iterates through lexicographically sorted permutations with repetition of a dataset.

    Type parameters

    • T

      The item type of the iterator.

      @@ -841,35 +841,35 @@
    • count: number = data.length

      The number of elements in each permutations.

    Returns AsyncIterPlus<T[]>

    The generated iterator.

    -
  • Generates an iterator that iterates through the lexicographically sorted powerset of a dataset.

    Type parameters

    • T

      The item type of the iterator.

    Parameters

    • data: T[]

      The data to get the powerset of.

    Returns AsyncIterPlus<T[]>

    The generated iterator.

    -
  • Generates an iterator that generates a lexicographically sorted cartesian product.

    Type parameters

    • T: unknown[]

      The item type of the iterator.

    Parameters

    • Rest ...data: ArrayMap<T>

      The iterators to take the product of.

    Returns AsyncIterPlus<T>

    The generated iterator.

    -

Legend

  • Private property
  • Private method
  • Method
  • Inherited method
  • Protected property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/classes/CircularBuffer.html b/docs/classes/CircularBuffer.html index 4045f43..391f816 100644 --- a/docs/classes/CircularBuffer.html +++ b/docs/classes/CircularBuffer.html @@ -2,54 +2,54 @@

A circular buffer with constant time push and pop on both ends.

Type parameters

Hierarchy

Index

Constructors

  • new CircularBuffer<T>(init?: Iterable<T>, capacity?: number): CircularBuffer<T>

Hierarchy

  • CircularBuffer

Index

Constructors

  • new CircularBuffer<T>(init?: Iterable<T>, capacity?: number): CircularBuffer<T>
  • Constructs a new CircularBuffer from a dataset.

    Type parameters

    • T

    Parameters

    • init: Iterable<T> = []

      The initial data.

      -
    • capacity: number = 32

    Returns CircularBuffer<T>

Properties

data: T[]
+
  • capacity: number = 32
  • Returns CircularBuffer<T>

    Properties

    data: T[]

    The data contained in the buffer.

    -
    end: number
    +
    end: number

    The index of the end of the buffer.

    -
    len: number
    +
    len: number

    The number of data elements in the buffer.

    -
    start: number
    +
    start: number

    The index of the start of the buffer.

    -

    Methods

    • [iterator](): Generator<T, any, unknown>

    Methods

    • [iterator](): Generator<T, any, unknown>
    • Generates an iterator for the buffer.

      Returns Generator<T, any, unknown>

      An iterator.

      -
    • capacity(): number
    • capacity(): number
    • Returns the number of elements allocated.

      Returns number

      The number of elements allocated.

      -
    • clear(): void
    • clear(): void
    • Clears the buffer, setting its length to 0.

      This doesn't deallocate any space.

      -

      Returns void

    • get(ind: number): T
    • get(ind: number): T
    • Gets an element from the buffer. Errors on out of bound access.

      Parameters

      • ind: number

        The index to get.

      Returns T

      The element at the index.

      -
    • getEnd(): T
    • getEnd(): T
    • Utility function to get the last element of the buffer. Errors on an empty buffer.

      Returns T

      The element at the back.

      -
    • popEnd(): T
    • popEnd(): T
    • popStart(): T
    • popStart(): T
    • possiblyExpand(): void
    • possiblyExpand(): void
    • possiblyShrink(): void
    • possiblyShrink(): void
    • pushEnd(val: T): void
    • pushEnd(val: T): void
    • Pushes a value to the end of the buffer.

      Parameters

      • val: T

        The value to push.

        -

      Returns void

    • pushStart(val: T): void

    Returns void

    • pushStart(val: T): void
    • Pushes a value to the start of the buffer.

      Parameters

      • val: T

        The value to push.

        -

      Returns void

    • resizeTo(capacity: number): void

    Returns void

    • resizeTo(capacity: number): void
    • Resizes the buffer to a certain capacity.

      This function also makes the buffer contiguous, so toArray will return faster.

      @@ -57,20 +57,20 @@ then it will automatically be scaled up to the length of the buffer.

      Parameters

      • capacity: number

        The capacity to expand to.

        -

      Returns void

    • set(ind: number, val: T): void

    Returns void

    • set(ind: number, val: T): void
    • Sets an element in the buffer. Errors on out of bounds access.

      Parameters

      • ind: number

        The index to set.

      • val: T

        The value to set to.

        -

      Returns void

    • setEnd(val: T): void

    Returns void

    • setEnd(val: T): void
    • Utility function to set the last element of the buffer. Errors on an empty buffer.

      Parameters

      • val: T

        The value to set to.

        -

      Returns void

    • size(): number

    Returns void

    • size(): number
    • Returns the number of elements in the buffer.

      Returns number

      The number of elements.

      -
    • toArray(): T[]
    • toArray(): T[]
    • Returns a shallow-copied array of the data.

      This is faster than collecting the iterator.

      Returns T[]

      The array.

      diff --git a/docs/classes/IterPlus.html b/docs/classes/IterPlus.html index b9de769..70ec9fd 100644 --- a/docs/classes/IterPlus.html +++ b/docs/classes/IterPlus.html @@ -4,28 +4,28 @@ so use tee the iterator into two first if you want to preserve elements.

    Type parameters

    • T

      The item type of the iterator.

      -

    Hierarchy

    Implements

    • CurIter<T>
    • Iterable<T>

    Index

    Constructors

    • new IterPlus<T>(iter: Iterator<T, any, undefined>): IterPlus<T>

    Hierarchy

    Implements

    • CurIter<T>
    • Iterable<T>

    Index

    Constructors

    • new IterPlus<T>(iter: Iterator<T, any, undefined>): IterPlus<T>
    • Instantiates an IterPlus from any iterator.

      Type parameters

      • T

      Parameters

      • iter: Iterator<T, any, undefined>

        The iterator to wrap around.

        -

      Returns IterPlus<T>

    Properties

    internal: Iterator<T, any, undefined>
    +

    Returns IterPlus<T>

    Properties

    internal: Iterator<T, any, undefined>

    The internal iterator that this wraps around.

    -

    Methods

    • [iterator](): Iterator<T, any, undefined>

    Methods

    • [iterator](): Iterator<T, any, undefined>
    • Makes the iterator work as an iterable.

      Returns Iterator<T, any, undefined>

      The same iterator.

      -
    • allEqual(): boolean
    • allEqual(): boolean
    • Checks if every element in this iterator is equal.

      This function is short-circuiting, so it stops on the first inequality.

      Returns boolean

      If every element is equal, or true if the iterator has one or less elements.

      -
    • allEqualBy(cmp: (first: T, second: T) => boolean): boolean
    • allEqualBy(cmp: (first: T, second: T) => boolean): boolean
    • 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.

      Parameters

      • cmp: (first: T, second: T) => boolean

        A function that checks if elements are equal.

          • (first: T, second: T): boolean
          • Parameters

            • first: T
            • second: T

            Returns boolean

      Returns boolean

      If every element is equal, or true if the iterator has one or less elements.

      -
    • allEqualWith<K>(key: (elem: T) => K): boolean
    • allEqualWith<K>(key: (elem: T) => K): boolean
    • 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.

      @@ -34,11 +34,11 @@

    Parameters

    • key: (elem: T) => K

      The key function.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If every element is equal, or true if the iterator has one or less elements.

    -
    • average(): T
    • average(): T
    • Returns the average of all elements in the iterator.

      throws

      A RangeError on an empty iterator.

      Returns T

      The average.

      -
    • chunks(chunkSize: number): IterPlus<T[]>
    • chunks(chunkSize: number): IterPlus<T[]>
    • 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.

      @@ -47,7 +47,7 @@

      Parameters

      • chunkSize: number

        The chunk size.

      Returns IterPlus<T[]>

      An iterator that yields the chunks.

      -
    • chunksExact(chunkSize: number): IterPlus<T[]>
    • chunksExact(chunkSize: number): IterPlus<T[]>
    • 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.

      @@ -56,22 +56,22 @@

      Parameters

      • chunkSize: number

        The chunk size.

      Returns IterPlus<T[]>

      An iterator that yields the chunks.

      -
    • collect(): T[]
    • collect(): T[]
    • Collects the items in this iterator into an array.

      Returns T[]

      An array with the items in the iterator.

      -
    • collectWith<R>(collector: (iter: IterPlus<T>) => R): R
    • collectWith<R>(collector: (iter: IterPlus<T>) => R): R
    • Calls a specified collector function with this iterator as its only argument.

      Type parameters

      • R

      Parameters

      Returns R

      The return value of the collector.

      -
    • compare(other: Iterable<T>): number
    • compare(other: Iterable<T>): number
    • Lexicographically compares this iterator with another.

      This function is short-circuiting, so it stops on the first inequality.

      Parameters

      • other: Iterable<T>

        Iterable to compare to.

      Returns number

      -1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

      -
    • compareBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => number): number
    • compareBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => number): number
    • Lexicographically compares this iterator with another using a comparison function.

      This function is short-circuiting, so it stops on the first inequality.

      @@ -83,7 +83,7 @@

      A function that should return a negative for less than, zero for equal to, and positive for greater than.

        • (first: T, second: O): number
        • Parameters

          • first: T
          • second: O

          Returns number

    Returns number

    -1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

    -
    • compareWith<K>(other: Iterable<T>, key: (elem: T) => K): number
    • compareWith<K>(other: Iterable<T>, key: (elem: T) => K): number
    • Lexicographically compares this iterator with another using a key.

      This function is short-circuiting, so it stops on the first inequality.

      @@ -94,58 +94,58 @@
    • key: (elem: T) => K

      Function to generate a key to compare with from an element.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns number

    -1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

    -
    • concat(...iters: Iterable<T>[]): IterPlus<T>
    • concat(...iters: Iterable<T>[]): IterPlus<T>
    • Concatenates one or more iterables to this iterator, creating an iterator that yields their elements in sequentual order.

      Parameters

      • Rest ...iters: Iterable<T>[]

        The iterables to chain to this one.

      Returns IterPlus<T>

      The generated iterator.

      -
    • construct<R>(ctor: new (item: IterPlus<T>) => R): R
    • construct<R>(ctor: new (item: IterPlus<T>) => R): R
    • Calls a specified constructor with this iterator as its only argument.

      Type parameters

      • R

      Parameters

      • ctor: new (item: IterPlus<T>) => R

        The constructor to use.

      Returns R

      The constructed value.

      -
    • count(): number
    • count(): number
    • Counts the number of items in this iterator.

      Returns number

      The number of items in the iterator.

      -
    • countIf(pred: (elem: T) => boolean): number
    • countIf(pred: (elem: T) => boolean): number
    • Counts the number of items in this iterator that match a predicate.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns number

      The number of matched items in the iterator.

      -
    • Removes elements of an iterator that are equal to the previous one.

      Returns IterPlus<T>

      An iterator with no consecutive duplicates.

      -
    • dedupBy(cmp: (first: T, second: T) => boolean): IterPlus<T>
    • dedupBy(cmp: (first: T, second: T) => boolean): IterPlus<T>
    • Removes elements of an iterator that are equal to the previous one with a comparison function.

      Parameters

      • cmp: (first: T, second: T) => boolean

        A function that checks if elements are equal.

          • (first: T, second: T): boolean
          • Parameters

            • first: T
            • second: T

            Returns boolean

      Returns IterPlus<T>

      An iterator with no consecutive duplicates.

      -
    • dedupWith<K>(key: (elem: T) => K): IterPlus<T>
    • dedupWith<K>(key: (elem: T) => K): IterPlus<T>
    • Removes elements of an iterator that are equal to the previous one with a key.

      Type parameters

      • K

        The type of the key.

      Parameters

      • key: (elem: T) => K

        The key function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns IterPlus<T>

      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.

      Parameters

      • n: number

        The number of elements to drop.

      Returns IterPlus<T>

      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.

      Returns IterPlus<[number, T]>

      The generated iterator.

      -
    • equals(other: Iterable<T>): boolean
    • equals(other: Iterable<T>): boolean
    • Checks if this iterator is equal to another.

      This function is short-circuiting, so it stops on the first inequality.

      Parameters

      • other: Iterable<T>

        Iterable to compare to.

      Returns boolean

      If the two iterators are equal.

      -
    • equalsBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • equalsBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • Checks if this iterator is equal to another using a comparison function.

      This function is short-circuiting, so it stops on the first inequality.

      @@ -156,7 +156,7 @@
    • cmp: (first: T, second: O) => boolean

      A function that checks if elements are equal.

        • (first: T, second: O): boolean
        • Parameters

          • first: T
          • second: O

          Returns boolean

    Returns boolean

    If the two iterators are equal.

    -
    • equalsWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • equalsWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • Checks if this iterator is equal to another using a key.

      This function is short-circuiting, so it stops on the first inequality.

      @@ -167,7 +167,7 @@
    • key: (elem: T) => K

      Function to generate a key to compare with from an element.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If the two iterators are equal.

    -
    • every(pred: (elem: T) => boolean): boolean
    • every(pred: (elem: T) => boolean): boolean
    • Checks if every element in the iterator matches a predicate.

      This function is short-circuiting, so if any element returns false, @@ -175,26 +175,26 @@

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns boolean

      If every element satisfies the predicate.

      -
    • filter(pred: (elem: T) => boolean): IterPlus<T>
    • filter(pred: (elem: T) => boolean): IterPlus<T>
    • Generates an iterator that only yields elements that match a predicate.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns IterPlus<T>

      The generated iterator.

      -
    • filterMap<K>(func: (elem: T) => null | K): IterPlus<K>
    • filterMap<K>(func: (elem: T) => null | K): IterPlus<K>
    • Generates a mapped iterator that yields non-null elements.

      Type parameters

      • K

        The resulting type.

      Parameters

      • func: (elem: T) => null | K

        The mapping function.

          • (elem: T): null | K
          • Parameters

            • elem: T

            Returns null | K

      Returns IterPlus<K>

      The generated iterator.

      -
    • find(pred: (elem: T) => boolean): null | T
    • find(pred: (elem: T) => boolean): null | T
    • Finds an element that satisfies a predicate.

      This function is short-circuiting, so it stops on the first match.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns null | T

      The element, or null if none was found.

      -
    • findIndex(pred: (elem: T) => boolean): number
    • findIndex(pred: (elem: T) => boolean): number
    • 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.

      @@ -203,7 +203,7 @@

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns number

      The index, or -1 if none was found.

      -
    • findMap<K>(func: (elem: T) => null | K): null | K
    • findMap<K>(func: (elem: T) => null | K): null | K
    • 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.

      @@ -212,49 +212,49 @@

    Parameters

    • func: (elem: T) => null | K

      The mapping function.

        • (elem: T): null | K
        • Parameters

          • elem: T

          Returns null | K

    Returns null | K

    The element, or null if none was found.

    -
    • flatMap<K>(func: (elem: T) => Iterable<K>): IterPlus<K>
    • flatMap<K>(func: (elem: T) => Iterable<K>): IterPlus<K>
    • Maps then flattens an iterator.

      Type parameters

      • K

        The resulting type.

      Parameters

      • func: (elem: T) => Iterable<K>

        The mapping function.

          • (elem: T): Iterable<K>
          • Parameters

            • elem: T

            Returns Iterable<K>

      Returns IterPlus<K>

      The generated iterator.

      -
    • Flattens an iterator of iterables, yielding an iterator that sequentially produces their elements.

      Type parameters

      • K

        The internal type.

      Returns IterPlus<K>

      The generated iterator.

      -
    • forEach(func: (elem: T) => unknown): void
    • forEach(func: (elem: T) => unknown): void
    • 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.

      Parameters

      • func: (elem: T) => unknown

        The function to run.

        -
          • (elem: T): unknown
          • Parameters

            • elem: T

            Returns unknown

      Returns void

    Returns void

    • Generates an iterator that is guaranteed to never yield a value after finishing.

      Returns IterPlus<T>

      The generated iterator.

      -
    • Globs elements of an iterator together.

      Returns IterPlus<T[]>

      An iterator where every element is an array of consecutively equal elements.

      -
    • globBy(cmp: (first: T, second: T) => boolean): IterPlus<T[]>
    • globBy(cmp: (first: T, second: T) => boolean): IterPlus<T[]>
    • Globs elements of an iterator together, with a comparison function.

      Parameters

      • cmp: (first: T, second: T) => boolean

        A function that checks if elements are equal.

          • (first: T, second: T): boolean
          • Parameters

            • first: T
            • second: T

            Returns boolean

      Returns IterPlus<T[]>

      An iterator where every element is an array of consecutively equal elements.

      -
    • globWith<K>(key: (elem: T) => K): IterPlus<T[]>
    • globWith<K>(key: (elem: T) => K): IterPlus<T[]>
    • Globs elements of an iterator together, with a key function.

      Type parameters

      • K

        The type of the key.

      Parameters

      • key: (elem: T) => K

        The key function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns IterPlus<T[]>

      An iterator where every element is an array of consecutively equal elements.

      -
    • group<K>(key: (elem: T) => K): Record<K, T[]>
    • group<K>(key: (elem: T) => K): Record<K, T[]>
    • Groups elements of an iterator together with a key function.

      Type parameters

      • K: string | number | symbol

        The type of the key.

      Parameters

      • key: (elem: T) => K
          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns Record<K, T[]>

      An object mapping keys to arrays of matching items.

      -
    • hasPrefix(other: Iterable<T>): boolean
    • hasPrefix(other: Iterable<T>): boolean
    • Checks if this iterator is equal to another, while the second iterator still yields elements.

      This function is short-circuiting, @@ -262,7 +262,7 @@

      Parameters

      • other: Iterable<T>

        Iterable to compare to.

      Returns boolean

      If the first iterator starts with the second iterator.

      -
    • hasPrefixBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • hasPrefixBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • Checks if this iterator is equal to another, while the second iterator still yields elements, using a comparison function.

      This function is short-circuiting, @@ -274,7 +274,7 @@

    • cmp: (first: T, second: O) => boolean

      A function that checks if elements are equal.

        • (first: T, second: O): boolean
        • Parameters

          • first: T
          • second: O

          Returns boolean

    Returns boolean

    If the first iterator starts with the second iterator.

    -
    • hasPrefixWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • hasPrefixWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • Checks if this iterator is equal to another, while the second iterator still yields elements, with a key function.

      This function is short-circuiting, @@ -286,7 +286,7 @@

    • key: (elem: T) => K

      The key function.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If the first iterator starts with the second iterator.

    -
    • headEquals(other: Iterable<T>): boolean
    • headEquals(other: Iterable<T>): boolean
    • Checks if this iterator is equal to another, while they both yield elements.

      This function is short-circuiting, @@ -296,7 +296,7 @@

      Parameters

      • other: Iterable<T>

        Iterable to compare to.

      Returns boolean

      If the two iterators are equal.

      -
    • headEqualsBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • headEqualsBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • Checks if this iterator is equal to another, while they both yield elements, using a comparison function.

      This function is short-circuiting, @@ -310,7 +310,7 @@

    • cmp: (first: T, second: O) => boolean

      A function that checks if elements are equal.

        • (first: T, second: O): boolean
        • Parameters

          • first: T
          • second: O

          Returns boolean

    Returns boolean

    If the two iterators are equal.

    -
    • headEqualsWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • headEqualsWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • Checks if this iterator is equal to another, while they both yield elements, using a key.

      This function is short-circuiting, @@ -324,28 +324,28 @@

    • key: (elem: T) => K

      The key function.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If the two iterators are equal.

    -
    • inspect(func: (elem: T) => unknown): IterPlus<T>
    • inspect(func: (elem: T) => unknown): IterPlus<T>
    • 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.

      Parameters

      • func: (elem: T) => unknown

        The function to call.

          • (elem: T): unknown
          • Parameters

            • elem: T

            Returns unknown

      Returns IterPlus<T>

      The generated iterator.

      -
    • interleave(...iters: Iterable<T>[]): IterPlus<T>
    • interleave(...iters: Iterable<T>[]): IterPlus<T>
    • Interleaves one or more iterables with this iterator.

      Parameters

      • Rest ...iters: Iterable<T>[]

        The iterables to interleave with this one.

      Returns IterPlus<T>

      The interleaved iterator, yielding elements in the iterators in order.

      -
    • Intersperses an element between every element of the iterator.

      Parameters

      • elem: T

        The element to intersperse.

      Returns IterPlus<T>

      The new iterator.

      -
    • intersperseMultiple(elems: Iterable<T>): IterPlus<T>
    • intersperseMultiple(elems: Iterable<T>): IterPlus<T>
    • Intersperses multiple elements between every element of the iterator.

      Parameters

      • elems: Iterable<T>

        The elements to intersperse.

      Returns IterPlus<T>

      The new iterator.

      -
    • isPartitioned(pred: (elem: T) => boolean): boolean
    • isPartitioned(pred: (elem: T) => boolean): boolean
    • Determines if an iterator is partitioned by a predicate (Items that return true come before items that return false).

      This function is short-circuiting, @@ -353,12 +353,12 @@

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns boolean

      If the iterator is partitioned.

      -
    • isSorted(): boolean
    • isSorted(): boolean
    • Determines if an iterator is sorted increasingly.

      This function is short-circuiting, so it stops on the first non-sorted element.

      Returns boolean

      If the iterator is sorted.

      -
    • isSortedBy(cmp: (first: T, second: T) => number): boolean
    • isSortedBy(cmp: (first: T, second: T) => number): boolean
    • 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.

      @@ -366,7 +366,7 @@

      A function that should return a negative for less than, zero for equal to, and positive for greater than.

        • (first: T, second: T): number
        • Parameters

          • first: T
          • second: T

          Returns number

    Returns boolean

    If the iterator is sorted.

    -
    • isSortedWith<K>(key: (elem: T) => K): boolean
    • isSortedWith<K>(key: (elem: T) => K): boolean
    • Determines if an iterator is sorted increasingly by a key.

      This function is short-circuiting, so it stops on the first non-sorted element.

      @@ -375,24 +375,24 @@

    Parameters

    • key: (elem: T) => K

      The key function.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If the iterator is sorted.

    -
    • Joins an iterator of iterables with an element.

      Type parameters

      • K

        The internal type.

      Parameters

      • elem: K

        The element to join with.

      Returns IterPlus<K>

      The joined iterator.

      -
    • joinMultiple<K>(elems: Iterable<K>): IterPlus<K>
    • joinMultiple<K>(elems: Iterable<K>): IterPlus<K>
    • Joins an iterator of iterables with multiple elements.

      Type parameters

      • K

        The internal type.

      Parameters

      • elems: Iterable<K>

        The elements to intersperse.

      Returns IterPlus<K>

      The joined iterator.

      -
    • last(): null | T
    • last(): null | T
    • Finds the last element in an iterator.

      Returns null | T

      The last element of the iterator, or null if the iterator is empty.

      -
    • map<K>(func: (elem: T) => K): IterPlus<K>
    • map<K>(func: (elem: T) => K): IterPlus<K>
    • 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.

      Type parameters

      • K

        @@ -400,7 +400,7 @@

      Parameters

      • func: (elem: T) => K

        The mapping function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns IterPlus<K>

      The generated iterator.

      -
    • mapAccum<A, V>(func: (accum: A, elem: T) => [A, V], initializer: A): IterPlus<V>
    • mapAccum<A, V>(func: (accum: A, elem: T) => [A, V], initializer: A): IterPlus<V>
    • Runs a function for every element of the iterator, keeping track of an accumulator.

      Type parameters

      • A

        The type of the accumulator.

        @@ -411,20 +411,20 @@
          • (accum: A, elem: T): [A, V]
          • Parameters

            • accum: A
            • elem: T

            Returns [A, V]

      • initializer: A

        The initial accumulator.

      Returns IterPlus<V>

      The mapped iterator.

      -
    • mapWhile<K>(func: (elem: T) => null | K): IterPlus<K>
    • mapWhile<K>(func: (elem: T) => null | K): IterPlus<K>
    • Lazily maps an iterator until it encounters null.

      Type parameters

      • K

        The resulting type.

      Parameters

      • func: (elem: T) => null | K

        The mapping function.

          • (elem: T): null | K
          • Parameters

            • elem: T

            Returns null | K

      Returns IterPlus<K>

      The generated iterator.

      -
    • max(overwrite?: boolean): null | T
    • max(overwrite?: boolean): null | T
    • Finds the maximum value of an iterator.

      Parameters

      • overwrite: boolean = false

        If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

      Returns null | T

      The maximum element, or null if the iterator is empty.

      -
    • maxBy(cmp: (first: T, second: T) => number, overwrite?: boolean): null | T
    • maxBy(cmp: (first: T, second: T) => number, overwrite?: boolean): null | T
    • Finds the maximum value of an iterator with a comparison function.

      Parameters

      • cmp: (first: T, second: T) => number

        A function that should return a negative for less than, zero for equal to, @@ -433,7 +433,7 @@

        If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

      Returns null | T

      The maximum element, or null if the iterator is empty.

      -
    • maxWith<K>(key: (elem: T) => K, overwrite?: boolean): null | T
    • maxWith<K>(key: (elem: T) => K, overwrite?: boolean): null | T
    • Finds the maximum value of an iterator with a key.

      Type parameters

      • K

        The type of the key.

        @@ -443,13 +443,13 @@

        If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

      Returns null | T

      The maximum element, or null if the iterator is empty.

      -
    • min(overwrite?: boolean): null | T
    • min(overwrite?: boolean): null | T
    • Finds the minimum value of an iterator.

      Parameters

      • overwrite: boolean = false

        If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

      Returns null | T

      The minimum element, or null if the iterator is empty.

      -
    • minBy(cmp: (first: T, second: T) => number, overwrite?: boolean): null | T
    • minBy(cmp: (first: T, second: T) => number, overwrite?: boolean): null | T
    • Finds the minimum value of an iterator with a comparison function.

      Parameters

      • cmp: (first: T, second: T) => number

        A function that should return a negative for less than, zero for equal to, @@ -458,7 +458,7 @@

        If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

      Returns null | T

      The minimum element, or null if the iterator is empty.

      -
    • minWith<K>(key: (elem: T) => K, overwrite?: boolean): null | T
    • minWith<K>(key: (elem: T) => K, overwrite?: boolean): null | T
    • Finds the minimum value of an iterator with a key.

      Type parameters

      • K

        The type of the key.

        @@ -468,34 +468,34 @@

        If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

      Returns null | T

      The minimum element, or null if the iterator is empty.

      -
    • next(): IteratorResult<T, any>
    • next(): IteratorResult<T, any>
    • Yields the next element in the iterator.

      Returns IteratorResult<T, any>

      The next element.

      -
    • nextVal(): null | T
    • nextVal(): null | T
    • Returns the next value, or null if the iterator ended.

      Returns null | T

      The next value, or null if the iterator ended.

      -
    • nth(n: number): null | T
    • nth(n: number): null | T
    • Finds the nth element in an iterator.

      Parameters

      • n: number

        The number element to get.

      Returns null | T

      The nth element of the iterator, or null if the iterator is too short.

      -
    • Removes duplicates from an iterator, including non-consecutive ones.

      Returns IterPlus<T>

      The nubbed iterator.

      -
    • nubBy(cmp: (first: T, second: T) => boolean): IterPlus<T>
    • nubBy(cmp: (first: T, second: T) => boolean): IterPlus<T>
    • 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.

      Parameters

      • cmp: (first: T, second: T) => boolean

        A function that checks if elements are equal.

          • (first: T, second: T): boolean
          • Parameters

            • first: T
            • second: T

            Returns boolean

      Returns IterPlus<T>

      The nubbed iterator.

      -
    • nubWith<K>(key: (elem: T) => K): IterPlus<T>
    • nubWith<K>(key: (elem: T) => K): IterPlus<T>
    • Removes duplicates from an iterator, including non-consecutive ones, with a key function.

      Type parameters

      • K

        The type of the key.

      Parameters

      • key: (elem: T) => K

        The key function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns IterPlus<T>

      The nubbed iterator.

      -
    • partition(pred: (elem: T) => boolean): [T[], T[]]
    • partition(pred: (elem: T) => boolean): [T[], T[]]
    • Partitions an iterator into two groups.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

        @@ -504,21 +504,21 @@
      • The elements where the predicate returned true.
      • The elements where the predicate returned false.
      -
    • product(empty?: number): number
    • product(empty: bigint): bigint
    • product(empty?: number): number
    • product(empty: bigint): bigint
    • Returns the product of all elements in the iterator.

      Parameters

      • Optional empty: number

        The default value for an empty iterator. Defaults to 1.

      Returns number

      The product.

      -
    • +
    • Returns the product of all elements in the iterator.

      Parameters

      • empty: bigint

        The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 1n or another bigint.

      Returns bigint

      The product.

      -
    • reduce<A>(func: (accum: A, elem: T) => A, initializer: A): A
    • reduce(func: (accum: T, elem: T) => T): T
    • reduce<A>(func: (accum: A, elem: T) => A, initializer: A): A
    • reduce(func: (accum: T, elem: T) => T): T
    • Runs a function for every element of the iterator, keeping track of an accumulator.

      Type parameters

      • A

        The type of the accumulator.

        @@ -527,7 +527,7 @@
          • (accum: A, elem: T): A
          • Parameters

            • accum: A
            • elem: T

            Returns A

      • initializer: A

        The initial accumulator.

      Returns A

      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.

      @@ -536,18 +536,18 @@

      Parameters

      • func: (accum: T, elem: T) => T

        The reducing function.

          • (accum: T, elem: T): T
          • Parameters

            • accum: T
            • elem: T

            Returns T

      Returns T

      The final accumulator.

      -
    • Creates an iterator that repeats the contents of the current iterator a certain number of times.

      Parameters

      • n: number

        The number of times to repeat.

      Returns IterPlus<T>

      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.

      Returns IterPlus<T>

      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. @@ -556,7 +556,7 @@

      Parameters

      • amount: number

        Amount to rotate by.

      Returns IterPlus<T>

      The rotated iterator.

      -
    • rotateRight(amount: number): IterPlus<T>
    • rotateRight(amount: number): IterPlus<T>
    • 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.

      @@ -566,7 +566,7 @@

      Parameters

      • amount: number

        Amount to rotate by.

      Returns IterPlus<T>

      The rotated iterator.

      -
    • scan<A>(func: (accum: A, elem: T) => A, initializer: A): IterPlus<A>
    • scan(func: (accum: T, elem: T) => T): IterPlus<T>
    • scan<A>(func: (accum: A, elem: T) => A, initializer: A): IterPlus<A>
    • scan(func: (accum: T, elem: T) => T): IterPlus<T>
    • Runs a function for every element of the iterator, keeping track of an accumulator.

      Type parameters

      • A

        The type of the accumulator.

        @@ -575,7 +575,7 @@
          • (accum: A, elem: T): A
          • Parameters

            • accum: A
            • elem: T

            Returns A

      • initializer: A

        The initial accumulator.

      Returns IterPlus<A>

      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.

      @@ -584,17 +584,17 @@

      Parameters

      • func: (accum: T, elem: T) => T

        The reducing function.

          • (accum: T, elem: T): T
          • Parameters

            • accum: T
            • elem: T

            Returns T

      Returns IterPlus<T>

      The iterator containing all intermediate accumulators.

      -
    • Skips the first n elements of an iterator.

      Parameters

      • n: number

        The number of elements to skip.

      Returns IterPlus<T>

      The generated iterator.

      -
    • skipWhile(pred: (elem: T) => boolean): IterPlus<T>
    • skipWhile(pred: (elem: T) => boolean): IterPlus<T>
    • Skips elements of an iterator while a predicate is met.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns IterPlus<T>

      The generated iterator.

      -
    • some(pred: (elem: T) => boolean): boolean
    • some(pred: (elem: T) => boolean): boolean
    • Checks if some element in the iterator matches a predicate.

      This function is short-circuiting, so if any element returns true, @@ -602,12 +602,12 @@

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns boolean

      If some element satisfies the predicate.

      -
    • split(elem: T, limit?: number): IterPlus<T[]>
    • split(elem: T, limit?: number): IterPlus<T[]>
    • Splits an iterator on an element.

      Parameters

      • elem: T
      • limit: number = Infinity

        The maximum number of chunks to make.

      Returns IterPlus<T[]>

      The iterator with the split chunks.

      -
    • splitInclusive(elem: T, limit?: number): IterPlus<T[]>
    • splitInclusive(elem: T, limit?: number): IterPlus<T[]>
    • Splits an iterator on an element, including the matched element as the last element of the chunk.

      Unlike the exclusive split, @@ -615,14 +615,14 @@

      Parameters

      • elem: T
      • limit: number = Infinity

        The maximum number of chunks to make.

      Returns IterPlus<T[]>

      The iterator with the split chunks.

      -
    • splitPred(pred: (elem: T) => boolean, limit?: number): IterPlus<T[]>
    • splitPred(pred: (elem: T) => boolean, limit?: number): IterPlus<T[]>
    • Splits an iterator on a predicate.

      Parameters

      • pred: (elem: T) => boolean

        The predicate to split with.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      • limit: number = Infinity

        The maximum number of chunks to make.

      Returns IterPlus<T[]>

      The iterator with the split chunks.

      -
    • splitPredInclusive(pred: (elem: T) => boolean, limit?: number): IterPlus<T[]>
    • splitPredInclusive(pred: (elem: T) => boolean, limit?: number): IterPlus<T[]>
    • Splits an iterator on a predicate, including the matched element as the last element of the chunk.

      Unlike the exclusive split, @@ -632,7 +632,7 @@

        • (elem: T): boolean
        • Parameters

          • elem: T

          Returns boolean

    • limit: number = Infinity

      The maximum number of chunks to make.

    Returns IterPlus<T[]>

    The iterator with the split chunks.

    -
    • starmap<K, R>(func: (...args: K[]) => R): IterPlus<R>
    • starmap<K, R>(func: (...args: K[]) => R): IterPlus<R>
    • Maps an iterator of iterables, and calls a function with the contents of the iterable as the argument.

      Type parameters

      • K

        @@ -642,50 +642,50 @@

      Parameters

      • func: (...args: K[]) => R

        The mapping function.

          • (...args: K[]): R
          • Parameters

            • Rest ...args: K[]

            Returns R

      Returns IterPlus<R>

      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.

      Parameters

      • step: number

        The step size.

      Returns IterPlus<T>

      An iterator that advances by the given step size.

      -
    • sum(empty?: number): number
    • sum(empty: bigint): bigint
    • sum(empty: string): string
    • sum(empty?: number): number
    • sum(empty: bigint): bigint
    • sum(empty: string): string
    • Returns the sum of all elements in the iterator.

      Parameters

      • Optional empty: number

        The default value for an empty iterator. Defaults to 0.

      Returns number

      The sum.

      -
    • +
    • Returns the sum of all elements in the iterator.

      Parameters

      • empty: bigint

        The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 0n or another bigint.

      Returns bigint

      The sum.

      -
    • +
    • Returns the sum of all elements in the iterator.

      Parameters

      • empty: string

        The default value for an empty iterator. For string iterators it's advised to explicitly set this to "" or another string.

      Returns string

      The sum.

      -
    • Takes the first n elements of an iterator.

      Parameters

      • n: number

        The number of elements to take.

      Returns IterPlus<T>

      The generated iterator.

      -
    • takeWhile(pred: (elem: T) => boolean): IterPlus<T>
    • takeWhile(pred: (elem: T) => boolean): IterPlus<T>
    • Takes elements of an iterator while a predicate is met.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns IterPlus<T>

      The generated iterator.

      -
    • tally(): Record<string, number>
    • tally(): Record<string, number>
    • Tallies elements of an iterator together.

      Returns Record<string, number>

      An object mapping keys to the number of times they appeared.

      -
    • tallyWith<K>(key: (elem: T) => K): Record<K, number>
    • tallyWith<K>(key: (elem: T) => K): Record<K, number>
    • Tallies elements of an iterator together with a key function.

      Type parameters

      • K: string | number | symbol

        The type of the key.

      Parameters

      • key: (elem: T) => K

        The key function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns Record<K, number>

      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.

      @@ -694,10 +694,10 @@

      Parameters

      • count: number = 2

        The number of iterators to split into.

      Returns IterPlus<T>[]

      An array of length count with separate iterators.

      -
    • toArray(): T[]
    • toArray(): T[]
    • Converts an iterator into an array.

      Returns T[]

      The generated array.

      -
    • toMap<K, V>(duplicate: "overwrite" | "maintain" | "error"): Map<K, V>
    • toMap<K, V>(duplicate: "overwrite" | "maintain" | "error"): Map<K, V>
    • Converts an iterator of key-value pairs into a map.

      throws

      A RangeError if duplicate is "error" and a duplicate key is encountered.

      Type parameters

      • K

        @@ -711,7 +711,7 @@ "error" throws an error. Defaults to "overwrite".

      Returns Map<K, V>

      The generated map.

      -
    • toObject<K, V>(duplicate: "overwrite" | "maintain" | "error"): {}
    • toObject<K, V>(duplicate: "overwrite" | "maintain" | "error"): {}
    • Converts an iterator of key-value pairs into an object.

      throws

      A RangeError if duplicate is "error" and a duplicate key is encountered.

      Type parameters

      • K

        @@ -725,15 +725,15 @@ "error" throws an error. Defaults to "overwrite".

      Returns {}

      The generated object.

      -
      • [key: string]: V
    • toSet(): Set<T>
    • toSet(): Set<T>
    • Converts an iterator into a set.

      Returns Set<T>

      The generated set.

      -
    • unzip<K>(): ArrayMap<K>
    • unzip<K>(): ArrayMap<K>
    • "Unzips" an iterator of tuples into a tuple of arrays.

      Type parameters

      • K: unknown[]

        The tuple type.

      Returns ArrayMap<K>

      A tuple with the individual elements.

      -
    • windows(windowSize: number, interval?: number): IterPlus<T[]>
    • windows(windowSize: number, interval?: number): IterPlus<T[]>
    • Returns an iterator yielding overlapping windows of the iterator.

      If there aren't enough elements to fill a window, no windows will be yielded.

      @@ -742,14 +742,14 @@
    • interval: number = 1

      The increment between the starts of windows. Defaults to 1.

    Returns IterPlus<T[]>

    An iterator that yields the windows.

    -
    • zip<K>(...iters: IterableMap<K>): IterPlus<[T, ...K[]]>
    • zip<K>(...iters: IterableMap<K>): IterPlus<[T, ...K[]]>
    • Zips one or more iterables with this iterator.

      Type parameters

      • K: unknown[]

        The types of the other iterables.

      Parameters

      • Rest ...iters: IterableMap<K>

        The iterables to zip with this one.

      Returns IterPlus<[T, ...K[]]>

      The generated iterator.

      -
    • zipWith<K, R>(func: (...args: [T, ...K[]]) => R, ...iters: IterableMap<K>): IterPlus<R>
    • zipWith<K, R>(func: (...args: [T, ...K[]]) => R, ...iters: IterableMap<K>): IterPlus<R>
    • Zips one or more iterables with this iterator using a function.

      Stops once any one of the iterators stop.

      Type parameters

      • K: unknown[]

        @@ -761,7 +761,7 @@
          • (...args: [T, ...K[]]): R
          • Parameters

            • Rest ...args: [T, ...K[]]

            Returns R

      • Rest ...iters: IterableMap<K>

        The iterables to zip with this one.

      Returns IterPlus<R>

      The generated iterator.

      -
    • combinations<T>(data: T[], count?: number): IterPlus<T[]>
    • combinations<T>(data: T[], count?: number): IterPlus<T[]>
    • Generates an iterator that iterates through lexicographically sorted combinations without repetition of a dataset.

      Type parameters

      • T

        The item type of the iterator.

        @@ -770,7 +770,7 @@
      • count: number = data.length

        The number of elements in each combination.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • combinationsWithRepetition<T>(data: T[], count?: number): IterPlus<T[]>
    • combinationsWithRepetition<T>(data: T[], count?: number): IterPlus<T[]>
    • Generates an iterator that iterates through lexicographically sorted combinations with repetition of a dataset.

      Type parameters

      • T

        The item type of the iterator.

        @@ -779,7 +779,7 @@
      • count: number = data.length

        The number of elements in each combination.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • cycle<T>(data: Iterable<T>): IterPlus<T>
    • cycle<T>(data: Iterable<T>): IterPlus<T>
    • Generates an iterator that cycles through an iterable.

      While this does work on infinite iterators, it should be avoided as it stores all elements, @@ -789,33 +789,33 @@

    Parameters

    • data: Iterable<T>

      The iterable to cycle through.

    Returns IterPlus<T>

    The generated iterator.

    -
    • Generates an empty iterator.

      Type parameters

      • T

        The item yielded by the iterator.

      Returns IterPlus<T>

      The generated iterator.

      -
    • fromFunction<T>(func: () => null | T): IterPlus<T>
    • fromFunction<T>(func: () => null | T): IterPlus<T>
    • Generates an iterator that yields values from a function and ends once the function returns null.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • func: () => null | T

        The function to yield values, or null to end the iterator.

          • (): null | T
          • Returns null | T

      Returns IterPlus<T>

      The generated iterator.

      -
    • Generates an iterator that yields a single value.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • val: T

        The value to yield.

      Returns IterPlus<T>

      The generated iterator.

      -
    • Generates an iterator that lazily yields a single value.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • func: () => T

        The function to generate a single value.

          • (): T
          • Returns T

      Returns IterPlus<T>

      The generated iterator.

      -
    • permutations<T>(data: T[], count?: number): IterPlus<T[]>
    • permutations<T>(data: T[], count?: number): IterPlus<T[]>
    • Generates an iterator that iterates through lexicographically sorted permutations without repetition of a dataset.

      Type parameters

      • T

        The item type of the iterator.

        @@ -824,7 +824,7 @@
      • count: number = data.length

        The number of elements in each permutations.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • permutationsWithRepetition<T>(data: T[], count?: number): IterPlus<T[]>
    • permutationsWithRepetition<T>(data: T[], count?: number): IterPlus<T[]>
    • Generates an iterator that iterates through lexicographically sorted permutations with repetition of a dataset.

      Type parameters

      • T

        The item type of the iterator.

        @@ -833,35 +833,35 @@
      • count: number = data.length

        The number of elements in each permutations.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • Generates an iterator that iterates through the lexicographically sorted powerset of a dataset.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • data: T[]

        The data to get the powerset of.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • product<T>(...data: ArrayMap<T>): IterPlus<T>
    • product<T>(...data: ArrayMap<T>): IterPlus<T>
    • Generates an iterator that generates a lexicographically sorted cartesian product.

      Type parameters

      • T: unknown[]

        The item type of the iterator.

      Parameters

      • Rest ...data: ArrayMap<T>

        The iterators to take the product of.

      Returns IterPlus<T>

      The generated iterator.

      -
    • Generates an iterator that endlessly repeats a value.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • val: T

        The value to yield.

      Returns IterPlus<T>

      The generated iterator.

      -
    • repeatWith<T>(func: () => T): IterPlus<T>
    • repeatWith<T>(func: () => T): IterPlus<T>
    • Generates an iterator that endlessly calls a function.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • func: () => T

        The function to generate values.

          • (): T
          • Returns T

      Returns IterPlus<T>

      The generated iterator.

      -
    • successors<T>(first: null | T, func: (prev: T) => null | T): IterPlus<T>
    • successors<T>(first: null | T, func: (prev: T) => null | T): IterPlus<T>
    • Generates an iterator that generates values based on the previous value.

      Type parameters

      • T

        The item type of the iterator.

        @@ -870,4 +870,4 @@
      • func: (prev: T) => null | T

        The function to generate new values.

          • (prev: T): null | T
          • Parameters

            • prev: T

            Returns null | T

      Returns IterPlus<T>

      The generated iterator.

      -
    • unfold<T, A>(func: (accum: A) => null | [T, A], init: A): IterPlus<T>
    • Type parameters

      • T

      • A

      Parameters

      • func: (accum: A) => null | [T, A]
          • (accum: A): null | [T, A]
          • Parameters

            • accum: A

            Returns null | [T, A]

      • init: A

      Returns IterPlus<T>

    Legend

    • Private property
    • Private method
    • Method
    • Inherited method
    • Protected property

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +
    • unfold<T, A>(func: (accum: A) => null | [T, A], init: A): IterPlus<T>
    • Type parameters

      • T

      • A

      Parameters

      • func: (accum: A) => null | [T, A]
          • (accum: A): null | [T, A]
          • Parameters

            • accum: A

            Returns null | [T, A]

      • init: A

      Returns IterPlus<T>

    Legend

    • Private property
    • Private method
    • Method
    • Inherited method
    • Protected property

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/classes/Peekable.html b/docs/classes/Peekable.html index c0a005d..1fdefd5 100644 --- a/docs/classes/Peekable.html +++ b/docs/classes/Peekable.html @@ -3,26 +3,26 @@

    Do not instantiate this directly, instead use the peekable method in IterPlus or AsyncIterPlus.

    Type parameters

    Hierarchy

    Index

    Constructors

    • new Peekable<T>(iter: Iterator<T, any, undefined>): Peekable<T>

    Hierarchy

    Index

    Constructors

    • new Peekable<T>(iter: Iterator<T, any, undefined>): Peekable<T>

    Properties

    internal: Iterator<T, any, undefined>
    +

    Type parameters

    • T

    Parameters

    • iter: Iterator<T, any, undefined>

    Returns Peekable<T>

    Properties

    internal: Iterator<T, any, undefined>

    The internal iterator that this wraps around.

    -
    storedVal: { has: true; val: IteratorResult<T, any> } | { has: false; val: unknown }

    Methods

    • [iterator](): Iterator<T, any, undefined>
    storedVal: { has: true; val: IteratorResult<T, any> } | { has: false; val: unknown }

    Methods

    • [iterator](): Iterator<T, any, undefined>
    • allEqual(): boolean
    • allEqual(): boolean
    • Checks if every element in this iterator is equal.

      This function is short-circuiting, so it stops on the first inequality.

      Returns boolean

      If every element is equal, or true if the iterator has one or less elements.

      -
    • allEqualBy(cmp: (first: T, second: T) => boolean): boolean
    • allEqualBy(cmp: (first: T, second: T) => boolean): boolean
    • 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.

      Parameters

      • cmp: (first: T, second: T) => boolean

        A function that checks if elements are equal.

          • (first: T, second: T): boolean
          • Parameters

            • first: T
            • second: T

            Returns boolean

      Returns boolean

      If every element is equal, or true if the iterator has one or less elements.

      -
    • allEqualWith<K>(key: (elem: T) => K): boolean
    • allEqualWith<K>(key: (elem: T) => K): boolean
    • 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.

      @@ -31,11 +31,11 @@

    Parameters

    • key: (elem: T) => K

      The key function.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If every element is equal, or true if the iterator has one or less elements.

    -
    • average(): T
    • average(): T
    • Returns the average of all elements in the iterator.

      throws

      A RangeError on an empty iterator.

      Returns T

      The average.

      -
    • chunks(chunkSize: number): IterPlus<T[]>
    • chunks(chunkSize: number): IterPlus<T[]>
    • 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.

      @@ -44,7 +44,7 @@

      Parameters

      • chunkSize: number

        The chunk size.

      Returns IterPlus<T[]>

      An iterator that yields the chunks.

      -
    • chunksExact(chunkSize: number): IterPlus<T[]>
    • chunksExact(chunkSize: number): IterPlus<T[]>
    • 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.

      @@ -53,22 +53,22 @@

      Parameters

      • chunkSize: number

        The chunk size.

      Returns IterPlus<T[]>

      An iterator that yields the chunks.

      -
    • collect(): T[]
    • collect(): T[]
    • Collects the items in this iterator into an array.

      Returns T[]

      An array with the items in the iterator.

      -
    • collectWith<R>(collector: (iter: IterPlus<T>) => R): R
    • collectWith<R>(collector: (iter: IterPlus<T>) => R): R
    • Calls a specified collector function with this iterator as its only argument.

      Type parameters

      • R

      Parameters

      Returns R

      The return value of the collector.

      -
    • compare(other: Iterable<T>): number
    • compare(other: Iterable<T>): number
    • Lexicographically compares this iterator with another.

      This function is short-circuiting, so it stops on the first inequality.

      Parameters

      • other: Iterable<T>

        Iterable to compare to.

      Returns number

      -1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

      -
    • compareBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => number): number
    • compareBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => number): number
    • Lexicographically compares this iterator with another using a comparison function.

      This function is short-circuiting, so it stops on the first inequality.

      @@ -80,7 +80,7 @@

      A function that should return a negative for less than, zero for equal to, and positive for greater than.

        • (first: T, second: O): number
        • Parameters

          • first: T
          • second: O

          Returns number

    Returns number

    -1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

    -
    • compareWith<K>(other: Iterable<T>, key: (elem: T) => K): number
    • compareWith<K>(other: Iterable<T>, key: (elem: T) => K): number
    • Lexicographically compares this iterator with another using a key.

      This function is short-circuiting, so it stops on the first inequality.

      @@ -91,58 +91,58 @@
    • key: (elem: T) => K

      Function to generate a key to compare with from an element.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns number

    -1 if this is less than the other, 0 if it's equal, and 1 if it's greater than.

    -
    • concat(...iters: Iterable<T>[]): IterPlus<T>
    • concat(...iters: Iterable<T>[]): IterPlus<T>
    • Concatenates one or more iterables to this iterator, creating an iterator that yields their elements in sequentual order.

      Parameters

      • Rest ...iters: Iterable<T>[]

        The iterables to chain to this one.

      Returns IterPlus<T>

      The generated iterator.

      -
    • construct<R>(ctor: new (item: IterPlus<T>) => R): R
    • construct<R>(ctor: new (item: IterPlus<T>) => R): R
    • Calls a specified constructor with this iterator as its only argument.

      Type parameters

      • R

      Parameters

      • ctor: new (item: IterPlus<T>) => R

        The constructor to use.

      Returns R

      The constructed value.

      -
    • count(): number
    • count(): number
    • Counts the number of items in this iterator.

      Returns number

      The number of items in the iterator.

      -
    • countIf(pred: (elem: T) => boolean): number
    • countIf(pred: (elem: T) => boolean): number
    • Counts the number of items in this iterator that match a predicate.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns number

      The number of matched items in the iterator.

      -
    • Removes elements of an iterator that are equal to the previous one.

      Returns IterPlus<T>

      An iterator with no consecutive duplicates.

      -
    • dedupBy(cmp: (first: T, second: T) => boolean): IterPlus<T>
    • dedupBy(cmp: (first: T, second: T) => boolean): IterPlus<T>
    • Removes elements of an iterator that are equal to the previous one with a comparison function.

      Parameters

      • cmp: (first: T, second: T) => boolean

        A function that checks if elements are equal.

          • (first: T, second: T): boolean
          • Parameters

            • first: T
            • second: T

            Returns boolean

      Returns IterPlus<T>

      An iterator with no consecutive duplicates.

      -
    • dedupWith<K>(key: (elem: T) => K): IterPlus<T>
    • dedupWith<K>(key: (elem: T) => K): IterPlus<T>
    • Removes elements of an iterator that are equal to the previous one with a key.

      Type parameters

      • K

        The type of the key.

      Parameters

      • key: (elem: T) => K

        The key function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns IterPlus<T>

      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.

      Parameters

      • n: number

        The number of elements to drop.

      Returns IterPlus<T>

      An iterator with the specified number of elements removed from the end.

      -
    • equals(other: Iterable<T>): boolean
    • equals(other: Iterable<T>): boolean
    • Checks if this iterator is equal to another.

      This function is short-circuiting, so it stops on the first inequality.

      Parameters

      • other: Iterable<T>

        Iterable to compare to.

      Returns boolean

      If the two iterators are equal.

      -
    • equalsBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • equalsBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • Checks if this iterator is equal to another using a comparison function.

      This function is short-circuiting, so it stops on the first inequality.

      @@ -153,7 +153,7 @@
    • cmp: (first: T, second: O) => boolean

      A function that checks if elements are equal.

        • (first: T, second: O): boolean
        • Parameters

          • first: T
          • second: O

          Returns boolean

    Returns boolean

    If the two iterators are equal.

    -
    • equalsWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • equalsWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • Checks if this iterator is equal to another using a key.

      This function is short-circuiting, so it stops on the first inequality.

      @@ -164,7 +164,7 @@
    • key: (elem: T) => K

      Function to generate a key to compare with from an element.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If the two iterators are equal.

    -
    • every(pred: (elem: T) => boolean): boolean
    • every(pred: (elem: T) => boolean): boolean
    • Checks if every element in the iterator matches a predicate.

      This function is short-circuiting, so if any element returns false, @@ -172,26 +172,26 @@

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns boolean

      If every element satisfies the predicate.

      -
    • filter(pred: (elem: T) => boolean): IterPlus<T>
    • filter(pred: (elem: T) => boolean): IterPlus<T>
    • Generates an iterator that only yields elements that match a predicate.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns IterPlus<T>

      The generated iterator.

      -
    • filterMap<K>(func: (elem: T) => null | K): IterPlus<K>
    • filterMap<K>(func: (elem: T) => null | K): IterPlus<K>
    • Generates a mapped iterator that yields non-null elements.

      Type parameters

      • K

        The resulting type.

      Parameters

      • func: (elem: T) => null | K

        The mapping function.

          • (elem: T): null | K
          • Parameters

            • elem: T

            Returns null | K

      Returns IterPlus<K>

      The generated iterator.

      -
    • find(pred: (elem: T) => boolean): null | T
    • find(pred: (elem: T) => boolean): null | T
    • Finds an element that satisfies a predicate.

      This function is short-circuiting, so it stops on the first match.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns null | T

      The element, or null if none was found.

      -
    • findIndex(pred: (elem: T) => boolean): number
    • findIndex(pred: (elem: T) => boolean): number
    • 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.

      @@ -200,7 +200,7 @@

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns number

      The index, or -1 if none was found.

      -
    • findMap<K>(func: (elem: T) => null | K): null | K
    • findMap<K>(func: (elem: T) => null | K): null | K
    • 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.

      @@ -209,53 +209,53 @@

    Parameters

    • func: (elem: T) => null | K

      The mapping function.

        • (elem: T): null | K
        • Parameters

          • elem: T

          Returns null | K

    Returns null | K

    The element, or null if none was found.

    -
    • flatMap<K>(func: (elem: T) => Iterable<K>): IterPlus<K>
    • flatMap<K>(func: (elem: T) => Iterable<K>): IterPlus<K>
    • Maps then flattens an iterator.

      Type parameters

      • K

        The resulting type.

      Parameters

      • func: (elem: T) => Iterable<K>

        The mapping function.

          • (elem: T): Iterable<K>
          • Parameters

            • elem: T

            Returns Iterable<K>

      Returns IterPlus<K>

      The generated iterator.

      -
    • Flattens an iterator of iterables, yielding an iterator that sequentially produces their elements.

      Type parameters

      • K

        The internal type.

      Returns IterPlus<K>

      The generated iterator.

      -
    • forEach(func: (elem: T) => unknown): void
    • forEach(func: (elem: T) => unknown): void
    • 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.

      Parameters

      • func: (elem: T) => unknown

        The function to run.

        -
          • (elem: T): unknown
          • Parameters

            • elem: T

            Returns unknown

      Returns void

    Returns void

    • Generates an iterator that is guaranteed to never yield a value after finishing.

      Returns IterPlus<T>

      The generated iterator.

      -
    • Globs elements of an iterator together.

      Returns IterPlus<T[]>

      An iterator where every element is an array of consecutively equal elements.

      -
    • globBy(cmp: (first: T, second: T) => boolean): IterPlus<T[]>
    • globBy(cmp: (first: T, second: T) => boolean): IterPlus<T[]>
    • Globs elements of an iterator together, with a comparison function.

      Parameters

      • cmp: (first: T, second: T) => boolean

        A function that checks if elements are equal.

          • (first: T, second: T): boolean
          • Parameters

            • first: T
            • second: T

            Returns boolean

      Returns IterPlus<T[]>

      An iterator where every element is an array of consecutively equal elements.

      -
    • globWith<K>(key: (elem: T) => K): IterPlus<T[]>
    • globWith<K>(key: (elem: T) => K): IterPlus<T[]>
    • Globs elements of an iterator together, with a key function.

      Type parameters

      • K

        The type of the key.

      Parameters

      • key: (elem: T) => K

        The key function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns IterPlus<T[]>

      An iterator where every element is an array of consecutively equal elements.

      -
    • group<K>(key: (elem: T) => K): Record<K, T[]>
    • group<K>(key: (elem: T) => K): Record<K, T[]>
    • Groups elements of an iterator together with a key function.

      Type parameters

      • K: string | number | symbol

        The type of the key.

      Parameters

      • key: (elem: T) => K
          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns Record<K, T[]>

      An object mapping keys to arrays of matching items.

      -
    • hasCached(): boolean
    • hasCached(): boolean
    • Checks if there's a value cached from a previous peek.

      Will return true even if the cached value is the end of the iterator.

      Returns boolean

      If there's a value cached.

      -
    • hasPrefix(other: Iterable<T>): boolean
    • hasPrefix(other: Iterable<T>): boolean
    • Checks if this iterator is equal to another, while the second iterator still yields elements.

      This function is short-circuiting, @@ -263,7 +263,7 @@

      Parameters

      • other: Iterable<T>

        Iterable to compare to.

      Returns boolean

      If the first iterator starts with the second iterator.

      -
    • hasPrefixBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • hasPrefixBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • Checks if this iterator is equal to another, while the second iterator still yields elements, using a comparison function.

      This function is short-circuiting, @@ -275,7 +275,7 @@

    • cmp: (first: T, second: O) => boolean

      A function that checks if elements are equal.

        • (first: T, second: O): boolean
        • Parameters

          • first: T
          • second: O

          Returns boolean

    Returns boolean

    If the first iterator starts with the second iterator.

    -
    • hasPrefixWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • hasPrefixWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • Checks if this iterator is equal to another, while the second iterator still yields elements, with a key function.

      This function is short-circuiting, @@ -287,7 +287,7 @@

    • key: (elem: T) => K

      The key function.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If the first iterator starts with the second iterator.

    -
    • headEquals(other: Iterable<T>): boolean
    • headEquals(other: Iterable<T>): boolean
    • Checks if this iterator is equal to another, while they both yield elements.

      This function is short-circuiting, @@ -297,7 +297,7 @@

      Parameters

      • other: Iterable<T>

        Iterable to compare to.

      Returns boolean

      If the two iterators are equal.

      -
    • headEqualsBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • headEqualsBy<O>(other: Iterable<O>, cmp: (first: T, second: O) => boolean): boolean
    • Checks if this iterator is equal to another, while they both yield elements, using a comparison function.

      This function is short-circuiting, @@ -311,7 +311,7 @@

    • cmp: (first: T, second: O) => boolean

      A function that checks if elements are equal.

        • (first: T, second: O): boolean
        • Parameters

          • first: T
          • second: O

          Returns boolean

    Returns boolean

    If the two iterators are equal.

    -
    • headEqualsWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • headEqualsWith<K>(other: Iterable<T>, key: (elem: T) => K): boolean
    • Checks if this iterator is equal to another, while they both yield elements, using a key.

      This function is short-circuiting, @@ -325,28 +325,28 @@

    • key: (elem: T) => K

      The key function.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If the two iterators are equal.

    -
    • inspect(func: (elem: T) => unknown): IterPlus<T>
    • inspect(func: (elem: T) => unknown): IterPlus<T>
    • 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.

      Parameters

      • func: (elem: T) => unknown

        The function to call.

          • (elem: T): unknown
          • Parameters

            • elem: T

            Returns unknown

      Returns IterPlus<T>

      The generated iterator.

      -
    • interleave(...iters: Iterable<T>[]): IterPlus<T>
    • interleave(...iters: Iterable<T>[]): IterPlus<T>
    • Interleaves one or more iterables with this iterator.

      Parameters

      • Rest ...iters: Iterable<T>[]

        The iterables to interleave with this one.

      Returns IterPlus<T>

      The interleaved iterator, yielding elements in the iterators in order.

      -
    • intersperseMultiple(elems: Iterable<T>): IterPlus<T>
    • intersperseMultiple(elems: Iterable<T>): IterPlus<T>
    • isPartitioned(pred: (elem: T) => boolean): boolean
    • isPartitioned(pred: (elem: T) => boolean): boolean
    • Determines if an iterator is partitioned by a predicate (Items that return true come before items that return false).

      This function is short-circuiting, @@ -354,12 +354,12 @@

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns boolean

      If the iterator is partitioned.

      -
    • isSorted(): boolean
    • isSorted(): boolean
    • Determines if an iterator is sorted increasingly.

      This function is short-circuiting, so it stops on the first non-sorted element.

      Returns boolean

      If the iterator is sorted.

      -
    • isSortedBy(cmp: (first: T, second: T) => number): boolean
    • isSortedBy(cmp: (first: T, second: T) => number): boolean
    • 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.

      @@ -367,7 +367,7 @@

      A function that should return a negative for less than, zero for equal to, and positive for greater than.

        • (first: T, second: T): number
        • Parameters

          • first: T
          • second: T

          Returns number

    Returns boolean

    If the iterator is sorted.

    -
    • isSortedWith<K>(key: (elem: T) => K): boolean
    • isSortedWith<K>(key: (elem: T) => K): boolean
    • Determines if an iterator is sorted increasingly by a key.

      This function is short-circuiting, so it stops on the first non-sorted element.

      @@ -376,24 +376,24 @@

    Parameters

    • key: (elem: T) => K

      The key function.

        • (elem: T): K
        • Parameters

          • elem: T

          Returns K

    Returns boolean

    If the iterator is sorted.

    -
    • Joins an iterator of iterables with an element.

      Type parameters

      • K

        The internal type.

      Parameters

      • elem: K

        The element to join with.

      Returns IterPlus<K>

      The joined iterator.

      -
    • joinMultiple<K>(elems: Iterable<K>): IterPlus<K>
    • joinMultiple<K>(elems: Iterable<K>): IterPlus<K>
    • Joins an iterator of iterables with multiple elements.

      Type parameters

      • K

        The internal type.

      Parameters

      • elems: Iterable<K>

        The elements to intersperse.

      Returns IterPlus<K>

      The joined iterator.

      -
    • last(): null | T
    • last(): null | T
    • Finds the last element in an iterator.

      Returns null | T

      The last element of the iterator, or null if the iterator is empty.

      -
    • map<K>(func: (elem: T) => K): IterPlus<K>
    • map<K>(func: (elem: T) => K): IterPlus<K>
    • 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.

      Type parameters

      • K

        @@ -401,7 +401,7 @@

      Parameters

      • func: (elem: T) => K

        The mapping function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns IterPlus<K>

      The generated iterator.

      -
    • mapAccum<A, V>(func: (accum: A, elem: T) => [A, V], initializer: A): IterPlus<V>
    • mapAccum<A, V>(func: (accum: A, elem: T) => [A, V], initializer: A): IterPlus<V>
    • Runs a function for every element of the iterator, keeping track of an accumulator.

      Type parameters

      • A

        The type of the accumulator.

        @@ -412,20 +412,20 @@
          • (accum: A, elem: T): [A, V]
          • Parameters

            • accum: A
            • elem: T

            Returns [A, V]

      • initializer: A

        The initial accumulator.

      Returns IterPlus<V>

      The mapped iterator.

      -
    • mapWhile<K>(func: (elem: T) => null | K): IterPlus<K>
    • mapWhile<K>(func: (elem: T) => null | K): IterPlus<K>
    • Lazily maps an iterator until it encounters null.

      Type parameters

      • K

        The resulting type.

      Parameters

      • func: (elem: T) => null | K

        The mapping function.

          • (elem: T): null | K
          • Parameters

            • elem: T

            Returns null | K

      Returns IterPlus<K>

      The generated iterator.

      -
    • max(overwrite?: boolean): null | T
    • max(overwrite?: boolean): null | T
    • Finds the maximum value of an iterator.

      Parameters

      • overwrite: boolean = false

        If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

      Returns null | T

      The maximum element, or null if the iterator is empty.

      -
    • maxBy(cmp: (first: T, second: T) => number, overwrite?: boolean): null | T
    • maxBy(cmp: (first: T, second: T) => number, overwrite?: boolean): null | T
    • Finds the maximum value of an iterator with a comparison function.

      Parameters

      • cmp: (first: T, second: T) => number

        A function that should return a negative for less than, zero for equal to, @@ -434,7 +434,7 @@

        If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

      Returns null | T

      The maximum element, or null if the iterator is empty.

      -
    • maxWith<K>(key: (elem: T) => K, overwrite?: boolean): null | T
    • maxWith<K>(key: (elem: T) => K, overwrite?: boolean): null | T
    • Finds the maximum value of an iterator with a key.

      Type parameters

      • K

        The type of the key.

        @@ -444,13 +444,13 @@

        If true, elements will be counted as the new maximum if they are equal to the maximum. Defaults to false.

      Returns null | T

      The maximum element, or null if the iterator is empty.

      -
    • min(overwrite?: boolean): null | T
    • min(overwrite?: boolean): null | T
    • Finds the minimum value of an iterator.

      Parameters

      • overwrite: boolean = false

        If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

      Returns null | T

      The minimum element, or null if the iterator is empty.

      -
    • minBy(cmp: (first: T, second: T) => number, overwrite?: boolean): null | T
    • minBy(cmp: (first: T, second: T) => number, overwrite?: boolean): null | T
    • Finds the minimum value of an iterator with a comparison function.

      Parameters

      • cmp: (first: T, second: T) => number

        A function that should return a negative for less than, zero for equal to, @@ -459,7 +459,7 @@

        If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

      Returns null | T

      The minimum element, or null if the iterator is empty.

      -
    • minWith<K>(key: (elem: T) => K, overwrite?: boolean): null | T
    • minWith<K>(key: (elem: T) => K, overwrite?: boolean): null | T
    • Finds the minimum value of an iterator with a key.

      Type parameters

      • K

        The type of the key.

        @@ -469,34 +469,34 @@

        If true, elements will be counted as the new minimum if they are equal to the minimum. Defaults to false.

      Returns null | T

      The minimum element, or null if the iterator is empty.

      -
    • next(): IteratorResult<T, any>
    • next(): IteratorResult<T, any>
    • Yields the next element in the iterator.

      Returns IteratorResult<T, any>

      The next element.

      -
    • nextVal(): null | T
    • nextVal(): null | T
    • Returns the next value, or null if the iterator ended.

      Returns null | T

      The next value, or null if the iterator ended.

      -
    • nth(n: number): null | T
    • nth(n: number): null | T
    • Finds the nth element in an iterator.

      Parameters

      • n: number

        The number element to get.

      Returns null | T

      The nth element of the iterator, or null if the iterator is too short.

      -
    • nubBy(cmp: (first: T, second: T) => boolean): IterPlus<T>
    • nubBy(cmp: (first: T, second: T) => boolean): IterPlus<T>
    • 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.

      Parameters

      • cmp: (first: T, second: T) => boolean

        A function that checks if elements are equal.

          • (first: T, second: T): boolean
          • Parameters

            • first: T
            • second: T

            Returns boolean

      Returns IterPlus<T>

      The nubbed iterator.

      -
    • nubWith<K>(key: (elem: T) => K): IterPlus<T>
    • nubWith<K>(key: (elem: T) => K): IterPlus<T>
    • Removes duplicates from an iterator, including non-consecutive ones, with a key function.

      Type parameters

      • K

        The type of the key.

      Parameters

      • key: (elem: T) => K

        The key function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns IterPlus<T>

      The nubbed iterator.

      -
    • partition(pred: (elem: T) => boolean): [T[], T[]]
    • partition(pred: (elem: T) => boolean): [T[], T[]]
    • Partitions an iterator into two groups.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

        @@ -505,28 +505,28 @@
      • The elements where the predicate returned true.
      • The elements where the predicate returned false.
      -
    • peek(): IteratorResult<T, any>
    • peek(): IteratorResult<T, any>
    • Peeks the next element in the iterator and does not consume it.

      Returns IteratorResult<T, any>

      The next element as an iterator result.

      -
    • peekVal(): null | T
    • peekVal(): null | T
    • Peeks the next element in the iterator and does not consume it.

      Nullable version of peek.

      Returns null | T

      The next element, or null if the iterator is finished.

      -
    • product(empty?: number): number
    • product(empty: bigint): bigint
    • product(empty?: number): number
    • product(empty: bigint): bigint
    • Returns the product of all elements in the iterator.

      Parameters

      • Optional empty: number

        The default value for an empty iterator. Defaults to 1.

      Returns number

      The product.

      -
    • +
    • Returns the product of all elements in the iterator.

      Parameters

      • empty: bigint

        The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 1n or another bigint.

      Returns bigint

      The product.

      -
    • reduce<A>(func: (accum: A, elem: T) => A, initializer: A): A
    • reduce(func: (accum: T, elem: T) => T): T
    • reduce<A>(func: (accum: A, elem: T) => A, initializer: A): A
    • reduce(func: (accum: T, elem: T) => T): T
    • Runs a function for every element of the iterator, keeping track of an accumulator.

      Type parameters

      • A

        The type of the accumulator.

        @@ -535,7 +535,7 @@
          • (accum: A, elem: T): A
          • Parameters

            • accum: A
            • elem: T

            Returns A

      • initializer: A

        The initial accumulator.

      Returns A

      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.

      @@ -544,18 +544,18 @@

      Parameters

      • func: (accum: T, elem: T) => T

        The reducing function.

          • (accum: T, elem: T): T
          • Parameters

            • accum: T
            • elem: T

            Returns T

      Returns T

      The final accumulator.

      -
    • Creates an iterator that repeats the contents of the current iterator a certain number of times.

      Parameters

      • n: number

        The number of times to repeat.

      Returns IterPlus<T>

      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.

      Returns IterPlus<T>

      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. @@ -564,7 +564,7 @@

      Parameters

      • amount: number

        Amount to rotate by.

      Returns IterPlus<T>

      The rotated iterator.

      -
    • rotateRight(amount: number): IterPlus<T>
    • rotateRight(amount: number): IterPlus<T>
    • 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.

      @@ -574,7 +574,7 @@

      Parameters

      • amount: number

        Amount to rotate by.

      Returns IterPlus<T>

      The rotated iterator.

      -
    • scan<A>(func: (accum: A, elem: T) => A, initializer: A): IterPlus<A>
    • scan(func: (accum: T, elem: T) => T): IterPlus<T>
    • scan<A>(func: (accum: A, elem: T) => A, initializer: A): IterPlus<A>
    • scan(func: (accum: T, elem: T) => T): IterPlus<T>
    • Runs a function for every element of the iterator, keeping track of an accumulator.

      Type parameters

      • A

        The type of the accumulator.

        @@ -583,7 +583,7 @@
          • (accum: A, elem: T): A
          • Parameters

            • accum: A
            • elem: T

            Returns A

      • initializer: A

        The initial accumulator.

      Returns IterPlus<A>

      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.

      @@ -592,17 +592,17 @@

      Parameters

      • func: (accum: T, elem: T) => T

        The reducing function.

          • (accum: T, elem: T): T
          • Parameters

            • accum: T
            • elem: T

            Returns T

      Returns IterPlus<T>

      The iterator containing all intermediate accumulators.

      -
    • Skips the first n elements of an iterator.

      Parameters

      • n: number

        The number of elements to skip.

      Returns IterPlus<T>

      The generated iterator.

      -
    • skipWhile(pred: (elem: T) => boolean): IterPlus<T>
    • skipWhile(pred: (elem: T) => boolean): IterPlus<T>
    • Skips elements of an iterator while a predicate is met.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns IterPlus<T>

      The generated iterator.

      -
    • some(pred: (elem: T) => boolean): boolean
    • some(pred: (elem: T) => boolean): boolean
    • Checks if some element in the iterator matches a predicate.

      This function is short-circuiting, so if any element returns true, @@ -610,12 +610,12 @@

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns boolean

      If some element satisfies the predicate.

      -
    • split(elem: T, limit?: number): IterPlus<T[]>
    • split(elem: T, limit?: number): IterPlus<T[]>
    • Splits an iterator on an element.

      Parameters

      • elem: T
      • limit: number = Infinity

        The maximum number of chunks to make.

      Returns IterPlus<T[]>

      The iterator with the split chunks.

      -
    • splitInclusive(elem: T, limit?: number): IterPlus<T[]>
    • splitInclusive(elem: T, limit?: number): IterPlus<T[]>
    • Splits an iterator on an element, including the matched element as the last element of the chunk.

      Unlike the exclusive split, @@ -623,14 +623,14 @@

      Parameters

      • elem: T
      • limit: number = Infinity

        The maximum number of chunks to make.

      Returns IterPlus<T[]>

      The iterator with the split chunks.

      -
    • splitPred(pred: (elem: T) => boolean, limit?: number): IterPlus<T[]>
    • splitPred(pred: (elem: T) => boolean, limit?: number): IterPlus<T[]>
    • Splits an iterator on a predicate.

      Parameters

      • pred: (elem: T) => boolean

        The predicate to split with.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      • limit: number = Infinity

        The maximum number of chunks to make.

      Returns IterPlus<T[]>

      The iterator with the split chunks.

      -
    • splitPredInclusive(pred: (elem: T) => boolean, limit?: number): IterPlus<T[]>
    • splitPredInclusive(pred: (elem: T) => boolean, limit?: number): IterPlus<T[]>
    • Splits an iterator on a predicate, including the matched element as the last element of the chunk.

      Unlike the exclusive split, @@ -640,7 +640,7 @@

        • (elem: T): boolean
        • Parameters

          • elem: T

          Returns boolean

    • limit: number = Infinity

      The maximum number of chunks to make.

    Returns IterPlus<T[]>

    The iterator with the split chunks.

    -
    • starmap<K, R>(func: (...args: K[]) => R): IterPlus<R>
    • starmap<K, R>(func: (...args: K[]) => R): IterPlus<R>
    • Maps an iterator of iterables, and calls a function with the contents of the iterable as the argument.

      Type parameters

      • K

        @@ -650,50 +650,50 @@

      Parameters

      • func: (...args: K[]) => R

        The mapping function.

          • (...args: K[]): R
          • Parameters

            • Rest ...args: K[]

            Returns R

      Returns IterPlus<R>

      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.

      Parameters

      • step: number

        The step size.

      Returns IterPlus<T>

      An iterator that advances by the given step size.

      -
    • sum(empty?: number): number
    • sum(empty: bigint): bigint
    • sum(empty: string): string
    • sum(empty?: number): number
    • sum(empty: bigint): bigint
    • sum(empty: string): string
    • Returns the sum of all elements in the iterator.

      Parameters

      • Optional empty: number

        The default value for an empty iterator. Defaults to 0.

      Returns number

      The sum.

      -
    • +
    • Returns the sum of all elements in the iterator.

      Parameters

      • empty: bigint

        The default value for an empty iterator. For bigint iterators it's advised to explicitly set this to 0n or another bigint.

      Returns bigint

      The sum.

      -
    • +
    • Returns the sum of all elements in the iterator.

      Parameters

      • empty: string

        The default value for an empty iterator. For string iterators it's advised to explicitly set this to "" or another string.

      Returns string

      The sum.

      -
    • Takes the first n elements of an iterator.

      Parameters

      • n: number

        The number of elements to take.

      Returns IterPlus<T>

      The generated iterator.

      -
    • takeWhile(pred: (elem: T) => boolean): IterPlus<T>
    • takeWhile(pred: (elem: T) => boolean): IterPlus<T>
    • Takes elements of an iterator while a predicate is met.

      Parameters

      • pred: (elem: T) => boolean

        The predicate function.

          • (elem: T): boolean
          • Parameters

            • elem: T

            Returns boolean

      Returns IterPlus<T>

      The generated iterator.

      -
    • tally(): Record<string, number>
    • tally(): Record<string, number>
    • Tallies elements of an iterator together.

      Returns Record<string, number>

      An object mapping keys to the number of times they appeared.

      -
    • tallyWith<K>(key: (elem: T) => K): Record<K, number>
    • tallyWith<K>(key: (elem: T) => K): Record<K, number>
    • Tallies elements of an iterator together with a key function.

      Type parameters

      • K: string | number | symbol

        The type of the key.

      Parameters

      • key: (elem: T) => K

        The key function.

          • (elem: T): K
          • Parameters

            • elem: T

            Returns K

      Returns Record<K, number>

      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.

      @@ -702,10 +702,10 @@

      Parameters

      • count: number = 2

        The number of iterators to split into.

      Returns IterPlus<T>[]

      An array of length count with separate iterators.

      -
    • toArray(): T[]
    • toArray(): T[]
    • toMap<K, V>(duplicate: "overwrite" | "maintain" | "error"): Map<K, V>
    • toMap<K, V>(duplicate: "overwrite" | "maintain" | "error"): Map<K, V>
    • Converts an iterator of key-value pairs into a map.

      throws

      A RangeError if duplicate is "error" and a duplicate key is encountered.

      Type parameters

      • K

        @@ -719,7 +719,7 @@ "error" throws an error. Defaults to "overwrite".

      Returns Map<K, V>

      The generated map.

      -
    • toObject<K, V>(duplicate: "overwrite" | "maintain" | "error"): {}
    • toObject<K, V>(duplicate: "overwrite" | "maintain" | "error"): {}
    • Converts an iterator of key-value pairs into an object.

      throws

      A RangeError if duplicate is "error" and a duplicate key is encountered.

      Type parameters

      • K

        @@ -733,15 +733,15 @@ "error" throws an error. Defaults to "overwrite".

      Returns {}

      The generated object.

      -
      • [key: string]: V
    • toSet(): Set<T>
    • toSet(): Set<T>
    • unzip<K>(): ArrayMap<K>
    • unzip<K>(): ArrayMap<K>
    • "Unzips" an iterator of tuples into a tuple of arrays.

      Type parameters

      • K: unknown[]

        The tuple type.

      Returns ArrayMap<K>

      A tuple with the individual elements.

      -
    • windows(windowSize: number, interval?: number): IterPlus<T[]>
    • windows(windowSize: number, interval?: number): IterPlus<T[]>
    • Returns an iterator yielding overlapping windows of the iterator.

      If there aren't enough elements to fill a window, no windows will be yielded.

      @@ -750,14 +750,14 @@
    • interval: number = 1

      The increment between the starts of windows. Defaults to 1.

    Returns IterPlus<T[]>

    An iterator that yields the windows.

    -
    • zip<K>(...iters: IterableMap<K>): IterPlus<[T, ...K[]]>
    • zip<K>(...iters: IterableMap<K>): IterPlus<[T, ...K[]]>
    • Zips one or more iterables with this iterator.

      Type parameters

      • K: unknown[]

        The types of the other iterables.

      Parameters

      • Rest ...iters: IterableMap<K>

        The iterables to zip with this one.

      Returns IterPlus<[T, ...K[]]>

      The generated iterator.

      -
    • zipWith<K, R>(func: (...args: [T, ...K[]]) => R, ...iters: IterableMap<K>): IterPlus<R>
    • zipWith<K, R>(func: (...args: [T, ...K[]]) => R, ...iters: IterableMap<K>): IterPlus<R>
    • Zips one or more iterables with this iterator using a function.

      Stops once any one of the iterators stop.

      Type parameters

      • K: unknown[]

        @@ -769,7 +769,7 @@
          • (...args: [T, ...K[]]): R
          • Parameters

            • Rest ...args: [T, ...K[]]

            Returns R

      • Rest ...iters: IterableMap<K>

        The iterables to zip with this one.

      Returns IterPlus<R>

      The generated iterator.

      -
    • combinations<T>(data: T[], count?: number): IterPlus<T[]>
    • combinations<T>(data: T[], count?: number): IterPlus<T[]>
    • Generates an iterator that iterates through lexicographically sorted combinations without repetition of a dataset.

      Type parameters

      • T

        The item type of the iterator.

        @@ -778,7 +778,7 @@
      • count: number = data.length

        The number of elements in each combination.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • combinationsWithRepetition<T>(data: T[], count?: number): IterPlus<T[]>
    • combinationsWithRepetition<T>(data: T[], count?: number): IterPlus<T[]>
    • Generates an iterator that iterates through lexicographically sorted combinations with repetition of a dataset.

      Type parameters

      • T

        The item type of the iterator.

        @@ -787,7 +787,7 @@
      • count: number = data.length

        The number of elements in each combination.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • cycle<T>(data: Iterable<T>): IterPlus<T>
    • cycle<T>(data: Iterable<T>): IterPlus<T>
    • Generates an iterator that cycles through an iterable.

      While this does work on infinite iterators, it should be avoided as it stores all elements, @@ -797,33 +797,33 @@

    Parameters

    • data: Iterable<T>

      The iterable to cycle through.

    Returns IterPlus<T>

    The generated iterator.

    -
    • Generates an empty iterator.

      Type parameters

      • T

        The item yielded by the iterator.

      Returns IterPlus<T>

      The generated iterator.

      -
    • fromFunction<T>(func: () => null | T): IterPlus<T>
    • fromFunction<T>(func: () => null | T): IterPlus<T>
    • Generates an iterator that yields values from a function and ends once the function returns null.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • func: () => null | T

        The function to yield values, or null to end the iterator.

          • (): null | T
          • Returns null | T

      Returns IterPlus<T>

      The generated iterator.

      -
    • Generates an iterator that yields a single value.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • val: T

        The value to yield.

      Returns IterPlus<T>

      The generated iterator.

      -
    • Generates an iterator that lazily yields a single value.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • func: () => T

        The function to generate a single value.

          • (): T
          • Returns T

      Returns IterPlus<T>

      The generated iterator.

      -
    • permutations<T>(data: T[], count?: number): IterPlus<T[]>
    • permutations<T>(data: T[], count?: number): IterPlus<T[]>
    • Generates an iterator that iterates through lexicographically sorted permutations without repetition of a dataset.

      Type parameters

      • T

        The item type of the iterator.

        @@ -832,7 +832,7 @@
      • count: number = data.length

        The number of elements in each permutations.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • permutationsWithRepetition<T>(data: T[], count?: number): IterPlus<T[]>
    • permutationsWithRepetition<T>(data: T[], count?: number): IterPlus<T[]>
    • Generates an iterator that iterates through lexicographically sorted permutations with repetition of a dataset.

      Type parameters

      • T

        The item type of the iterator.

        @@ -841,35 +841,35 @@
      • count: number = data.length

        The number of elements in each permutations.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • Generates an iterator that iterates through the lexicographically sorted powerset of a dataset.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • data: T[]

        The data to get the powerset of.

      Returns IterPlus<T[]>

      The generated iterator.

      -
    • product<T>(...data: ArrayMap<T>): IterPlus<T>
    • product<T>(...data: ArrayMap<T>): IterPlus<T>
    • Generates an iterator that generates a lexicographically sorted cartesian product.

      Type parameters

      • T: unknown[]

        The item type of the iterator.

      Parameters

      • Rest ...data: ArrayMap<T>

        The iterators to take the product of.

      Returns IterPlus<T>

      The generated iterator.

      -
    • Generates an iterator that endlessly repeats a value.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • val: T

        The value to yield.

      Returns IterPlus<T>

      The generated iterator.

      -
    • repeatWith<T>(func: () => T): IterPlus<T>
    • repeatWith<T>(func: () => T): IterPlus<T>
    • Generates an iterator that endlessly calls a function.

      Type parameters

      • T

        The item type of the iterator.

      Parameters

      • func: () => T

        The function to generate values.

          • (): T
          • Returns T

      Returns IterPlus<T>

      The generated iterator.

      -
    • successors<T>(first: null | T, func: (prev: T) => null | T): IterPlus<T>
    • successors<T>(first: null | T, func: (prev: T) => null | T): IterPlus<T>
    • Generates an iterator that generates values based on the previous value.

      Type parameters

      • T

        The item type of the iterator.

        @@ -878,4 +878,4 @@
      • func: (prev: T) => null | T

        The function to generate new values.

          • (prev: T): null | T
          • Parameters

            • prev: T

            Returns null | T

      Returns IterPlus<T>

      The generated iterator.

      -
    • unfold<T, A>(func: (accum: A) => null | [T, A], init: A): IterPlus<T>
    • Type parameters

      • T

      • A

      Parameters

      • func: (accum: A) => null | [T, A]
          • (accum: A): null | [T, A]
          • Parameters

            • accum: A

            Returns null | [T, A]

      • init: A

      Returns IterPlus<T>

    Legend

    • Private property
    • Private method
    • Method
    • Inherited method
    • Protected property

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/modules.html b/docs/modules.html index 17f858e..91a4406 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1,17 +1,17 @@ -iterplus - v3.0.2
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    iterplus - v3.0.2

    Index

    Type aliases

    Null: typeof nullVal
    +iterplus - v3.0.2
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    iterplus - v3.0.2

    Index

    Type aliases

    Null: typeof nullVal

    The type of null to use.

    -
    PromiseOrValue<T>: T | Promise<T>
    +
    PromiseOrValue<T>: T | Promise<T>

    A promise or a value that can be awaited.

    -

    Type parameters

    • T

    Variables

    nullVal: null = null
    +

    Type parameters

    • T

    Variables

    nullVal: null = null

    The value of null to use.

    Defaults to null.

    -

    Functions

    Functions

    • Generates an AsyncIterPlus from an async iterable.

      Type parameters

      • T

        The iteration type.

      Parameters

      • iter: AsyncIterable<T>

        The async iterable to upgrade.

        -

      Returns AsyncIterPlus<T>

    • asyncify<A, R>(func: (...args: A) => R): (...args: A) => Promise<R>

    Returns AsyncIterPlus<T>

    • asyncify<A, R>(func: (...args: A) => R): (...args: A) => Promise<R>
    • Lifts an function to an async function that immediately resolves the return value.

      Type parameters

      • A: unknown[]

        The arguments of the function.

        @@ -23,52 +23,52 @@
          • (...args: A): Promise<R>
          • Lifts an function to an async function that immediately resolves the return value.

            Parameters

            • Rest ...args: A

            Returns Promise<R>

            The lifted function.

            -
    • canAsyncIter(obj: any): obj is AsyncIterable<unknown>
    • canAsyncIter(obj: any): obj is AsyncIterable<unknown>
    • Tests if an object is iterable.

      Parameters

      • obj: any

        The object to test for.

      Returns obj is AsyncIterable<unknown>

      If obj is an iterable.

      -
    • canIter(obj: any): obj is Iterable<unknown>
    • canIter(obj: any): obj is Iterable<unknown>
    • Tests if an object is iterable.

      Parameters

      • obj: any

        The object to test for.

      Returns obj is Iterable<unknown>

      If obj is an iterable.

      -
    • count(start: bigint, step?: bigint): IterPlus<bigint>
    • count(start: number, step?: number): IterPlus<number>
    • count(start: bigint, step?: bigint): IterPlus<bigint>
    • count(start: number, step?: number): IterPlus<number>
    • Creates an iterator that keeps adding values to a starting point.

      Parameters

      • start: bigint

        The starting point.

      • Optional step: bigint

        The step.

        -

      Returns IterPlus<bigint>

    • +

    Returns IterPlus<bigint>

  • Creates an iterator that keeps adding values to a starting point.

    Parameters

    • start: number

      The starting point.

    • Optional step: number

      The step.

      -

    Returns IterPlus<number>

    • isAsyncIter(obj: any): obj is AsyncIterator<unknown, any, undefined>

    Returns IterPlus<number>

    • isAsyncIter(obj: any): obj is AsyncIterator<unknown, any, undefined>
    • Tests if an object is an iterator.

      Parameters

      • obj: any

        The object to test for.

      Returns obj is AsyncIterator<unknown, any, undefined>

      If obj is an iterator.

      -
    • isIter(obj: any): obj is Iterator<unknown, any, undefined>
    • isIter(obj: any): obj is Iterator<unknown, any, undefined>
    • Tests if an object is an iterator.

      Parameters

      • obj: any

        The object to test for.

      Returns obj is Iterator<unknown, any, undefined>

      If obj is an iterator.

      -
    • iterplus<T>(iter: Iterable<T>): IterPlus<T>
    • iterplus<T>(iter: Iterable<T>): IterPlus<T>
    • Generates an IterPlus from an iterable.

      Type parameters

      • T

        The iteration type.

      Parameters

      • iter: Iterable<T>

        The iterable to upgrade.

        -

      Returns IterPlus<T>

    Returns IterPlus<T>

    • Lifts an iterable to an async iterable that immediately resolves promises.

      Type parameters

      • T

        The item of the iterator.

      Parameters

      • iterable: Iterable<T>

        The iterable to lift.

      Returns AsyncIterPlus<T>

      The lifted iterator.

      -
    • range(start: bigint, dest?: bigint, step?: bigint): IterPlus<bigint>
    • range(start: number, dest?: number, step?: number): IterPlus<number>
    • range(start: bigint, dest?: bigint, step?: bigint): IterPlus<bigint>
    • range(start: number, dest?: number, step?: number): IterPlus<number>
    • Creates an inclusive-exclusive range iterator that's useful for loops.

      Parameters

      • start: bigint

        The starting point.

        @@ -76,7 +76,7 @@

        The ending point, exclusive.

      • Optional step: bigint

        The step, can be negative to go down.

        -

      Returns IterPlus<bigint>

    • +

    Returns IterPlus<bigint>

  • Creates an inclusive-exclusive range iterator that's useful for loops.

    Parameters

    • start: number

      The starting point.