You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
523 B

4 years ago
  1. var isSymbol = require('./isSymbol');
  2. /** Used as references for various `Number` constants. */
  3. var INFINITY = 1 / 0;
  4. /**
  5. * Converts `value` to a string key if it's not a string or symbol.
  6. *
  7. * @private
  8. * @param {*} value The value to inspect.
  9. * @returns {string|symbol} Returns the key.
  10. */
  11. function toKey(value) {
  12. if (typeof value == 'string' || isSymbol(value)) {
  13. return value;
  14. }
  15. var result = (value + '');
  16. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  17. }
  18. module.exports = toKey;