Options
All
  • Public
  • Public/Protected
  • All
Menu

Module array/adjust

Index

References

Functions

References

Renames and re-exports adjust

Functions

  • adjust<T>(fn: Endo1<T>, index: number, list: ArrayLike<T>): T[]
  • adjust<T>(fn: Endo1<T>, index: number): (list: ArrayLike<T>) => T[]
  • adjust<T>(fn: Endo1<T>): CurriedFunction2<number, ArrayLike<T>, T[]>
  • Applies a function to the value at the given index of an array, returning a new copy of the array with the element at the given index replaced with the result of the function application.

    example
     adjust(add(10), 1, [1, 2, 3]);     //=> [1, 12, 3]
    adjust(add(10))(1)([1, 2, 3]); //=> [1, 12, 3]

    Type parameters

    • T

    Parameters

    • fn: Endo1<T>

      The function to apply.

    • index: number
    • list: ArrayLike<T>

      An array whose value at the supplied index will be replaced.

    Returns T[]

    A copy of the supplied array with the element at index idx replaced with the value returned by applying fn to the existing element.

  • Applies a function to the value at the given index of an array, returning a new copy of the array with the element at the given index replaced with the result of the function application.

    example
     adjust(add(10), 1, [1, 2, 3]);     //=> [1, 12, 3]
    adjust(add(10))(1)([1, 2, 3]); //=> [1, 12, 3]

    Type parameters

    • T

    Parameters

    • fn: Endo1<T>

      The function to apply.

    • index: number

    Returns (list: ArrayLike<T>) => T[]

    A copy of the supplied array with the element at index idx replaced with the value returned by applying fn to the existing element.

      • (list: ArrayLike<T>): T[]
      • Parameters

        • list: ArrayLike<T>

        Returns T[]

  • Applies a function to the value at the given index of an array, returning a new copy of the array with the element at the given index replaced with the result of the function application.

    example
     adjust(add(10), 1, [1, 2, 3]);     //=> [1, 12, 3]
    adjust(add(10))(1)([1, 2, 3]); //=> [1, 12, 3]

    Type parameters

    • T

    Parameters

    • fn: Endo1<T>

      The function to apply.

    Returns CurriedFunction2<number, ArrayLike<T>, T[]>

    A copy of the supplied array with the element at index idx replaced with the value returned by applying fn to the existing element.

Generated using TypeDoc