function cloneAndTrim(obj, depth = 5) {
    if (depth < 1) return null;

    const ret = {};
    forOwn(obj, (val, key) => {
        if (key.startsWith('_')) return;
        if (val && !val.toJSON) {
            if (isObject(val)) {
                val = depth > 1 ? cloneAndTrim(val, depth - 1) : '{...}';
            }
            if (isArray(val)) {
                val = depth > 1 ? val.map(it => cloneAndTrim(it, depth - 1)) : '[...]';
            }
        }
        ret[key] = val;
    });

    return ret;
}
//   - Don't touch objects that implement toJSON()
Don't touch objects that implement toJSON()
Don ' t touch objects that implement toJSON ()
function cloneAndTrim(obj, depth = 5) {
    if (depth < 1) return null;
    const ret = {};
    forOwn(obj, (val, key) => {
        if (key.startsWith('_')) return;
        if (val && !val.toJSON) {
            if (isObject(val)) {
                val = depth > 1 ? cloneAndTrim(val, depth - 1) : '{...}';
            }
            if (isArray(val)) {
                val = depth > 1 ? val.map(it => cloneAndTrim(it, depth - 1)) : '[...]';
            }
        }
        ret[key] = val;
    });
    return ret;
}
function cloneAndTrim ( obj , depth = 5 ) { if ( depth < 1 ) return null ; const ret = { } ; forOwn ( obj , ( val , key ) => { if ( key . startsWith ( '_' ) ) return ; if ( val && ! val . toJSON ) { if ( isObject ( val ) ) { val = depth > 1 ? cloneAndTrim ( val , depth - 1 ) : '{...}' ; } if ( isArray ( val ) ) { val = depth > 1 ? val . map ( it => cloneAndTrim ( it , depth - 1 ) ) : '[...]' ; } } ret [ key ] = val ; } ) ; return ret ; }
Don't touch objects that implement toJSON()
Don ' t touch objects that implement toJSON ()