Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "updater"

Index

Functions

defUpdater

  • defUpdater<T>(path: Path0, fn: UpdateFn<T, T>): FnO<T, T>
  • defUpdater<T, A>(path: Path1<T, A>, fn: UpdateFn<OptPathVal<T, [A]>, PathVal<T, [A]>>): FnO<T, T>
  • defUpdater<T, A, B>(path: Path2<T, A, B>, fn: UpdateFn<OptPathVal<T, [A, B]>, PathVal<T, [A, B]>>): FnO<T, T>
  • defUpdater<T, A, B, C>(path: Path3<T, A, B, C>, fn: UpdateFn<OptPathVal<T, [A, B, C]>, PathVal<T, [A, B, C]>>): FnO<T, T>
  • defUpdater<T, A, B, C, D>(path: Path4<T, A, B, C, D>, fn: UpdateFn<OptPathVal<T, [A, B, C, D]>, PathVal<T, [A, B, C, D]>>): FnO<T, T>
  • defUpdater<T, A, B, C, D, E>(path: Path5<T, A, B, C, D, E>, fn: UpdateFn<OptPathVal<T, [A, B, C, D, E]>, PathVal<T, [A, B, C, D, E]>>): FnO<T, T>
  • defUpdater<T, A, B, C, D, E, F>(path: Path6<T, A, B, C, D, E, F>, fn: UpdateFn<OptPathVal<T, [A, B, C, D, E, F]>, PathVal<T, [A, B, C, D, E, F]>>): FnO<T, T>
  • defUpdater<T, A, B, C, D, E, F, G>(path: Path7<T, A, B, C, D, E, F, G>, fn: UpdateFn<OptPathVal<T, [A, B, C, D, E, F, G]>, PathVal<T, [A, B, C, D, E, F, G]>>): FnO<T, T>
  • defUpdater<T, A, B, C, D, E, F, G, H>(path: Path8<T, A, B, C, D, E, F, G, H>, fn: UpdateFn<OptPathVal<T, [A, B, C, D, E, F, G, H]>, PathVal<T, [A, B, C, D, E, F, G, H]>>): FnO<T, T>
  • defUpdater<T, A, B, C, D, E, F, G, H>(path: DeepPath<T, A, B, C, D, E, F, G, H>, fn: UpdateFn<any, any>): FnO<T, T>
  • Type checked version of defUpdaterUnsafe. Only the first 8 path levels are type checked.

    Type parameters

    • T

    Parameters

    Returns FnO<T, T>

  • Type parameters

    • T

    • A

    Parameters

    • path: Path1<T, A>
    • fn: UpdateFn<OptPathVal<T, [A]>, PathVal<T, [A]>>

    Returns FnO<T, T>

  • Type parameters

    • T

    • A

    • B

    Parameters

    • path: Path2<T, A, B>
    • fn: UpdateFn<OptPathVal<T, [A, B]>, PathVal<T, [A, B]>>

    Returns FnO<T, T>

  • Type parameters

    • T

    • A

    • B

    • C

    Parameters

    • path: Path3<T, A, B, C>
    • fn: UpdateFn<OptPathVal<T, [A, B, C]>, PathVal<T, [A, B, C]>>

    Returns FnO<T, T>

  • Type parameters

    • T

    • A

    • B

    • C

    • D

    Parameters

    • path: Path4<T, A, B, C, D>
    • fn: UpdateFn<OptPathVal<T, [A, B, C, D]>, PathVal<T, [A, B, C, D]>>

    Returns FnO<T, T>

  • Type parameters

    • T

    • A

    • B

    • C

    • D

    • E

    Parameters

    • path: Path5<T, A, B, C, D, E>
    • fn: UpdateFn<OptPathVal<T, [A, B, C, D, E]>, PathVal<T, [A, B, C, D, E]>>

    Returns FnO<T, T>

  • Type parameters

    • T

    • A

    • B

    • C

    • D

    • E

    • F

    Parameters

    • path: Path6<T, A, B, C, D, E, F>
    • fn: UpdateFn<OptPathVal<T, [A, B, C, D, E, F]>, PathVal<T, [A, B, C, D, E, F]>>

    Returns FnO<T, T>

  • Type parameters

    • T

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    Parameters

    • path: Path7<T, A, B, C, D, E, F, G>
    • fn: UpdateFn<OptPathVal<T, [A, B, C, D, E, F, G]>, PathVal<T, [A, B, C, D, E, F, G]>>

    Returns FnO<T, T>

  • Type parameters

    • T

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    Parameters

    • path: Path8<T, A, B, C, D, E, F, G, H>
    • fn: UpdateFn<OptPathVal<T, [A, B, C, D, E, F, G, H]>, PathVal<T, [A, B, C, D, E, F, G, H]>>

    Returns FnO<T, T>

  • Type parameters

    • T

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    Parameters

    • path: DeepPath<T, A, B, C, D, E, F, G, H>
    • fn: UpdateFn<any, any>

    Returns FnO<T, T>

Const defUpdaterUnsafe

  • defUpdaterUnsafe<T>(path: Path, fn: UpdateFn<T, T>): FnO<T, any>
  • Similar to defSetterUnsafe, returns a function to update values at given path using provided update fn. Paths and the arguments given to the returned function are NOT type checked.

    remarks

    The returned function accepts a single object / array and applies fn to given path value (incl. any additional / optional arguments passed) and uses result as new value. Does not modify original state.

    The type parameter T can be used to indicate the type of the nested value to be updated (default: any).

    example
    const incB = defUpdaterUnsafe("a.b", (x, n) => x + n);
    // or
    const incB = defUpdaterUnsafe(["a", "b"], (x, n) => x + n);
    
    incB({ a: { b: 10 } }, 13);
    // { a: { b: 23 } }

    Type parameters

    • T

    Parameters

    Returns FnO<T, any>

Generated using TypeDoc