You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cloneDeep.js 679B

1234567891011121314151617181920212223242526272829
  1. var baseClone = require('./_baseClone');
  2. /** Used to compose bitmasks for cloning. */
  3. var CLONE_DEEP_FLAG = 1,
  4. CLONE_SYMBOLS_FLAG = 4;
  5. /**
  6. * This method is like `_.clone` except that it recursively clones `value`.
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 1.0.0
  11. * @category Lang
  12. * @param {*} value The value to recursively clone.
  13. * @returns {*} Returns the deep cloned value.
  14. * @see _.clone
  15. * @example
  16. *
  17. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  18. *
  19. * var deep = _.cloneDeep(objects);
  20. * console.log(deep[0] === objects[0]);
  21. * // => false
  22. */
  23. function cloneDeep(value) {
  24. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  25. }
  26. module.exports = cloneDeep;