CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
invert.js43 linesDownload Raw Back to lodash
1var constant = require('./constant'),2    createInverter = require('./_createInverter'),3    identity = require('./identity');4 5/** Used for built-in method references. */6var objectProto = Object.prototype;7 8/**9 * Used to resolve the10 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)11 * of values.12 */13var nativeObjectToString = objectProto.toString;14 15/**16 * Creates an object composed of the inverted keys and values of `object`.17 * If `object` contains duplicate values, subsequent values overwrite18 * property assignments of previous values.19 *20 * @static21 * @memberOf _22 * @since 0.7.023 * @category Object24 * @param {Object} object The object to invert.25 * @returns {Object} Returns the new inverted object.26 * @example27 *28 * var object = { 'a': 1, 'b': 2, 'c': 1 };29 *30 * _.invert(object);31 * // => { '1': 'c', '2': 'b' }32 */33var invert = createInverter(function(result, value, key) {34  if (value != null &&35      typeof value.toString != 'function') {36    value = nativeObjectToString.call(value);37  }38 39  result[value] = key;40}, constant(identity));41 42module.exports = invert;43 
basant307/AI_Governance_Project · CoolFace