main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | import Symbol from './_Symbol.js';
|
---|
2 | import arrayMap from './_arrayMap.js';
|
---|
3 | import isArray from './isArray.js';
|
---|
4 | import isSymbol from './isSymbol.js';
|
---|
5 |
|
---|
6 | /** Used as references for various `Number` constants. */
|
---|
7 | var INFINITY = 1 / 0;
|
---|
8 |
|
---|
9 | /** Used to convert symbols to primitives and strings. */
|
---|
10 | var symbolProto = Symbol ? Symbol.prototype : undefined,
|
---|
11 | symbolToString = symbolProto ? symbolProto.toString : undefined;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * The base implementation of `_.toString` which doesn't convert nullish
|
---|
15 | * values to empty strings.
|
---|
16 | *
|
---|
17 | * @private
|
---|
18 | * @param {*} value The value to process.
|
---|
19 | * @returns {string} Returns the string.
|
---|
20 | */
|
---|
21 | function baseToString(value) {
|
---|
22 | // Exit early for strings to avoid a performance hit in some environments.
|
---|
23 | if (typeof value == 'string') {
|
---|
24 | return value;
|
---|
25 | }
|
---|
26 | if (isArray(value)) {
|
---|
27 | // Recursively convert values (susceptible to call stack limits).
|
---|
28 | return arrayMap(value, baseToString) + '';
|
---|
29 | }
|
---|
30 | if (isSymbol(value)) {
|
---|
31 | return symbolToString ? symbolToString.call(value) : '';
|
---|
32 | }
|
---|
33 | var result = (value + '');
|
---|
34 | return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
---|
35 | }
|
---|
36 |
|
---|
37 | export default baseToString;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.