Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GeneratorOps<S>

Type parameters

Hierarchy

  • GeneratorOps

Index

Methods

asArray

  • asArray<T>(gen: Genable<T, S>): ReturnValue<T[], S>

concat

  • Concatenates generators (or iterators or iterables).

    Ensures that any supplied generators are terminated when this is terminated.

    Type parameters

    Parameters

    • Rest ...gens: T

      zero or more additional Genable to provide values.

    Returns Enhanced<GenUnion<T>, S>

enhance

every

  • every<T>(p: IndexedPredicate<T, S>, thisArg?: any): (gen: Genable<T, S>) => ReturnValue<boolean, S>
  • every<T>(p: IndexedPredicate<T, S>): (gen: Genable<T, S>, thisArg?: any) => ReturnValue<boolean, S>
  • every<T>(p: IndexedPredicate<T, S>, gen: Genable<T, S>): ReturnValue<boolean, S>
  • every<T>(p: IndexedPredicate<T, S>, thisArg: any, gen: Genable<T, S>): ReturnValue<boolean, S>
  • every<T>(pred: IndexedPredicate<T, S>, genOrThis?: any | Genable<T, S>, gen?: Genable<T, S>): ReturnValue<boolean, S> | ((gen: Genable<T, S>) => ReturnValue<boolean, S>)
  • Returns false and terminates the generator if the predicate is false for any of the generator's yielded values.

    If the generator terminates without having failed the predicate, true is returned.

    Type parameters

    • T

    Parameters

    • p: IndexedPredicate<T, S>

      predicate to apply to each yielded value.

    • Optional thisArg: any

      Optional value to supply as context (this) for the predicate

    Returns (gen: Genable<T, S>) => ReturnValue<boolean, S>

      • (gen: Genable<T, S>): ReturnValue<boolean, S>
      • Parameters

        Returns ReturnValue<boolean, S>

  • Returns false and terminates this generator if the predicate is false for any of the generator's yielded values.

    If the generator terminates without having failed the predicate, true is returned.

    Type parameters

    • T

    Parameters

    • p: IndexedPredicate<T, S>

      predicate to apply to each yielded value.

    Returns (gen: Genable<T, S>, thisArg?: any) => ReturnValue<boolean, S>

      • (gen: Genable<T, S>, thisArg?: any): ReturnValue<boolean, S>
      • Parameters

        • gen: Genable<T, S>
        • Optional thisArg: any

        Returns ReturnValue<boolean, S>

  • Returns false and terminates this generator if the predicate is false for any of the generator's yielded values.

    If the generator terminates without having failed the predicate, true is returned.

    Type parameters

    • T

    Parameters

    • p: IndexedPredicate<T, S>

      predicate to apply to each yielded value.

    • gen: Genable<T, S>

      the generator

    Returns ReturnValue<boolean, S>

  • Returns false and terminates this generator if the predicate is false for any of the generator's yielded values.

    If the generator terminates without having failed the predicate, true is returned.

    Type parameters

    • T

    Parameters

    • p: IndexedPredicate<T, S>

      predicate to apply to each yielded value.

    • thisArg: any

      Optional value to supply as context (this) for the predicate

    • gen: Genable<T, S>

      the generator

    Returns ReturnValue<boolean, S>

  • Type parameters

    • T

    Parameters

    • pred: IndexedPredicate<T, S>
    • Optional genOrThis: any | Genable<T, S>
    • Optional gen: Genable<T, S>

    Returns ReturnValue<boolean, S> | ((gen: Genable<T, S>) => ReturnValue<boolean, S>)

filter

  • filter<T>(f: IndexedPredicate<T, S>): GenOpValue<S, T, [any], Enhanced<T, S>>
  • filter<T>(f: IndexedPredicate<T, S>, thisArg: any): GenOpValue<S, T, [], Enhanced<T, S>>
  • filter<T>(f: IndexedPredicate<T, S>, iter: Genable<T, S>): Enhanced<T, S>
  • filter<T>(f: IndexedPredicate<T, S>, thisArg: any, iter: Genable<T, S>): Enhanced<T, S>
  • filter<T>(f: IndexedPredicate<T, S>, thisArg?: any, iter?: Genable<T, S>): Enhanced<T, S>
  • Return a functionthat filters a Genable and yields a new EnhancedGenerator that yields only the values that satisfy the predicate f.

    f receives the value and a sequential index.

    Type parameters

    • T

      the type of value.

    Parameters

    • f: IndexedPredicate<T, S>

    Returns GenOpValue<S, T, [any], Enhanced<T, S>>

  • Return a functionthat filters a Genable and yields a new EnhancedGenerator that yields only the values that satisfy the predicate f.

    f receives the value and a sequential index.

    Type parameters

    • T

      the type of value.

    Parameters

    • f: IndexedPredicate<T, S>
    • thisArg: any

      Optional context to be passed as this to the predicate.

    Returns GenOpValue<S, T, [], Enhanced<T, S>>

  • Return a new EnhancedGenerator that yields only the values that satisfy the predicate f.

    f receives the value and a sequential index.

    Type parameters

    • T

      the type of value.

    Parameters

    Returns Enhanced<T, S>

  • Return a new EnhancedGenerator that yields only the values that satisfy the predicate f.

    f receives the value and a sequential index.

    Type parameters

    • T

      the type of value.

    Parameters

    • f: IndexedPredicate<T, S>
    • thisArg: any

      Optional context to be passed as this to the predicate.

    • iter: Genable<T, S>

    Returns Enhanced<T, S>

  • Type parameters

    • T

    Parameters

    • f: IndexedPredicate<T, S>
    • Optional thisArg: any
    • Optional iter: Genable<T, S>

    Returns Enhanced<T, S>

flat

  • Flatten the values yielded by the generator to level depth. Produces a generator that yields the individual values at each level in depth-first order. Any iterable (including Array) or iterator will be traversed and its values yielded.

    The return type is currently over-broad

    Type parameters

    • T

    • D: number

    Parameters

    • depth: D

    Returns <X>(gen: Genable<X, S>) => Enhanced<FlatGen<X, D>, S>

  • Flatten the values yielded by the generator to level depth. Produces a generator that yields the individual values at each level in depth-first order. Any iterable (including Array) or iterator will be traversed and its values yielded.

    The return type is currently over-broad

    Type parameters

    • T

    • D: number

    Parameters

    Returns Enhanced<FlatGen<T, D>, S>

  • Flatten the values yielded by the generator to level depth. Produces a generator that yields the individual values at each level in depth-first order. Any iterable (including Array) or iterator will be traversed and its values yielded.

    The return type is currently over-broad

    Type parameters

    • T

    • D: number

    Parameters

    • gen: Genable<T, S>
    • Optional depth: D

      default = 1

    Returns Enhanced<FlatGen<T, D>, S>

  • Type parameters

    • T

    • D: number

    Parameters

    Returns Enhanced<FlatGen<T, D>, S> | (<X>(gen: Genable<X, S>) => Enhanced<S, FlatGen<X, D>>) | (<X>(gen: Genable<X, S>, thisObj: any) => Enhanced<S, FlatGen<X, D>>)

flatMap

  • flatMap<T, D, R>(f: IndexedFn<T, R, S>, depth: D): (gen: Genable<T, S>) => Enhanced<FlatGen<R, D>, S>
  • flatMap<T, D, R>(f: IndexedFn<T, R, S>): (gen: Genable<T, S>, depth?: D) => Enhanced<FlatGen<R, D>, S>
  • flatMap<T, D, R>(f: IndexedFn<T, R, S>, gen: Genable<T, S>): Enhanced<FlatGen<R, D>, S>
  • flatMap<T, D, R>(f: IndexedFn<T, R, S>, depth: D, gen: Genable<T, S>): Enhanced<FlatGen<R, D>, S>
  • flatMap<T, D, R>(f: IndexedFn<T, R, S>, depthOrGen?: D | Genable<T, S>, gen?: Genable<T, S>): Enhanced<FlatGen<R, D>, S> | (<X, Y>(gen: Genable<X, S>) => Enhanced<Y, S>) | (<X, Y>(gen: Genable<X, S>, depth?: D) => Enhanced<Y, S>)
  • Flatten the values yielded by applying the function to the values yielded by the generator to level depth. Produces a function that accepts a generator, and returns another generator that yields the individual value at each level in depth-first order. Any iterable (including Array) or iterator will be traversed and its values yielded.

    The return type is currently over-broad

    Type parameters

    • T

    • D: number

    • R

    Parameters

    • f: IndexedFn<T, R, S>
    • depth: D

    Returns (gen: Genable<T, S>) => Enhanced<FlatGen<R, D>, S>

  • Flatten the values yielded by applying the function to the values yielded by the generator to level depth. Produces a function that accepts a generator, and returns another generator that yields the individual value at each level in depth-first order. Any iterable (including Array) or iterator will be traversed and its values yielded.

    The return type is currently over-broad

    Type parameters

    • T

    • D: number

    • R

    Parameters

    • f: IndexedFn<T, R, S>

    Returns (gen: Genable<T, S>, depth?: D) => Enhanced<FlatGen<R, D>, S>

  • Flatten the values yielded by applying the function to the values yielded by the generator to level depth. Produces a generator that yields the individual values at each level in depth-first order. Any iterable (including Array) or iterator will be traversed and its values yielded.

    The return type is currently over-broad

    Type parameters

    • T

    • D: number

    • R

    Parameters

    • f: IndexedFn<T, R, S>
    • gen: Genable<T, S>

    Returns Enhanced<FlatGen<R, D>, S>

  • Flatten the values yielded by applying the function to the values yielded by the generator to level depth. Produces a generator that yields the individual values at each level in depth-first order. Any iterable (including Array) or iterator will be traversed and its values yielded.

    The return type is currently over-broad

    Type parameters

    • T

    • D: number

    • R

    Parameters

    • f: IndexedFn<T, R, S>
    • depth: D
    • gen: Genable<T, S>

    Returns Enhanced<FlatGen<R, D>, S>

  • Type parameters

    • T

    • D: number

    • R

    Parameters

    • f: IndexedFn<T, R, S>
    • Optional depthOrGen: D | Genable<T, S>
    • Optional gen: Genable<T, S>

    Returns Enhanced<FlatGen<R, D>, S> | (<X, Y>(gen: Genable<X, S>) => Enhanced<Y, S>) | (<X, Y>(gen: Genable<X, S>, depth?: D) => Enhanced<Y, S>)

forEach

  • forEach<T>(f: IndexedFn<T, void, S>, thisArg: any, gen: Genable<T, S>): GenVoid<S>
  • forEach<T>(f: IndexedFn<T, void, S>, gen: Genable<T, S>): GenVoid<S>
  • forEach<T>(f: IndexedFn<T, void, S>, thisArg?: any): (gen: Genable<T, S>) => GenVoid<S>
  • forEach<T>(f: IndexedFn<T, void, S>): (gen: Genable<T, S>, thisArg?: any) => GenVoid<S>
  • Operate on each value produced by the generator. f is called with two values, the value yielded by this generator and a sequential index.

    Type parameters

    • T

      the type of value produced by the generator.

    Parameters

    • f: IndexedFn<T, void, S>
    • thisArg: any

      Optional value to be supplied as context this for function f.

    • gen: Genable<T, S>

      the generator.

    Returns GenVoid<S>

  • Operate on each value produced by the generator. f is called with two values, the value yielded by this generator and a sequential index.

    Type parameters

    • T

      the type of value produced by the generator.

    Parameters

    • f: IndexedFn<T, void, S>
    • gen: Genable<T, S>

      the generator.

    Returns GenVoid<S>

  • Operate on each value produced by the generator. f is called with two values, the value yielded by this generator and a sequential index.

    Type parameters

    • T

      the type of value produced by the generator.

    Parameters

    • f: IndexedFn<T, void, S>
    • Optional thisArg: any

      Optional value to be supplied as context this for function f.

    Returns (gen: Genable<T, S>) => GenVoid<S>

      • Parameters

        Returns GenVoid<S>

  • Operate on each value produced by the generator. f is called with two values, the value yielded by this generator and a sequential index.

    Type parameters

    • T

      the type of value produced by the generator.

    Parameters

    • f: IndexedFn<T, void, S>

    Returns (gen: Genable<T, S>, thisArg?: any) => GenVoid<S>

      • (gen: Genable<T, S>, thisArg?: any): GenVoid<S>
      • Parameters

        • gen: Genable<T, S>
        • Optional thisArg: any

        Returns GenVoid<S>

join

  • join(sep: string): <T>(gen: Genable<T, S>) => ReturnValue<string, S>
  • join<T>(gen: Genable<T, S>, sep?: undefined | string): ReturnValue<string, S>
  • join<T>(genOrSeparator: Genable<T, S> | string, sep?: undefined | string): ReturnValue<string, S> | (<X>(gen: Genable<X>) => ReturnValue<string, S>)
  • Returns a function that joins the elements produced by a Genable, analogous to Array.prototype.join.

    Parameters

    • sep: string

      (default = ',')

    Returns <T>(gen: Genable<T, S>) => ReturnValue<string, S>

      • <T>(gen: Genable<T, S>): ReturnValue<string, S>
      • Type parameters

        • T

        Parameters

        Returns ReturnValue<string, S>

  • Joins the elements produced by a Genable, analogous to Array.prototype.join.

    Type parameters

    • T

    Parameters

    • gen: Genable<T, S>
    • Optional sep: undefined | string

    Returns ReturnValue<string, S>

  • Type parameters

    • T

    Parameters

    • genOrSeparator: Genable<T, S> | string
    • Optional sep: undefined | string

    Returns ReturnValue<string, S> | (<X>(gen: Genable<X>) => ReturnValue<string, S>)

limit

  • limit<T>(max: number, gen: Genable<T, S>): Enhanced<T, S>
  • limit(max: number): GenOp<S>

map

  • map<T, V>(f: IndexedFn<T, V, S>): GenOpValue<S, T, [any], Enhanced<V, S>>
  • map<T, V>(f: IndexedFn<T, V, S>, thisArg?: any): GenOpValue<S, T, [], Enhanced<V, S>>
  • map<T, V>(f: IndexedFn<T, V, S>, gen: Genable<T, S>): Enhanced<V, S>
  • map<T, V>(f: IndexedFn<T, V, S>, thisArg: any, gen: Genable<T, S>): Enhanced<V, S>
  • Accepts a function from T to V, and returns a function that adapts aGenerator(or any [Genable|Genable\\<T>]) to an enhancedGenerator. Each yielded value V is the result of applying the functionfto to a value yielded by theGenerator`.

    In the async case, f may also return Promise<T>.

    Type parameters

    • T

      the type of value yielded by the supplied generator.

    • V

      the type of value yielded by the resulting generator.

    Parameters

    • f: IndexedFn<T, V, S>

      a function from V to T

    Returns GenOpValue<S, T, [any], Enhanced<V, S>>

  • Accepts a function from T to V, and returns a function that adapts aGenerator(or any [Genable|Genable\\<T>]) to an enhancedGenerator. Each yielded value V is the result of applying the functionfto to a value yielded by theGenerator`.

    In the async case, f may also return Promise<T>.

    Type parameters

    • T

      the type of value produced by the generator.

    • V

      the type of value yielded by the resulting generator.

    Parameters

    • f: IndexedFn<T, V, S>
    • Optional thisArg: any

      supplied as 'this' for each invocation of f.

    Returns GenOpValue<S, T, [], Enhanced<V, S>>

  • Accepts a function from T to V, and aGenerator(or any [Genable|Genable\\<T>]) and returns an enhancedGenerator`.

    Each yielded value V is the result of applying the function f to to a value yielded by the Generator<T>.

    In the async case, f may also return Promise<T>.

    Type parameters

    • T

      the type of value produced by the generator.

    • V

      the type of value yielded by the resulting generator.

    Parameters

    • f: IndexedFn<T, V, S>
    • gen: Genable<T, S>

      the Genable whose yielded values we are mapping over.

    Returns Enhanced<V, S>

  • Accepts a function from T to V, and aGenerator(or any [Genable|Genable\\<T>]) and returns an enhancedGenerator`.

    Each yielded value V is the result of applying the function f to to a value yielded by the Generator<T>.

    In the async case, f may also return Promise<T>.

    Type parameters

    • T

      the type of value produced by the generator.

    • V

      the type of value yielded by the resulting generator.

    Parameters

    • f: IndexedFn<T, V, S>
    • thisArg: any

      supplied as 'this' for each invocation of f.

    • gen: Genable<T, S>

      the Genable whose yielded values we are mapping over.

    Returns Enhanced<V, S>

of

  • Return a generator that provides the supplied values.

    Type parameters

    • T

    Parameters

    • Rest ...values: T[]

    Returns Enhanced<T, S>

reduce

  • reduce<A, T>(f: Reducer<A, T, T, S>, gen: Genable<T, S>): ReturnValue<A, S>
  • reduce<A, T>(f: Reducer<A, T, T, S>): (gen: Genable<T, S>) => ReturnValue<A, S>
  • reduce<A, T>(f: Reducer<A, T, A, S>): (init: A, gen: Genable<T, S>) => ReturnValue<A, S>
  • reduce<A, T>(f: Reducer<A, T, A, S>, init: A, gen: Genable<T, S>): ReturnValue<A, S>
  • reduce<A, T>(f: Reducer<A, T, A>, init: A): (gen: Genable<T, S>) => ReturnValue<A, S>
  • reduce<A, T>(f: Reducer<A, T, A | T, S>, initOrGen?: Value<A, S> | Genable<T, S>, gen?: Genable<T, S>): Value<A, S> | ((gen: Genable<T, S>) => Value<A, S>) | ((f: (acc: A, v: T) => Value<A, S>, init: A) => Value<A, S>) | ((f: (acc: A | T, v: T) => Value<A, S>) => Value<A, S>)
  • Reduces gen like Array.prototype.reduce, but the 3rd argument to the reducing function ("array") is omitted because there is no array.

    Type parameters

    • A

    • T

    Parameters

    Returns ReturnValue<A, S>

  • Returns a reducer function that, when applied to a Generator gen, reduces gen like Array.prototype.reduce. The 3rd argument to the reducing function ("array") is omitted because there is no array.

    Type parameters

    • A

    • T

    Parameters

    Returns (gen: Genable<T, S>) => ReturnValue<A, S>

      • (gen: Genable<T, S>): ReturnValue<A, S>
      • Parameters

        Returns ReturnValue<A, S>

  • Returns a reducer function that, when applied to a Generator gen, reduces gen like Array.prototype.reduce. The 3rd argument to the reducing function ("array") is omitted because there is no array.

    Type parameters

    • A

    • T

    Parameters

    Returns (init: A, gen: Genable<T, S>) => ReturnValue<A, S>

      • (init: A, gen: Genable<T, S>): ReturnValue<A, S>
      • Parameters

        Returns ReturnValue<A, S>

  • Reduces gen like Array.prototype.reduce, but the 3rd argument to the reducing function ("array") is omitted because there is no array.

    Type parameters

    • A

    • T

    Parameters

    Returns ReturnValue<A, S>

  • Returns a reducer function that, when applied to a Generator gen, reduces gen like Array.prototype.reduce. The 3rd argument to the reducing function ("array") is omitted because there is no array.

    Alternatively, the init value can be supplied along with the generator as a second argument.

    Type parameters

    • A

    • T

    Parameters

    Returns (gen: Genable<T, S>) => ReturnValue<A, S>

      • (gen: Genable<T, S>): ReturnValue<A, S>
      • Parameters

        Returns ReturnValue<A, S>

  • Type parameters

    • A

    • T

    Parameters

    Returns Value<A, S> | ((gen: Genable<T, S>) => Value<A, S>) | ((f: (acc: A, v: T) => Value<A, S>, init: A) => Value<A, S>) | ((f: (acc: A | T, v: T) => Value<A, S>) => Value<A, S>)

repeat

  • repeat<T>(value: T, repetitions: number): Enhanced<T, S>
  • Returns a new generator that repeats the supplied value.

    Type parameters

    • T

    Parameters

    • value: T

      the value to repeat

    • repetitions: number

      The number repetitions; the default is infinite.

    Returns Enhanced<T, S>

repeatLast

  • repeatLast<T>(gen: Genable<T, S>, max: number): Enhanced<T | undefined, S>
  • Returns a new generator that repeats the last value returned by gen (or undefined if gen did not return any values).

    Type parameters

    • T

    Parameters

    Returns Enhanced<T | undefined, S>

slice

some

  • some<T>(p: IndexedPredicate<T, S>, thisArg?: any): (gen: Genable<T, S>) => ReturnValue<boolean, S>
  • some<T>(p: IndexedPredicate<T, S>): (gen: Genable<T, S>, thisArg?: any) => ReturnValue<boolean, S>
  • some<T>(p: IndexedPredicate<T, S>, gen: Genable<T, S>): ReturnValue<boolean, S>
  • some<T>(p: IndexedPredicate<T, S>, thisArg: any, gen: Genable<T, S>): ReturnValue<boolean, S>
  • some<T>(pred: IndexedPredicate<T, S>, thisOrGen?: any | Genable<T, S>, gen?: Genable<T, S>): ReturnValue<boolean, S> | ((gen: Genable<T, S>) => ReturnValue<boolean, S>)
  • Returns true and terminates the generator if the predicate is true for any of the generator's yielded values.

    If the generator terminates without having satisfied the predicate, false is returned.

    Type parameters

    • T

    Parameters

    • p: IndexedPredicate<T, S>

      predicate to apply to each yielded value.

    • Optional thisArg: any

      Optional value to supply as context (this) for the predicate

    Returns (gen: Genable<T, S>) => ReturnValue<boolean, S>

      • (gen: Genable<T, S>): ReturnValue<boolean, S>
      • Parameters

        Returns ReturnValue<boolean, S>

  • Returns true and terminates the generator if the predicate is true for any of the generator's yielded values.

    If the generator terminates without having satisfied the predicate, false is returned.

    Type parameters

    • T

    Parameters

    • p: IndexedPredicate<T, S>

      predicate to apply to each yielded value.

    Returns (gen: Genable<T, S>, thisArg?: any) => ReturnValue<boolean, S>

      • (gen: Genable<T, S>, thisArg?: any): ReturnValue<boolean, S>
      • Parameters

        • gen: Genable<T, S>
        • Optional thisArg: any

        Returns ReturnValue<boolean, S>

  • Returns true and terminates the generator if the predicate is true for any of the generator's yielded values.

    If the generator terminates without having satisfied the predicate, false is returned.

    Type parameters

    • T

    Parameters

    • p: IndexedPredicate<T, S>

      predicate to apply to each yielded value.

    • gen: Genable<T, S>

      the generator

    Returns ReturnValue<boolean, S>

  • Returns true and terminates the generator if the predicate is true for any of the generator's yielded values.

    If the generator terminates without having satisfied the predicate, false is returned.

    Type parameters

    • T

    Parameters

    • p: IndexedPredicate<T, S>

      predicate to apply to each yielded value.

    • thisArg: any

      Optional value to supply as context (this) for the predicate

    • gen: Genable<T, S>

      the generator

    Returns ReturnValue<boolean, S>

  • Type parameters

    • T

    Parameters

    • pred: IndexedPredicate<T, S>
    • Optional thisOrGen: any | Genable<T, S>
    • Optional gen: Genable<T, S>

    Returns ReturnValue<boolean, S> | ((gen: Genable<T, S>) => ReturnValue<boolean, S>)

zip

  • zip<G>(...gens: G): Enhanced<UnwrapGen<S, G>, S>

Generated using TypeDoc