mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Bump to v4.17.5.
This commit is contained in:
15
invert.js
15
invert.js
@@ -1,5 +1,15 @@
|
||||
define(['./constant', './_createInverter', './identity'], function(constant, createInverter, 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
|
||||
@@ -19,6 +29,11 @@ define(['./constant', './_createInverter', './identity'], function(constant, cre
|
||||
* // => { '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