dist/modules/to.js
function toUnnested(obj, prefix, def) {
    if (is_1.isValue(prefix) && !is_1.isBoolean(prefix)) {
        def = prefix;
        prefix = undefined;
    }
    var dupes = 0;
    function unnest(src, dest, pre) {
        dest = dest || {};
        for (var p in src) {
            if (dupes > 0)
                return;
            if (src.hasOwnProperty(p)) {
                if (is_1.isPlainObject(src[p])) {
                    var parent = prefix !== false &&
                        (pre && pre.length) ?
                        pre + '.' + p : p;
                    unnest(src[p], dest, parent);
                }
                else {
                    var name = prefix !== false &&
                        pre && pre.length ?
                        pre + '.' + p : p;
                    if (dest[name])
                        dupes += 1;
                    else
                        dest[name] = src[p];
                }
            }
        }
        if (dupes > 0)
            return null;
        return dest;
    }
    return function_1.tryWrap(unnest, object_1.clone(obj))(def);
}
function toUnnested(obj, prefix, def) {
    if (is_1.isValue(prefix) && !is_1.isBoolean(prefix)) {
        def = prefix;
        prefix = undefined;
    }
    var dupes = 0;
    function unnest(src, dest, pre) {
        dest = dest || {};
        for (var p in src) {
            if (dupes > 0)
                return;
            if (src.hasOwnProperty(p)) {
                if (is_1.isPlainObject(src[p])) {
                    var parent = prefix !== false &&
                        (pre && pre.length) ?
                        pre + '.' + p : p;
                    unnest(src[p], dest, parent);
                }
                else {
                    var name = prefix !== false &&
                        pre && pre.length ?
                        pre + '.' + p : p;
                    if (dest[name])
                        dupes += 1;
                    else
                        dest[name] = src[p];
                }
            }
        }
        if (dupes > 0)
            return null;
        return dest;
    }
    return function_1.tryWrap(unnest, object_1.clone(obj))(def);
}
function toUnnested ( obj , prefix , def ) { if ( is_1 . isValue ( prefix ) && ! is_1 . isBoolean ( prefix ) ) { def = prefix ; prefix = undefined ; } var dupes = 0 ; function unnest ( src , dest , pre ) { dest = dest || { } ; for ( var p in src ) { if ( dupes > 0 ) return ; if ( src . hasOwnProperty ( p ) ) { if ( is_1 . isPlainObject ( src [ p ] ) ) { var parent = prefix !== false && ( pre && pre . length ) ? pre + '.' + p : p ; unnest ( src [ p ] , dest , parent ) ; } else { var name = prefix !== false && pre && pre . length ? pre + '.' + p : p ; if ( dest [ name ] ) dupes += 1 ; else dest [ name ] = src [ p ] ; } } } if ( dupes > 0 ) return null ; return dest ; } return function_1 . tryWrap ( unnest , object_1 . clone ( obj ) ) ( def ) ; }
To Unnested
Takes a nested object and flattens it
to a single level safely. To disable key
prefixing set prefix to false.

@param val the object to be unnested.
@param prefix when NOT false parent key is prefixed to children.
@param def optional default value on null.
To Unnested Takes a nested object and flattens it to a single level safely . To disable key prefixing set prefix to false .