UNPKG

moltres-utils

Version:
40 lines (30 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _isSymbol = _interopRequireDefault(require("./isSymbol")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** Used as references for various `Number` constants. */ const INFINITY = 1 / 0; /** Used to convert symbols to primitives and strings. */ const symbolProto = Symbol ? Symbol.prototype : undefined; const symbolToString = symbolProto ? symbolProto.toString : undefined; const baseToString = value => { // Exit early for strings to avoid a performance hit in some environments. if (typeof value == 'string') { return value; } if (Array.isArray(value)) { // Recursively convert values (susceptible to call stack limits). return `${value.map(baseToString)}`; } if ((0, _isSymbol.default)(value)) { return symbolToString ? symbolToString.call(value) : ''; } const result = `${value}`; return result == '0' && 1 / value == -INFINITY ? '-0' : result; }; var _default = baseToString; exports.default = _default; //# sourceMappingURL=baseToString.js.map