2016-10-10 03:43:44 +02:00
|
|
|
var baseClone = require('./_baseClone');
|
|
|
|
|
2016-11-16 01:59:39 +01:00
|
|
|
/** Used to compose bitmasks for cloning. */
|
|
|
|
var CLONE_DEEP_FLAG = 1,
|
|
|
|
CLONE_SYMBOLS_FLAG = 4;
|
|
|
|
|
2016-10-10 03:43:44 +02:00
|
|
|
/**
|
|
|
|
* This method is like `_.clone` except that it recursively clones `value`.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
* @memberOf _
|
|
|
|
* @since 1.0.0
|
|
|
|
* @category Lang
|
|
|
|
* @param {*} value The value to recursively clone.
|
|
|
|
* @returns {*} Returns the deep cloned value.
|
|
|
|
* @see _.clone
|
|
|
|
* @example
|
|
|
|
*
|
|
|
|
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
|
|
|
*
|
|
|
|
* var deep = _.cloneDeep(objects);
|
|
|
|
* console.log(deep[0] === objects[0]);
|
|
|
|
* // => false
|
|
|
|
*/
|
|
|
|
function cloneDeep(value) {
|
2016-11-16 01:59:39 +01:00
|
|
|
return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = cloneDeep;
|