Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "xform/map-keys"

Index

Functions

Functions

mapKeys

  • mapKeys(keys: IObjectOf<Fn2<any, any, any>>, copy?: undefined | false | true): Transducer<any, any>
  • mapKeys(keys: IObjectOf<Fn2<any, any, any>>, src: Iterable<any>): IterableIterator<any>
  • mapKeys(keys: IObjectOf<Fn2<any, any, any>>, copy: boolean, src: Iterable<any>): IterableIterator<any>
  • Takes a keys object of transformation functions and returns a transducer which expects object values. For each input x then calls transformation functions for each key k in keys. I.e. executes keys[k](x[k], x) and reassigns result. By default creates a shallow copy of each x.

    example
    [...mapKeys(
      {
        a: (x) => x != null ? x * 10 : x,
        b: (x) => x != null ? x * 100: "n/a"
      },
      [{a: 1, b: 2}, {c: 3, d: 4}]
    )]
    // [ { a: 10, b: 200 }, { c: 3, d: 4, b: 'n/a', a: undefined } ]

    Parameters

    • keys: IObjectOf<Fn2<any, any, any>>

      object of transformation functions

    • Optional copy: undefined | false | true

      if true (default), creates a shallow copy of each incoming value

    Returns Transducer<any, any>

  • Parameters

    • keys: IObjectOf<Fn2<any, any, any>>
    • src: Iterable<any>

    Returns IterableIterator<any>

  • Parameters

    • keys: IObjectOf<Fn2<any, any, any>>
    • copy: boolean
    • src: Iterable<any>

    Returns IterableIterator<any>

Generated using TypeDoc