Ohm-Management - Projektarbeit B-ME
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.

cloneDeepWith.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 `_.cloneWith` except that it recursively clones `value`.
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 4.0.0
  11. * @category Lang
  12. * @param {*} value The value to recursively clone.
  13. * @param {Function} [customizer] The function to customize cloning.
  14. * @returns {*} Returns the deep cloned value.
  15. * @see _.cloneWith
  16. * @example
  17. *
  18. * function customizer(value) {
  19. * if (_.isElement(value)) {
  20. * return value.cloneNode(true);
  21. * }
  22. * }
  23. *
  24. * var el = _.cloneDeepWith(document.body, customizer);
  25. *
  26. * console.log(el === document.body);
  27. * // => false
  28. * console.log(el.nodeName);
  29. * // => 'BODY'
  30. * console.log(el.childNodes.length);
  31. * // => 20
  32. */
  33. function cloneDeepWith(value, customizer) {
  34. customizer = typeof customizer == 'function' ? customizer : undefined;
  35. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  36. }
  37. module.exports = cloneDeepWith;