doddle
    Preparing search index...

    Class Seq<T>Abstract

    The Seq class, which wraps a synchronous iterable.

    Type Parameters

    • T

    Implements

    Index

    Properties

    flatMap: <S>(
        projection: (
            element: T,
            index: number,
        ) =>
            | object & Iterable<S>
            | object & Iterator<S, any, undefined>
            | object & ArrayLike<S>
            | Doddle<ObjectIterable<S>>
            | Seq.FunctionInput<S>
            | Doddle<Seq.Input<S>>,
    ) => Seq<Get_Concat_Element_Type<T, S>> = ...

    Type declaration

      • <S>(
            projection: (
                element: T,
                index: number,
            ) =>
                | object & Iterable<S>
                | object & Iterator<S, any, undefined>
                | object & ArrayLike<S>
                | Doddle<ObjectIterable<S>>
                | Seq.FunctionInput<S>
                | Doddle<Seq.Input<S>>,
        ): Seq<Get_Concat_Element_Type<T, S>>
      • Applies a sequence projection on each element of this sequence and concatenates the resulting sequences.

        Type Parameters

        • S

        Parameters

        Returns Seq<Get_Concat_Element_Type<T, S>>

        A new sequence with the flattened results.

    Methods

    • Calls a side-effect function after all elements have been yielded, but before iteration finishes.

      ⚠️ If the client stops iterating early, the action won't be executed.

      Parameters

      • action: () => unknown

        A function to invoke after iteration completes.

      Returns Seq<T>

      A new sequence that acts like this but invokes action before it's finished.

    • Reinterprets the declared element type of this as another, arbitrary type.

      ℹ️ This is only useful in TypeScript and has no runtime effects.

      Type Parameters

      • S

        The new element type.

      Returns Seq<S>

      The same sequence, but with a different declared type.

    • 🦥Lazily gets the element at the given index in this sequence, or undefined if the index is out of bounds.

      ℹ️ Negative indexes count from the end of the sequence.
      ⚠️ Requires iterating over the sequence up to the given index.

      Parameters

      • index: number

        The index of the item to retrieve.

      Returns Doddle<undefined | T>

      A 🦥Doddle that resolves to the item at the given index.

    • Executes a side effect action once before any elements are yielded, but after iteration has begun.

      Parameters

      • action: () => unknown

        Invokes before any elements are yielded.

      Returns Seq<T>

      A new async sequence that performs action before yielding elements.

    • Caches the elements of this sequence as they're iterated over, so that it's evaluated only once.

      Returns Seq<T>

      A new sequence with the same elements as the original sequence.

    • Handles errors thrown while iterating over this sequence.

      Type Parameters

      • S = T

      Parameters

      • handler: (
            element: unknown,
            index: number,
        ) =>
            | void
            | object & Iterable<S>
            | object & Iterator<S, any, undefined>
            | object & ArrayLike<S>
            | Doddle<ObjectIterable<S>>
            | Seq.FunctionInput<S>
            | Doddle<void | Seq.Input<S>>

        A handler that will be called with the error and the index of the element that caused it. Should return a new sequence or undefined, which stops iteration.

      Returns Seq<T | S>

      A new sequence that handles errors.

    • Splits this sequence into chunks of the given size, optionally applying a projection to each chunk.

      ℹ️ The last chunk may be smaller than the given size.

      Type Parameters

      • L extends number
      • S = getWindowOutputType<T, L>

      Parameters

      • size: L

        The size of each chunk.

      • Optionalprojection: (...window: getWindowArgsType<T, L>) => S | Doddle<S>

        Optionally, an N-ary projection to apply to each chunk. Defaults to collecting the elements into an array.

      Returns Seq<S>

      A new sequence.

    • Returns a new sequence. When iterated, before yielding its first element, it will iterate over all the elements of this and store them in memory. Then it will yield all of them one by one.

      ℹ️ Used to control side-effects. Makes sure all side-effects execute before continuing to apply other operators.

      Returns Seq<T>

      A new sequence with the same elements as this one, but where iteration has already completed.

    • Concatenates one or more sequences to the end of this, so that their elements appear in order.

      Type Parameters

      Parameters

      • ...inputs: Seqs

        The sequential inputs to concatenate to the end of this.

      Returns Seq<T | {}>

      A new sequence with the concatenated elements.

    • Applies a sequence projection on each element of this sequence and concatenates the resulting sequences.

      Type Parameters

      • S

      Parameters

      Returns Seq<Get_Concat_Element_Type<T, S>>

      A new sequence with the flattened results.

    • Concatenates this sequence to the end of one or more other sequences.

      ℹ️ Input sequences are concatenated in the order that they appear.

      Type Parameters

      Parameters

      • ...inputs: Seqs

        One or more other sequences.

      Returns Seq<T | {}>

      A new sequence with the concatenated elements.

    • 🦥Lazily counts the number of elements in this sequence.

      ⚠️ Requires iterating over the entire sequence.

      Returns Doddle<number>

      A 🦥Doddle that resolves to the number of elements in this.

    • 🦥Lazily counts the number of elements in this sequence that match the given predicate.

      ⚠️ Requires iterating over the entire sequence.

      Parameters

      • predicate: (element: T, index: number) => false | true | Doddle<boolean>

        The predicate used to test each element.

      Returns Doddle<number>

      A 🦥Doddle that resolves to the number of matching elements.

    • Calls an action function as each element in this is iterated over. Calls the function before or after yielding the element, or both.

      Parameters

      • action: (element: T, index: number, stage: "before" | "after") => void

        The action function to invoke for each element.

      • stage: undefined | "before" | "after" | "both" = ...

        The stage at which to invoke the function. Can be "before", "after", or "both".

      Returns Seq<T>

      A new sequence that invokes the action function while being iterated.

    • 🦥Lazily checks if all elements in this sequence match the given predicate.

      ⚠️ May iterate over the entire sequence.

      Parameters

      • predicate: (element: T, index: number) => false | true | Doddle<boolean>

        The predicate.

      Returns Doddle<boolean>

      A 🦥Doddle that yields true if all elements match, or false otherwise.

    • Filters the elements of this sequence based on the given type predicate, narrowing the type of the elements in the resulting sequence.

      Type Parameters

      • S

      Parameters

      • predicate: (element: T, index: number) => element is S

        The predicate to filter elements.

      Returns Seq<S>

      A new sequence with the filtered elements, its type narrowed based on the predicate.

    • Filters the elements of this sequence based on the given predicate.

      Parameters

      • predicate: (element: T, index: number) => false | true | Doddle<boolean>

        The predicate to filter elements.

      Returns Seq<T>

      A new sequence with the filtered elements.

    • 🦥Lazily finds the first element in this sequence, or undefined if it's empty.

      Returns Doddle<undefined | T>

      A 🦥Doddle that resolves to the first element or the alternative value.

    • 🦥Lazily finds the first element in this sequence that matches the given predicate.

      ⚠️ May iterate over the entire sequence.

      Type Parameters

      • const Alt = undefined

      Parameters

      • predicate: (element: T, index: number) => false | true | Doddle<boolean>

        The predicate used to find the element.

      • Optionalalt: Alt

        The value to return if no element matches the predicate. Defaults to undefined.

      Returns Doddle<T | Alt>

    • Groups the elements of this sequence by key, resulting in a sequence of pairs where the first element is the key and the second is a sequence of values.

      Type Parameters

      • K

      Parameters

      • keyProjection: (element: T) => K | Doddle<K>

        The projection used to determine the key for each element.

      Returns Seq<
          {
              "[unscopables]": {
                  "[iterator]"?: boolean;
                  "[unscopables]"?: boolean;
                  at?: boolean;
                  concat?: boolean;
                  entries?: boolean;
                  every?: boolean;
                  filter?: boolean;
                  find?: boolean;
                  findIndex?: boolean;
                  flat?: boolean;
                  flatMap?: boolean;
                  forEach?: boolean;
                  includes?: boolean;
                  indexOf?: boolean;
                  join?: boolean;
                  keys?: boolean;
                  lastIndexOf?: boolean;
                  length?: boolean;
                  map?: boolean;
                  reduce?: boolean;
                  reduceRight?: boolean;
                  slice?: boolean;
                  some?: boolean;
                  toLocaleString?: boolean;
                  toString?: boolean;
                  values?: boolean;
                  readonly [key: number]: undefined
                  | boolean;
              };
              "0": K;
              "1": Seq<T>;
              length: 2;
              "[iterator]"(): IterableIterator<Seq<T> | K>;
              at(index: number): undefined | Seq<T> | K;
              concat(...items: ConcatArray<Seq<T> | K>[]): (Seq<T> | K)[];
              concat(...items: (Seq<T> | K | ConcatArray<Seq<T> | K>)[]): (Seq<T> | K)[];
              entries(): IterableIterator<[number, Seq<T> | K]>;
              every<S>(
                  predicate: (
                      value: Seq<T> | K,
                      index: number,
                      array: readonly (Seq<T> | K)[],
                  ) => value is S,
                  thisArg?: any,
              ): this is readonly S[];
              every(
                  predicate: (
                      value: Seq<T> | K,
                      index: number,
                      array: readonly (Seq<T> | K)[],
                  ) => unknown,
                  thisArg?: any,
              ): boolean;
              filter<S>(
                  predicate: (
                      value: Seq<T> | K,
                      index: number,
                      array: readonly (Seq<T> | K)[],
                  ) => value is S,
                  thisArg?: any,
              ): S[];
              filter(
                  predicate: (
                      value: Seq<T> | K,
                      index: number,
                      array: readonly (Seq<T> | K)[],
                  ) => unknown,
                  thisArg?: any,
              ): (Seq<T> | K)[];
              find<S>(
                  predicate: (
                      value: Seq<T> | K,
                      index: number,
                      obj: readonly (Seq<T> | K)[],
                  ) => value is S,
                  thisArg?: any,
              ): undefined | S;
              find(
                  predicate: (
                      value: Seq<T> | K,
                      index: number,
                      obj: readonly (Seq<T> | K)[],
                  ) => unknown,
                  thisArg?: any,
              ): undefined | Seq<T> | K;
              findIndex(
                  predicate: (
                      value: Seq<T> | K,
                      index: number,
                      obj: readonly (Seq<T> | K)[],
                  ) => unknown,
                  thisArg?: any,
              ): number;
              flat<A, D extends number = 1>(this: A, depth?: D): FlatArray<A, D>[];
              flatMap<U, This = undefined>(
                  callback: (
                      this: This,
                      value: Seq<T> | K,
                      index: number,
                      array: (Seq<T> | K)[],
                  ) => U | readonly U[],
                  thisArg?: This,
              ): U[];
              forEach(
                  callbackfn: (
                      value: Seq<T> | K,
                      index: number,
                      array: readonly (Seq<T> | K)[],
                  ) => void,
                  thisArg?: any,
              ): void;
              includes(searchElement: Seq<T> | K, fromIndex?: number): boolean;
              indexOf(searchElement: Seq<T> | K, fromIndex?: number): number;
              join(separator?: string): string;
              keys(): IterableIterator<number>;
              lastIndexOf(searchElement: Seq<T> | K, fromIndex?: number): number;
              map<U>(
                  callbackfn: (
                      value: Seq<T> | K,
                      index: number,
                      array: readonly (Seq<T> | K)[],
                  ) => U,
                  thisArg?: any,
              ): U[];
              reduce(
                  callbackfn: (
                      previousValue: Seq<T> | K,
                      currentValue: Seq<T> | K,
                      currentIndex: number,
                      array: readonly (Seq<T> | K)[],
                  ) => Seq<T> | K,
              ): Seq<T> | K;
              reduce(
                  callbackfn: (
                      previousValue: Seq<T> | K,
                      currentValue: Seq<T> | K,
                      currentIndex: number,
                      array: readonly (Seq<T> | K)[],
                  ) => Seq<T> | K,
                  initialValue: Seq<T> | K,
              ): Seq<T> | K;
              reduce<U>(
                  callbackfn: (
                      previousValue: U,
                      currentValue: Seq<T> | K,
                      currentIndex: number,
                      array: readonly (Seq<T> | K)[],
                  ) => U,
                  initialValue: U,
              ): U;
              reduceRight(
                  callbackfn: (
                      previousValue: Seq<T> | K,
                      currentValue: Seq<T> | K,
                      currentIndex: number,
                      array: readonly (Seq<T> | K)[],
                  ) => Seq<T> | K,
              ): Seq<T> | K;
              reduceRight(
                  callbackfn: (
                      previousValue: Seq<T> | K,
                      currentValue: Seq<T> | K,
                      currentIndex: number,
                      array: readonly (Seq<T> | K)[],
                  ) => Seq<T> | K,
                  initialValue: Seq<T> | K,
              ): Seq<T> | K;
              reduceRight<U>(
                  callbackfn: (
                      previousValue: U,
                      currentValue: Seq<T> | K,
                      currentIndex: number,
                      array: readonly (Seq<T> | K)[],
                  ) => U,
                  initialValue: U,
              ): U;
              slice(start?: number, end?: number): (Seq<T> | K)[];
              some(
                  predicate: (
                      value: Seq<T> | K,
                      index: number,
                      array: readonly (Seq<T> | K)[],
                  ) => unknown,
                  thisArg?: any,
              ): boolean;
              toLocaleString(): string;
              toLocaleString(
                  locales: string | string[],
                  options?: NumberFormatOptions & DateTimeFormatOptions,
              ): string;
              toString(): string;
              values(): IterableIterator<Seq<T> | K>;
          },
      >

      A sequence of pairs.

    • 🦥Lazily checks if this sequence includes one or more values by iterating over it.

      ⚠️ May iterate over the entire sequence.

      Type Parameters

      • T
      • S

      Parameters

      • this: Seq<T>
      • ...values: S[]

        The values to check for inclusion.

      Returns Doddle<boolean>

    • 🦥Lazily checks if this sequence includes one or more values.

      ⚠️ May iterate over the entire sequence.

      Type Parameters

      • S

      Parameters

      • ...value: S[]

      Returns Doddle<boolean>

    • 🦥Lazily joins the elements of this sequence into a single string, separated by the given separator.

      ⚠️ Requires iterating over the entire sequence.

      Parameters

      • separator: string = ","

        The string to use as a separator between elements.

      Returns Doddle<string>

      A 🦥Doddle that resolves to the joined string.

    • 🦥Lazily gets the last element in this sequence, or undefined.

      Returns Doddle<undefined | T>

      A 🦥Doddle that resolves to the last element in this sequence, or undefined.

    • 🦥Lazily finds the last element in this sequence that matches the given predicate.

      ⚠️ Requires iterating over the entire sequence.

      Type Parameters

      • const Alt = undefined

      Parameters

      • predicate: (element: T, index: number) => false | true | Doddle<boolean>

        The predicate for testing each element.

      • Optionalalt: Alt

        Optionally, the value to return if no matching value is found. Defaults to undefined.

      Returns Doddle<T | Alt>

      A 🦥Doddle that resolves to the last matching element or the alternative value.

    • Applies a projection to each element of this sequence.

      Type Parameters

      • S

      Parameters

      • projection: (element: T, index: number) => S | Doddle<S>

        The projection to apply to each element.

      Returns Seq<S>

      A new sequence with the projected elements.

    • 🦥Lazily finds the maximum element in this sequence by key, or the given alternative value if the sequence is empty.

      Type Parameters

      • K
      • const Alt = undefined

      Parameters

      • projection: (element: T, index: number) => K | Doddle<K>

        Projects each element into a key so it can be compared.

      • Optionalalt: Alt

        The value to return if the sequence is empty. Defaults to undefined.

      Returns Doddle<T | Alt>

    • 🦥Lazily finds the minimum element in this sequence by key, or the given alternative value if the sequence is empty.

      Type Parameters

      • K
      • const Alt = undefined

      Parameters

      • projection: (element: T, index: number) => K | Doddle<K>

        Projects each element into a key so it can be compared.

      • Optionalalt: Alt

        The value to return if the sequence is empty. Defaults to undefined.

      Returns Doddle<T | Alt>

      A 🦥Doddle that resolves to the element with the minimum key, or alt if the sequence is empty.

    • Orders the elements of this sequence by key, using the given key projection.

      ⚠️ Has to iterate over the entire sequence.

      Type Parameters

      • K

      Parameters

      • projection: (element: T) => K | Doddle<K>

        A projection that returns a key to order by.

      • Optionaldescending: boolean

        Whether to use descending order.

      Returns Seq<T>

      A new sequence with the elements ordered by the given key.

    • Orders the elements of this using the given mutli-key tuple projection.

      ℹ️ The keys are compared in the order they appear.
      ⚠️ Has to iterate over the entire sequence.

      Type Parameters

      • K extends [unknown, ...unknown[]]

      Parameters

      • projection: (element: T) => K | Doddle<K>

        A projection function that returns a tuple of keys to order by.

      • Optionaldescending: boolean

        Whether to use descending order.

      Returns Seq<T>

      A new sequence with the elements ordered by the given keys.

    • Returns a cartesian product of this sequence with one or more other sequences, optionally applying an N-ary projection to each combination of elements.

      The product of N sequences is the collection of all possible sets of elements from each sequence.

      For example, the product of [1, 2] and [3, 4] is:

      ;[
      [1, 3],
      [1, 4],
      [2, 3],
      [2, 4]
      ]

      Type Parameters

      • Xs extends any[]
      • R = [T, ...Xs[]]

      Parameters

      • _others: { [K in string | number | symbol]: Seq.Input<Xs[K<K>]> }
      • Optionalprojection: (...args: [T, ...Xs[]]) => R

        Optionally, an N-ary projection to apply to each combination of elements. If not given, each combination is yielded as an array.

      Returns Seq<R>

      A new sequence.

      seq([1, 2]).product([3, 4])
      // => [[1, 3], [1, 4], [2, 3], [2, 4]]
      seq([]).product([3, 4])
      // => []
      seq([1, 2]).product([3, 4], (a, b) => a + b)
      // => [4, 5, 5, 6]
    • 🦥Lazily reduces this sequence to a single value by applying the given reduction.

      ℹ️ Uses the first element as the initial value.

      Parameters

      • reduction: (acc: T, element: T, index: number) => T | Doddle<T>

        The reduction function to apply to each element.

      Returns Doddle<T>

      A 🦥Doddle that resolves to the reduced value.

    • 🦥Lazily reduces this sequence to a single value by applying the given reduction.

      ℹ️ You need to supply an initial value.

      Type Parameters

      • Acc

      Parameters

      • reducer: (acc: Acc, element: T, index: number) => Acc | Doddle<Acc>

        The reduction to apply to each element.

      • initial: Acc

        The initial value to start the reduction with.

      Returns Doddle<Acc>

    • Reverses this sequence.

      ⚠️ Requires iterating over the entire sequence.

      Returns Seq<T>

      A new sequence with the elements in reverse order.

    • Applies a reduction to each element of this sequence. Returns a new sequence that yields the accumulated value at each step.

      ℹ️ The first element is used as the initial value.

      Parameters

      • reduction: (acc: T, element: T, index: number) => T | Doddle<T>

        The reduction function to apply.

      Returns Seq<T>

      A new sequence with the accumulated values.

      If this is empty.

    • Applies a reduction to each element of this sequence. Returns a new sequence that yields the accumulated value at each step.

      ℹ️ You need to supply an initial value.

      Type Parameters

      • Acc

      Parameters

      • reduction: (acc: Acc, element: T, index: number) => Acc | Doddle<Acc>

        The reduction to apply.

      • initial: Acc

        The initial value to start the reduction with.

      Returns Seq<Acc>

    • 🦥Lazily checks if this sequence is equal to the input sequence.

      ℹ️ For two sequences to be equal, their elements must be equal and be in the same order.

      Type Parameters

      • T
      • S

      Parameters

      • this: Seq<T>
      • input: Seq.Input<S>

        The sequence-like input to compare with.

      Returns Doddle<boolean>

      A 🦥Doddle that resolves to true if all elements are equal, or false

    • 🦥Lazily checks if this sequence is equal to the input sequence.

      ℹ️ For two sequences to be equal, their elements must be equal and be in the same order.

      Type Parameters

      • S

      Parameters

      • input: Seq.Input<S>

        The sequence-like input to compare with.

      Returns Doddle<boolean>

      A 🦥Doddle that resolves to true if all elements are equal, or false

    • 🦥Lazily checks if this sequence is equal to the input sequence.

      ℹ️ For two sequences to be equal, their elements must be equal and be in the same order.

      Type Parameters

      • K
      • S = T

      Parameters

      • input: Seq.Input<S>

        The sequence-like input to compare with.

      • projection: (element: T | S) => K | Doddle<K>

        The projection function that determines the key for comparison.

      Returns Doddle<boolean>

      A 🦥Doddle that resolves to true if all elements are equal, or false

    • 🦥Lazily checks if this sequence contains the same elements as the input sequence, without regard to order.

      ⚠️ Requires iterating over the entire sequence.

      Type Parameters

      • T
      • S

      Parameters

      • this: Seq<T>
      • input: Seq.Input<S>

        The sequence-like input to compare with.

      Returns Doddle<boolean>

      A 🦥Doddle that resolves to true if this is set-equal to the input, or false otherwise.

    • 🦥Lazily checks if this sequence contains the same elements as the input sequence, without regard to order.

      ⚠️ Requires iterating over the entire sequence.

      Type Parameters

      • S

      Parameters

      • input: Seq.Input<S>

        The sequence-like input to compare with.

      Returns Doddle<boolean>

      A 🦥Doddle that resolves to true if this is set-equal to the input, or false otherwise.

    • 🦥Lazily checks if this sequence contains the same elements as the input sequence, without regard to order.

      ℹ️ The elements are compared by key, using the given key projection.

      Type Parameters

      • K
      • S = T

      Parameters

      • input: Seq.Input<S>

        The sequence-like input to compare with.

      • projection: (element: T | S) => K | Doddle<K>

        The projection function that determines the key for comparison.

      Returns Doddle<boolean>

      A 🦥Doddle that resolves to true if this is set-equal to the input, or false otherwise.

    • Returns a new sequence that shares its iterator state. This allows different loops to iterate over it, sharing progress.

      ⚠️ Can be iterated over exactly once, and will be empty afterwards.

      Returns Seq<T>

      A new, shared iterable sequence that can be iterated over exactly once.

    • Shuffles the elements of this sequence randomly.

      ⚠️ Requires iterating over the entire sequence.

      Returns Seq<T>

      A new sequence with the shuffled elements.

    • Skips the first count elements of this sequence, yielding the rest.

      ℹ️ If count is negative, skips the final elements instead (e.g. skipLast)

      Parameters

      • count: number

        The number of elements to skip.

      Returns Seq<T>

      A new sequence without the skipped elements.

    • Skips elements from this sequence while the given predicate is true, and yields the rest.

      ℹ️ You can use the options argument to skip the first element that returns false.

      Parameters

      • predicate: (element: T, index: number) => false | true | Doddle<boolean>

        The predicate to determine whether to continue skipping.

      • Optionaloptions: { skipFinal?: boolean }

        Options for skipping behavior.

        • OptionalskipFinal?: boolean

          Whether to skip the boundary element for which the predicate returns false.

      Returns Seq<T>

      A new sequence without the skipped elements.

    • 🦥Lazily checks if any element in this sequence matches the given predicate, by iterating over it until a match is found.

      Parameters

      • predicate: (element: T, index: number) => false | true | Doddle<boolean>

        The predicate to match the element.

      Returns Doddle<boolean>

      A 🦥Doddle that resolves to true if any element matches, or false otherwise.

    • 🦥Lazily sums the elements of this sequence by iterating over it, applying the given projection to each element.

      Parameters

      • projection: (element: T, index: number) => number | Doddle<number>

        The projection function to apply to each element.

      Returns Doddle<number>

      A 🦥Doddle that resolves to the sum of the projected elements.

    • Yields the first count elements of this sequence.

      ℹ️ If count is negative, yields the last -count elements instead.
      ℹ️ If the sequence is smaller than count, it yields all elements.

      Parameters

      • count: number

        The number of elements to yield.

      Returns Seq<T>

      A new sequence with the yielded elements.

    • Yields the first elements of this sequence while the given predicate is true and skips the rest.

      ℹ️ If the sequence is too small, the result will be empty.
      ℹ️ The options argument lets you keep the first element for which the predicate returns false.

      Parameters

      • predicate: (element: T, index: number) => false | true | Doddle<boolean>

        The predicate to determine whether to continue yielding.

      • Optionaloptions: { takeFinal?: boolean }

        Extra options.

      Returns Seq<T>

      A new sequence with the yielded elements.

    • 🦥Lazily converts this sequence into a Map.

      ⚠️ Has to iterate over the entire sequence.

      Type Parameters

      • K
      • V

      Parameters

      • kvpProjection: (element: T, index: number) => readonly [K, V] | Doddle<readonly [K, V]>

        A function that takes an element and returns a key-value pair.

      Returns Doddle<Map<K, V>>

      A 🦥Doddle that resolves to a Map of the elements in the sequence.

    • 🦥Lazily converts this sequence into a plain JS object. Uses the given kvpProjection to determine each key-value pair.

      Type Parameters

      • const Key extends PropertyKey
      • Value

      Parameters

      • kvpProjection: (
            element: T,
            index: number,
        ) => readonly [Key, Value] | Doddle<readonly [Key, Value]>

        A function that takes an element and returns a key-value pair. Each key must be a valid PropertyKey.

      Returns Doddle<{ [k in PropertyKey]: Value }>

      A 🦥Doddle that resolves to a plain JS object.

    • Filters out duplicate elements from this sequence, optionally using a key projection.

      ℹ️ Doesn't need to iterate over the entire sequence.
      ⚠️ Needs to cache the sequence as it's iterated over.

      Parameters

      • keyProjection: (element: T) => any = ...

        A function that takes an element and returns a key used to check for uniqueness.

      Returns Seq<T>

      A sequence of unique elements.

    • Splits this async sequence into overlapping windows of fixed size, applying a projection to each window.

      ℹ️ If the sequence is smaller than the window size, one smaller window will yielded.

      Type Parameters

      • L extends number
      • S

      Parameters

      • size: L

        The size of each window.

      • projection: (...window: getWindowArgsType<T, L>) => S | Doddle<S>

        A function to project each window to a value.

      Returns Seq<S>

      A new sequence of windows or projected results.

    • Splits this async sequence into overlapping windows of fixed size.

      ℹ️ If the sequence is smaller than the window size, one smaller window will yielded.

      Type Parameters

      • L extends number

      Parameters

      • size: L

        The size of each window.

      Returns Seq<getWindowOutputType<T, L>>

      A new sequence of windows.

    • Zips this sequence with other sequences, yielding tuples of elements that appear in the same position in each sequence.

      ℹ️ Sequences that are exhausted will yield undefined for their elements.
      ℹ️ The resulting sequence will be as long as the longest input sequence.

      Type Parameters

      • Xs extends [any, ...any[]]

      Parameters

      • others: { [K in string | number | symbol]: Seq.Input<Xs[K<K>]> }

        An array of other sequence inputs to zip with.

      Returns Seq<[undefined | neverToUndefined<T>, ...getZipValuesType<Xs>[]]>

      A new async sequence of tuples containing parallel elements.

    • Zips this sequence with other sequences, applying a projection to each set of elements and yielding the results.

      ℹ️ Sequences that are exhausted will yield undefined for their elements.
      ℹ️ The resulting sequence will be as long as the longest input sequence.

      Type Parameters

      • Xs extends [any, ...any[]]
      • R

      Parameters

      • others: { [K in string | number | symbol]: Seq.Input<Xs[K<K>]> }

        An array of other sequence inputs to zip with.

      • projection: (...args: [undefined | neverToUndefined<T>, ...getZipValuesType<Xs>[]]) => R

      Returns Seq<R>

      A new sequence of elements generated from the zipped values.