mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Bump to v4.17.5.
This commit is contained in:
15
invert.js
15
invert.js
@@ -2,6 +2,16 @@ import constant from './constant.js';
|
||||
import createInverter from './_createInverter.js';
|
||||
import identity from './identity.js';
|
||||
|
||||
/** 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
|
||||
@@ -21,6 +31,11 @@ import identity from './identity.js';
|
||||
* // => { '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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user