Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/map-keys/docs/types/index.d"

Index

Type aliases

Functions

Type aliases

Binary

Binary: (key: string, value: any) => string | symbol

Returns an object key.

param

object key

param

object value corresponding to key

returns

new key

Type declaration

    • (key: string, value: any): string | symbol
    • Parameters

      • key: string
      • value: any

      Returns string | symbol

Nullary

Nullary: () => string | symbol

Returns an object key.

returns

new key

Type declaration

    • (): string | symbol
    • Returns string | symbol

Ternary

Ternary: (key: string, value: any, obj: any) => string | symbol

Returns an object key.

param

object key

param

object value corresponding to key

param

the input object

returns

new key

Type declaration

    • (key: string, value: any, obj: any): string | symbol
    • Parameters

      • key: string
      • value: any
      • obj: any

      Returns string | symbol

Transform

Transform: Nullary | Unary | Binary | Ternary

Returns an object key.

param

object key

param

object value corresponding to key

param

the input object

returns

new key

Unary

Unary: (key: string) => string | symbol

Returns an object key.

param

object key

returns

new key

Type declaration

    • (key: string): string | symbol
    • Parameters

      • key: string

      Returns string | symbol

Functions

Export assignment mapKeys

  • mapKeys(obj: any, transform: Transform): any
  • Maps keys from one object to a new object having the same values.

    Notes

    • The transform function is provided three arguments:

      • key: object key
      • value: object value corresponding to key
      • obj: the input object
    • The value returned by a transform function should be a value which can be serialized as an object key.

    • The function only maps own properties. Hence, the function does not map inherited properties.

    • The function shallow copies key values.

    • Iteration order is not guaranteed.

    Parameters

    • obj: any

      source object

    • transform: Transform

      transform function

    Returns any

    new object

    Example

    function transform( key, value ) {
        return key + value;
    }
    
    var obj1 = {
        'a': 1,
        'b': 2
    };
    
    var obj2 = mapKeys( obj1, transform );
    // returns { 'a1': 1, 'b2': 2 }