Sha256: b07fc2c0146755c10a796e8cdcd7e73a43e63d0fca0d493b6567df4ceefbaad3

Contents?: true

Size: 1.15 KB

Versions: 69

Compression:

Stored size: 1.15 KB

Contents

define(['./clone', '../object/forOwn', './kindOf', './isPlainObject'], function (clone, forOwn, kindOf, isPlainObject) {

    /**
     * Recursively clone native types.
     */
    function deepClone(val, instanceClone) {
        switch ( kindOf(val) ) {
            case 'Object':
                return cloneObject(val, instanceClone);
            case 'Array':
                return cloneArray(val, instanceClone);
            default:
                return clone(val);
        }
    }

    function cloneObject(source, instanceClone) {
        if (isPlainObject(source)) {
            var out = {};
            forOwn(source, function(val, key) {
                this[key] = deepClone(val, instanceClone);
            }, out);
            return out;
        } else if (instanceClone) {
            return instanceClone(source);
        } else {
            return source;
        }
    }

    function cloneArray(arr, instanceClone) {
        var out = [],
            i = -1,
            n = arr.length,
            val;
        while (++i < n) {
            out[i] = deepClone(arr[i], instanceClone);
        }
        return out;
    }

    return deepClone;

});

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/mout/src/lang/deepClone.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/mout/src/lang/deepClone.js