Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ArrayMethods<T>

Methods added to Array and ReadonlyArray interfaces

Type parameters

  • T: Iterable<any>

Hierarchy

  • ArrayMethods

Index

Methods

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

    Type parameters

    • S: any

      Type of all filtered values

    Parameters

    • callback: FilterCallback<T, S>

      Filter callback

    • Optional thisArg: any

      Optional argument. Binds this for the callback

    Returns Generator<S, void, unknown>

  • Parameters

    Returns Generator<IterType<T>, void, unknown>

  • factoryFlat<D>(depth?: D): Generator<FlatArray<IterType<T>[], D>, void, unknown>
  • factoryFlatMap<U>(callback: MapCallback<T, U>, thisArg?: any): Generator<U extends readonly InnerArr[] ? InnerArr : U, void, unknown>
  • 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

    • U

      Mapped type

    Parameters

    • callback: MapCallback<T, U>

      flatMap callback

    • Optional thisArg: any

      Optional argument. Binds this for callback

    Returns Generator<U extends readonly InnerArr[] ? InnerArr : U, void, unknown>

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

    Type parameters

    • U

      Mapped type

    Parameters

    • callback: MapCallback<T, U>

      Map callback

    • Optional thisArg: any

      Optional argument. Binds this for the callback

    Returns Generator<U, void, unknown>

Generated using TypeDoc