source: imaps-frontend/node_modules/lodash-es/invert.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import constant from './constant.js';
2import createInverter from './_createInverter.js';
3import identity from './identity.js';
4
5/** Used for built-in method references. */
6var objectProto = Object.prototype;
7
8/**
9 * Used to resolve the
10 * [`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 overwrite
18 * property assignments of previous values.
19 *
20 * @static
21 * @memberOf _
22 * @since 0.7.0
23 * @category Object
24 * @param {Object} object The object to invert.
25 * @returns {Object} Returns the new inverted object.
26 * @example
27 *
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
42export default invert;
Note: See TracBrowser for help on using the repository browser.