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
appmap-0.66.0 ./node_modules/lodash/invert.js
appmap-0.65.1 ./node_modules/lodash/invert.js
appmap-0.65.0 ./node_modules/lodash/invert.js
trusty-cms-4.3.4 node_modules/lodash/invert.js
appmap-0.64.0 ./node_modules/lodash/invert.js
appmap-0.63.0 ./node_modules/lodash/invert.js
jekyll-esm-0.0.3 node_modules/lodash/invert.js
trusty-cms-4.3.3 node_modules/lodash/invert.js
trusty-cms-4.3.2 node_modules/lodash/invert.js
trusty-cms-4.3.1 node_modules/lodash/invert.js
boring_generators-0.11.0 tmp/templates/app_template/node_modules/lodash/invert.js
trusty-cms-4.3 node_modules/lodash/invert.js
boring_generators-0.10.0 tmp/templates/app_template/node_modules/lodash/invert.js
trusty-cms-4.2.3 node_modules/lodash/invert.js
boring_generators-0.9.0 tmp/templates/app_template/node_modules/lodash/invert.js
tang-0.2.1 spec/tang_app/node_modules/lodash/invert.js
trusty-cms-4.2.2 node_modules/lodash/invert.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/lodash/invert.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/lodash/invert.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/lodash/invert.js