moltres-utils
Version:
Utils for Moltres apps
46 lines (33 loc) • 1.27 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _ramda = require("ramda");
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 _toString = value => {
if (value == null) {
return '';
} // 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 `${(0, _ramda.map)(other => other == null ? other : toString(other), value)}`;
}
if ((0, _isSymbol.default)(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
const result = `${value}`;
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
};
var _default = _toString;
exports.default = _default;
//# sourceMappingURL=toString.js.map
;