main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | import baseClone from './_baseClone.js';
|
---|
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 | export default cloneDeepWith;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.