|
2691 | 2691 | if (!cloneableTags[tag]) {
|
2692 | 2692 | return object ? value : {};
|
2693 | 2693 | }
|
2694 |
| - result = initCloneByTag(value, tag, baseClone, isDeep); |
| 2694 | + result = initCloneByTag(value, tag, isDeep); |
2695 | 2695 | }
|
2696 | 2696 | }
|
2697 | 2697 | // Check for circular references and return its corresponding clone.
|
|
2702 | 2702 | }
|
2703 | 2703 | stack.set(value, result);
|
2704 | 2704 |
|
| 2705 | + if (isSet(value)) { |
| 2706 | + value.forEach(function(subValue) { |
| 2707 | + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); |
| 2708 | + }); |
| 2709 | + |
| 2710 | + return result; |
| 2711 | + } |
| 2712 | + |
| 2713 | + if (isMap(value)) { |
| 2714 | + value.forEach(function(subValue, key) { |
| 2715 | + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); |
| 2716 | + }); |
| 2717 | + |
| 2718 | + return result; |
| 2719 | + } |
| 2720 | + |
2705 | 2721 | var keysFunc = isFull
|
2706 | 2722 | ? (isFlat ? getAllKeysIn : getAllKeys)
|
2707 | 2723 | : (isFlat ? keysIn : keys);
|
|
4565 | 4581 | return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
4566 | 4582 | }
|
4567 | 4583 |
|
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 | 4584 | /**
|
4583 | 4585 | * Creates a clone of `regexp`.
|
4584 | 4586 | *
|
|
4592 | 4594 | return result;
|
4593 | 4595 | }
|
4594 | 4596 |
|
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 | 4597 | /**
|
4610 | 4598 | * Creates a clone of the `symbol` object.
|
4611 | 4599 | *
|
|
6227 | 6215 | * Initializes an object clone based on its `toStringTag`.
|
6228 | 6216 | *
|
6229 | 6217 | * **Note:** This function only supports cloning values with tags of
|
6230 |
| - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. |
| 6218 | + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. |
6231 | 6219 | *
|
6232 | 6220 | * @private
|
6233 | 6221 | * @param {Object} object The object to clone.
|
6234 | 6222 | * @param {string} tag The `toStringTag` of the object to clone.
|
6235 |
| - * @param {Function} cloneFunc The function to clone values. |
6236 | 6223 | * @param {boolean} [isDeep] Specify a deep clone.
|
6237 | 6224 | * @returns {Object} Returns the initialized clone.
|
6238 | 6225 | */
|
6239 |
| - function initCloneByTag(object, tag, cloneFunc, isDeep) { |
| 6226 | + function initCloneByTag(object, tag, isDeep) { |
6240 | 6227 | var Ctor = object.constructor;
|
6241 | 6228 | switch (tag) {
|
6242 | 6229 | case arrayBufferTag:
|
|
6255 | 6242 | return cloneTypedArray(object, isDeep);
|
6256 | 6243 |
|
6257 | 6244 | case mapTag:
|
6258 |
| - return cloneMap(object, isDeep, cloneFunc); |
| 6245 | + return new Ctor; |
6259 | 6246 |
|
6260 | 6247 | case numberTag:
|
6261 | 6248 | case stringTag:
|
|
6265 | 6252 | return cloneRegExp(object);
|
6266 | 6253 |
|
6267 | 6254 | case setTag:
|
6268 |
| - return cloneSet(object, isDeep, cloneFunc); |
| 6255 | + return new Ctor; |
6269 | 6256 |
|
6270 | 6257 | case symbolTag:
|
6271 | 6258 | return cloneSymbol(object);
|
|
0 commit comments