lib/utilities.js
function invertObject(obj, override) {
  if (!obj || typeof obj !== 'object') {
    throw new TypeError('First argument must be an object');
  }

  var key;
  var value;
  var isOverridePresent = typeof override === 'function';
  var overrides = {};
  var result = {};

  for (key in obj) {
    value = obj[key];

    if (isOverridePresent) {
      overrides = override(key, value);
      if (overrides && overrides.length === 2) {
        result[overrides[0]] = overrides[1];
        continue;
      }
    }

    if (typeof value === 'string') {
      result[value] = key;
    }
  }

  return result;
}
function invertObject(obj, override) {
  if (!obj || typeof obj !== 'object') {
    throw new TypeError('First argument must be an object');
  }

  var key;
  var value;
  var isOverridePresent = typeof override === 'function';
  var overrides = {};
  var result = {};

  for (key in obj) {
    value = obj[key];

    if (isOverridePresent) {
      overrides = override(key, value);
      if (overrides && overrides.length === 2) {
        result[overrides[0]] = overrides[1];
        continue;
      }
    }

    if (typeof value === 'string') {
      result[value] = key;
    }
  }

  return result;
}
function invertObject ( obj , override ) { if ( ! obj || typeof obj !== 'object' ) { throw new TypeError ( 'First argument must be an object' ) ; } var key ; var value ; var isOverridePresent = typeof override === 'function' ; var overrides = { } ; var result = { } ; for ( key in obj ) { value = obj [ key ] ; if ( isOverridePresent ) { overrides = override ( key , value ) ; if ( overrides && overrides . length === 2 ) { result [ overrides [ 0 ] ] = overrides [ 1 ] ; continue ; } } if ( typeof value === 'string' ) { result [ value ] = key ; } } return result ; }
Swap key with value in an object.

@param  {Object}   obj        - The object.
@param  {Function} [override] - The override method.
@return {Object}              - The inverted object.
Swap key with value in an object .