Sha256: 8fb9d43290025ff2ed2c6bec15bbe70d908644b4ca954fecec1299295a3dc957

Contents?: true

Size: 1.1 KB

Versions: 213

Compression:

Stored size: 1.1 KB

Contents

var constant = require('./constant'),
    createInverter = require('./_createInverter'),
    identity = require('./identity');

/** Used for built-in method references. */
var objectProto = Object.prototype;

/**
 * Used to resolve the
 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
 * of values.
 */
var nativeObjectToString = objectProto.toString;

/**
 * Creates an object composed of the inverted keys and values of `object`.
 * If `object` contains duplicate values, subsequent values overwrite
 * property assignments of previous values.
 *
 * @static
 * @memberOf _
 * @since 0.7.0
 * @category Object
 * @param {Object} object The object to invert.
 * @returns {Object} Returns the new inverted object.
 * @example
 *
 * var object = { 'a': 1, 'b': 2, 'c': 1 };
 *
 * _.invert(object);
 * // => { '1': 'c', '2': 'b' }
 */
var invert = createInverter(function(result, value, key) {
  if (value != null &&
      typeof value.toString != 'function') {
    value = nativeObjectToString.call(value);
  }

  result[value] = key;
}, constant(identity));

module.exports = invert;

Version data entries

213 entries across 212 versions & 23 rubygems

Version Path
govuk_publishing_components-16.17.0 node_modules/lodash/invert.js
blsk-sevcore-0.0.2 blsk_old/bluesky-doc/bluesky-doc/node_modules/lodash/invert.js
optimacms-0.4.3 spec/dummy/node_modules/lodash/invert.js
optimacms-0.4.2 spec/dummy/node_modules/lodash/invert.js
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/lodash/invert.js
lux_assets-0.2.11 ./node_modules/lodash/invert.js
lux_assets-0.2.9 ./node_modules/lodash/invert.js
lux_assets-0.2.4 ./node_modules/lodash/invert.js
lux_assets-0.2.2 ./node_modules/lodash/invert.js
lux_assets-0.2.1 ./node_modules/lodash/invert.js
locomotivecms-3.4.0 app/javascript/node_modules/lodash/invert.js
condenser-0.0.4 lib/condenser/processors/node_modules/lodash/invert.js
dragonfly_puppeteer-0.1.0 node_modules/lodash/invert.js