1 | import addSetEntry from './_addSetEntry';
|
2 | import arrayReduce from './_arrayReduce';
|
3 | import setToArray from './_setToArray';
|
4 |
|
5 | /**
|
6 | * Creates a clone of `set`.
|
7 | *
|
8 | * @private
|
9 | * @param {Object} set The set to clone.
|
10 | * @param {Function} cloneFunc The function to clone values.
|
11 | * @param {boolean} [isDeep] Specify a deep clone.
|
12 | * @returns {Object} Returns the cloned set.
|
13 | */
|
14 | function cloneSet(set, isDeep, cloneFunc) {
|
15 | var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
|
16 | return arrayReduce(array, addSetEntry, new set.constructor);
|
17 | }
|
18 |
|
19 | export default cloneSet;
|