root / HServer / 00.Server / 00.Program / node_modules / lodash / cloneDeepWith.js
이력 | 보기 | 이력해설 | 다운로드 (1.02 KB)
| 1 | 39 | HKM | var baseClone = require('./_baseClone'); |
|---|---|---|---|
| 2 | |||
| 3 | /** Used to compose bitmasks for cloning. */
|
||
| 4 | var CLONE_DEEP_FLAG = 1, |
||
| 5 | CLONE_SYMBOLS_FLAG = 4;
|
||
| 6 | |||
| 7 | /**
|
||
| 8 | * This method is like `_.cloneWith` except that it recursively clones `value`.
|
||
| 9 | *
|
||
| 10 | * @static
|
||
| 11 | * @memberOf _
|
||
| 12 | * @since 4.0.0
|
||
| 13 | * @category Lang
|
||
| 14 | * @param {*} value The value to recursively clone.
|
||
| 15 | * @param {Function} [customizer] The function to customize cloning.
|
||
| 16 | * @returns {*} Returns the deep cloned value.
|
||
| 17 | * @see _.cloneWith
|
||
| 18 | * @example
|
||
| 19 | *
|
||
| 20 | * function customizer(value) {
|
||
| 21 | * if (_.isElement(value)) {
|
||
| 22 | * return value.cloneNode(true);
|
||
| 23 | * }
|
||
| 24 | * }
|
||
| 25 | *
|
||
| 26 | * var el = _.cloneDeepWith(document.body, customizer);
|
||
| 27 | *
|
||
| 28 | * console.log(el === document.body);
|
||
| 29 | * // => false
|
||
| 30 | * console.log(el.nodeName);
|
||
| 31 | * // => 'BODY'
|
||
| 32 | * console.log(el.childNodes.length);
|
||
| 33 | * // => 20
|
||
| 34 | */
|
||
| 35 | function cloneDeepWith(value, customizer) { |
||
| 36 | customizer = typeof customizer == 'function' ? customizer : undefined; |
||
| 37 | return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
|
||
| 38 | } |
||
| 39 | |||
| 40 | module.exports = cloneDeepWith; |