Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Type aliases

Functions

Type aliases

Binary

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

Returns an object value.

param

object value corresponding to key

param

object key

returns

new value

Type declaration

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

      • value: any
      • key: string

      Returns any

Nullary

Nullary: () => any

Returns an object value.

returns

new value

Type declaration

    • (): any
    • Returns any

Ternary

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

Returns an object value.

param

object value corresponding to key

param

object key

param

the input object

returns

new value

Type declaration

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

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

      Returns any

Transform

Transform: Nullary | Unary | Binary | Ternary

Returns an object value.

param

object value corresponding to key

param

object key

param

the input object

returns

new value

Unary

Unary: (key: string) => any

Returns an object value.

param

object value corresponding to key

returns

new value

Type declaration

    • (key: string): any
    • Parameters

      • key: string

      Returns any

Functions

Export assignment mapValues

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

    Notes

    • The transform function is provided three arguments:

      • value: object value corresponding to key
      • key: object key
      • obj: the input object
    • The function only maps values from 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( value, key ) {
        return key + value;
    }
    
    var obj1 = {
        'a': 1,
        'b': 2
    };
    
    var obj2 = mapValues( obj1, transform );
    // returns { 'a': 'a1', 'b': 'b2' }