Options
All
  • Public
  • Public/Protected
  • All
Menu

array-factory

Index

Type aliases

FilterCallback<T, S>: S extends IterType<T> ? (value: IterType<T>, index: number, array: T) => value is S : (value: IterType<T>, index: number, array: T) => unknown

Callback for Array.filter

Type parameters

  • T: Iterable<any>

    Array type

  • S = unknown

    Type of all filtered values

MapCallback<T, U>: (value: IterType<T>, index: number, array: T) => U

Type parameters

  • T: Iterable<any>

    Array type

  • U

    Mapped type

Type declaration

    • (value: IterType<T>, index: number, array: T): U
    • Callback for Array.map

      Parameters

      • value: IterType<T>
      • index: number
      • array: T

      Returns U

Functions

  • factoryFilter<T, S>(array: T, callback: FilterCallback<T, S>, thisArg?: any): Generator<S extends unknown ? IterType<T> : S, void>
  • example
    const myArray = [1, 2, 3]
    // Only even numbers
    for (const item of myArray.factoryFilter(el => !(el % 2))) {
    console.log(item)
    }

    Type parameters

    • T: Iterable<any, T>

      Array type

    • S = unknown

      Type of all filtered values

    Parameters

    • array: T

      The array

    • callback: FilterCallback<T, S>

      Filter callback

    • Optional thisArg: any

      Optional argument. Binds this for the callback

    Returns Generator<S extends unknown ? IterType<T> : S, void>

  • factoryFlat<T, D>(array: T, depth?: D): Generator<FlatArray<IterType<T>[], D>, void>
  • factoryFlatMap<T, U>(array: T, callback: MapCallback<T, U>, thisArg?: any): Generator<FlatArray<U[], 1>, void>
  • example
    const myArray = [1, 2, 3]
    for (const item of myArray.factoryFlatMap(el => [el, el * 2])) {
    console.log(item)
    }
    // 1, 2, 2, 4, 3, 6

    Type parameters

    • T: Iterable<any, T>

      Array type

    • U

      Mapped type

    Parameters

    • array: T

      The array

    • callback: MapCallback<T, U>

      flatMap callback

    • Optional thisArg: any

      Optional argument. Binds this for callback

    Returns Generator<FlatArray<U[], 1>, void>

  • factoryMap<T, U>(array: T, callback: MapCallback<T, U>, thisArg?: any): Generator<U, void>
  • example
    const myArray = [1, 2, 3]
    for (const item of myArray.factoryMap(el => el * 2)) {
    console.log(item)
    }

    Type parameters

    • T: Iterable<any, T>

      Array type

    • U

      Mapped type

    Parameters

    • array: T

      The array

    • callback: MapCallback<T, U>

      Map callback

    • Optional thisArg: any

      Optional argument. Binds this for the callback

    Returns Generator<U, void>

Generated using TypeDoc