Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/object-inverse/docs/types/index.d"

Index

Interfaces

Functions

Functions

Export assignment invert

  • invert(obj: any, options?: Options): any
  • Inverts an object, such that keys become values and values become keys.

    Parameters

    • obj: any

      input object

    • Optional options: Options

    Returns any

    inverted object

    Example

    var out = invert({
        'a': 'beep',
        'b': 'boop'
    });
    // returns { 'beep': 'a', 'boop': 'b' }

    Example

    var out = invert({
        'a': 'beep',
        'b': 'beep'
    });
    // returns { 'beep': [ 'a', 'b' ] }

    Example

    var obj = {};
    obj.a = 'beep';
    obj.b = 'boop';
    obj.c = 'beep'; // inserted after `a`
    
    var out = invert( obj, {
        'duplicates': false
    });
    // returns { 'beep': 'c', 'boop': 'b' }