Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
523 bytes
|
Line | |
---|
1 | var isSymbol = require('./isSymbol');
|
---|
2 |
|
---|
3 | /** Used as references for various `Number` constants. */
|
---|
4 | var INFINITY = 1 / 0;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Converts `value` to a string key if it's not a string or symbol.
|
---|
8 | *
|
---|
9 | * @private
|
---|
10 | * @param {*} value The value to inspect.
|
---|
11 | * @returns {string|symbol} Returns the key.
|
---|
12 | */
|
---|
13 | function toKey(value) {
|
---|
14 | if (typeof value == 'string' || isSymbol(value)) {
|
---|
15 | return value;
|
---|
16 | }
|
---|
17 | var result = (value + '');
|
---|
18 | return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
---|
19 | }
|
---|
20 |
|
---|
21 | module.exports = toKey;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.