|
451 | 451 |
|
452 | 452 | /*--------------------------------------------------------------------------*/
|
453 | 453 |
|
454 |
| - /** |
455 |
| - * Adds the key-value `pair` to `map`. |
456 |
| - * |
457 |
| - * @private |
458 |
| - * @param {Object} map The map to modify. |
459 |
| - * @param {Array} pair The key-value pair to add. |
460 |
| - * @returns {Object} Returns `map`. |
461 |
| - */ |
462 |
| - function addMapEntry(map, pair) { |
463 |
| - // Don't return `map.set` because it's not chainable in IE 11. |
464 |
| - map.set(pair[0], pair[1]); |
465 |
| - return map; |
466 |
| - } |
467 |
| - |
468 |
| - /** |
469 |
| - * Adds `value` to `set`. |
470 |
| - * |
471 |
| - * @private |
472 |
| - * @param {Object} set The set to modify. |
473 |
| - * @param {*} value The value to add. |
474 |
| - * @returns {Object} Returns `set`. |
475 |
| - */ |
476 |
| - function addSetEntry(set, value) { |
477 |
| - // Don't return `set.add` because it's not chainable in IE 11. |
478 |
| - set.add(value); |
479 |
| - return set; |
480 |
| - } |
481 |
| - |
482 | 454 | /**
|
483 | 455 | * A faster alternative to `Function#apply`, this function invokes `func`
|
484 | 456 | * with the `this` binding of `thisArg` and the arguments of `args`.
|
|
2691 | 2663 | if (!cloneableTags[tag]) {
|
2692 | 2664 | return object ? value : {};
|
2693 | 2665 | }
|
2694 |
| - result = initCloneByTag(value, tag, baseClone, isDeep); |
| 2666 | + result = initCloneByTag(value, tag, isDeep); |
2695 | 2667 | }
|
2696 | 2668 | }
|
2697 | 2669 | // Check for circular references and return its corresponding clone.
|
|
2702 | 2674 | }
|
2703 | 2675 | stack.set(value, result);
|
2704 | 2676 |
|
| 2677 | + if (isSet(value)) { |
| 2678 | + value.forEach(function(subValue) { |
| 2679 | + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); |
| 2680 | + }); |
| 2681 | + |
| 2682 | + return result; |
| 2683 | + } |
| 2684 | + |
| 2685 | + if (isMap(value)) { |
| 2686 | + value.forEach(function(subValue, key) { |
| 2687 | + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); |
| 2688 | + }); |
| 2689 | + |
| 2690 | + return result; |
| 2691 | + } |
| 2692 | + |
2705 | 2693 | var keysFunc = isFull
|
2706 | 2694 | ? (isFlat ? getAllKeysIn : getAllKeys)
|
2707 | 2695 | : (isFlat ? keysIn : keys);
|
|
4565 | 4553 | return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
4566 | 4554 | }
|
4567 | 4555 |
|
4568 |
| - /** |
4569 |
| - * Creates a clone of `map`. |
4570 |
| - * |
4571 |
| - * @private |
4572 |
| - * @param {Object} map The map to clone. |
4573 |
| - * @param {Function} cloneFunc The function to clone values. |
4574 |
| - * @param {boolean} [isDeep] Specify a deep clone. |
4575 |
| - * @returns {Object} Returns the cloned map. |
4576 |
| - */ |
4577 |
| - function cloneMap(map, isDeep, cloneFunc) { |
4578 |
| - var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map); |
4579 |
| - return arrayReduce(array, addMapEntry, new map.constructor); |
4580 |
| - } |
4581 |
| - |
4582 | 4556 | /**
|
4583 | 4557 | * Creates a clone of `regexp`.
|
4584 | 4558 | *
|
|
4592 | 4566 | return result;
|
4593 | 4567 | }
|
4594 | 4568 |
|
4595 |
| - /** |
4596 |
| - * Creates a clone of `set`. |
4597 |
| - * |
4598 |
| - * @private |
4599 |
| - * @param {Object} set The set to clone. |
4600 |
| - * @param {Function} cloneFunc The function to clone values. |
4601 |
| - * @param {boolean} [isDeep] Specify a deep clone. |
4602 |
| - * @returns {Object} Returns the cloned set. |
4603 |
| - */ |
4604 |
| - function cloneSet(set, isDeep, cloneFunc) { |
4605 |
| - var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set); |
4606 |
| - return arrayReduce(array, addSetEntry, new set.constructor); |
4607 |
| - } |
4608 |
| - |
4609 | 4569 | /**
|
4610 | 4570 | * Creates a clone of the `symbol` object.
|
4611 | 4571 | *
|
|
6227 | 6187 | * Initializes an object clone based on its `toStringTag`.
|
6228 | 6188 | *
|
6229 | 6189 | * **Note:** This function only supports cloning values with tags of
|
6230 |
| - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. |
| 6190 | + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. |
6231 | 6191 | *
|
6232 | 6192 | * @private
|
6233 | 6193 | * @param {Object} object The object to clone.
|
6234 | 6194 | * @param {string} tag The `toStringTag` of the object to clone.
|
6235 |
| - * @param {Function} cloneFunc The function to clone values. |
6236 | 6195 | * @param {boolean} [isDeep] Specify a deep clone.
|
6237 | 6196 | * @returns {Object} Returns the initialized clone.
|
6238 | 6197 | */
|
6239 |
| - function initCloneByTag(object, tag, cloneFunc, isDeep) { |
| 6198 | + function initCloneByTag(object, tag, isDeep) { |
6240 | 6199 | var Ctor = object.constructor;
|
6241 | 6200 | switch (tag) {
|
6242 | 6201 | case arrayBufferTag:
|
|
6255 | 6214 | return cloneTypedArray(object, isDeep);
|
6256 | 6215 |
|
6257 | 6216 | case mapTag:
|
6258 |
| - return cloneMap(object, isDeep, cloneFunc); |
| 6217 | + return new Ctor; |
6259 | 6218 |
|
6260 | 6219 | case numberTag:
|
6261 | 6220 | case stringTag:
|
|
6265 | 6224 | return cloneRegExp(object);
|
6266 | 6225 |
|
6267 | 6226 | case setTag:
|
6268 |
| - return cloneSet(object, isDeep, cloneFunc); |
| 6227 | + return new Ctor; |
6269 | 6228 |
|
6270 | 6229 | case symbolTag:
|
6271 | 6230 | return cloneSymbol(object);
|
|
0 commit comments