diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/lodash/invert.js | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
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)); |