diff options
Diffstat (limited to 'node_modules/lodash/invert.js')
-rw-r--r-- | node_modules/lodash/invert.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/node_modules/lodash/invert.js b/node_modules/lodash/invert.js index 21d10aba3..8c4795097 100644 --- a/node_modules/lodash/invert.js +++ b/node_modules/lodash/invert.js @@ -2,6 +2,16 @@ 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 @@ -21,6 +31,11 @@ var constant = require('./constant'), * // => { '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)); |