source: trip-planner-front/node_modules/lodash/cloneWith.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1var baseClone = require('./_baseClone');
2
3/** Used to compose bitmasks for cloning. */
4var CLONE_SYMBOLS_FLAG = 4;
5
6/**
7 * This method is like `_.clone` except that it accepts `customizer` which
8 * is invoked to produce the cloned value. If `customizer` returns `undefined`,
9 * cloning is handled by the method instead. The `customizer` is invoked with
10 * up to four arguments; (value [, index|key, object, stack]).
11 *
12 * @static
13 * @memberOf _
14 * @since 4.0.0
15 * @category Lang
16 * @param {*} value The value to clone.
17 * @param {Function} [customizer] The function to customize cloning.
18 * @returns {*} Returns the cloned value.
19 * @see _.cloneDeepWith
20 * @example
21 *
22 * function customizer(value) {
23 * if (_.isElement(value)) {
24 * return value.cloneNode(false);
25 * }
26 * }
27 *
28 * var el = _.cloneWith(document.body, customizer);
29 *
30 * console.log(el === document.body);
31 * // => false
32 * console.log(el.nodeName);
33 * // => 'BODY'
34 * console.log(el.childNodes.length);
35 * // => 0
36 */
37function cloneWith(value, customizer) {
38 customizer = typeof customizer == 'function' ? customizer : undefined;
39 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
40}
41
42module.exports = cloneWith;
Note: See TracBrowser for help on using the repository browser.