Sha256: 2480ba5c4f5f6036b860746caee9b970a3c0a37ef903555df9678a6816017cbd

Contents?: true

Size: 1013 Bytes

Versions: 3

Compression:

Stored size: 1013 Bytes

Contents

const objectToString = Object.prototype.toString;
function isNone(obj) {
    return obj === null || obj === undefined;
}
/*
 A `toString` util function that supports objects without a `toString`
 method, e.g. an object created with `Object.create(null)`.
*/
export default function toString(obj) {
    if (typeof obj === 'string') {
        return obj;
    }
    if (null === obj)
        return 'null';
    if (undefined === obj)
        return 'undefined';
    if (Array.isArray(obj)) {
        // Reimplement Array.prototype.join according to spec (22.1.3.13)
        // Changing ToString(element) with this safe version of ToString.
        let r = '';
        for (let k = 0; k < obj.length; k++) {
            if (k > 0) {
                r += ',';
            }
            if (!isNone(obj[k])) {
                r += toString(obj[k]);
            }
        }
        return r;
    }
    if (typeof obj.toString === 'function') {
        return obj.toString();
    }
    return objectToString.call(obj);
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/-internals/utils/lib/to-string.js
discourse-ember-source-3.5.1.1 dist/es/ember-utils/lib/to-string.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-utils/lib/to-string.js