Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "rename-keys"

Index

Functions

Const renameKeysMap

  • renameKeysMap<K, V>(src: Map<K, V>, km: Map<K, K>, out?: Map<K, V>): undefined | Map<K, V>
  • Renames keys in src using mapping provided by key map km. Does support key swapping / swizzling. Does not modify original.

    Type parameters

    • K

    • V

    Parameters

    • src: Map<K, V>

      source map

    • km: Map<K, K>

      key mappings

    • Optional out: Map<K, V>

      result map

    Returns undefined | Map<K, V>

Const renameKeysObj

  • renameKeysObj<T>(src: T, km: {}, out?: any): any
  • Renames keys in src using mapping provided by key map km. Does support key swapping / swizzling. Does not modify original.

    // swap a & b, rename c
    renameKeysObj({a: 1, b: 2, c: 3}, {a: "b", b: "a", c: "cc"})
    // {b: 1, a: 2, cc: 3}

    Type parameters

    • T

    Parameters

    • src: T

      source object

    • km: {}

      key mappings

      • Default value out: any = {}

        result object

      Returns any

    Generated using TypeDoc