mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
|
import Symbol from './_Symbol.js';
|
||
|
import arrayMap from './_arrayMap.js';
|
||
|
import isArray from './isArray.js';
|
||
|
import isSymbol from './isSymbol.js';
|
||
|
|
||
|
/** Used as references for various `Number` constants. */
|
||
|
var INFINITY = 1 / 0;
|
||
|
|
||
|
/** Used to convert symbols to primitives and strings. */
|
||
|
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||
|
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.toString` which doesn't convert nullish
|
||
|
* values to empty strings.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to process.
|
||
|
* @returns {string} Returns the string.
|
||
|
*/
|
||
|
function baseToString(value) {
|
||
|
// Exit early for strings to avoid a performance hit in some environments.
|
||
|
if (typeof value == 'string') {
|
||
|
return value;
|
||
|
}
|
||
|
if (isArray(value)) {
|
||
|
// Recursively convert values (susceptible to call stack limits).
|
||
|
return arrayMap(value, baseToString) + '';
|
||
|
}
|
||
|
if (isSymbol(value)) {
|
||
|
return symbolToString ? symbolToString.call(value) : '';
|
||
|
}
|
||
|
var result = (value + '');
|
||
|
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||
|
}
|
||
|
|
||
|
export default baseToString;
|