Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
composition / dist / toStringy.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const exotic_1 = require("exotic");
const symbolPrototype = Symbol ? Symbol.prototype : undefined;
const symbolToString = symbolPrototype ? symbolPrototype.toString : undefined;
/**
 * @see https://github.com/lodash/lodash/blob/4ea8c2ec249be046a0f4ae32539d652194caf74f/toString.js
 * Converts `value` to a string. An empty string is returned for `null`
 * and `undefined` values. The sign of `-0` is preserved.
 *
 * @since 4.0.0
 * @category Lang
 * @param {*} value The value to convert.
 * @returns {string} Returns the converted string.
 * @example
 *
 * toString(null)
 * // => ''
 *
 * toString(-0)
 * // => '-0'
 *
 * toString([1, 2, 3])
 * // => '1,2,3'
 */
function toStringy(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 `${value.map(other => (other == null ? other : toStringy(other)))}`;
    }
    if (exotic_1.isSymbol(value)) {
        return symbolToString ? symbolToString.call(value) : '';
    }
    const result = `${value}`;
    return result == '0' && 1 / value == -exotic_1.INFINITY ? '-0' : result;
}
exports.default = toStringy;
//# sourceMappingURL=toStringy.js.map