mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Bump to v4.11.2.
This commit is contained in:
25
toString.js
25
toString.js
@@ -1,14 +1,4 @@
|
||||
define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** 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;
|
||||
define(['./_baseToString'], function(baseToString) {
|
||||
|
||||
/**
|
||||
* Converts `value` to a string. An empty string is returned for `null`
|
||||
@@ -32,18 +22,7 @@ define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
|
||||
* // => '1,2,3'
|
||||
*/
|
||||
function toString(value) {
|
||||
// Exit early for strings to avoid a performance hit in some environments.
|
||||
if (typeof value == 'string') {
|
||||
return value;
|
||||
}
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
if (isSymbol(value)) {
|
||||
return symbolToString ? symbolToString.call(value) : '';
|
||||
}
|
||||
var result = (value + '');
|
||||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||||
return value == null ? '' : baseToString(value);
|
||||
}
|
||||
|
||||
return toString;
|
||||
|
||||
Reference in New Issue
Block a user