UNPKG

585 BJavaScriptView Raw
1import addSetEntry from './_addSetEntry';
2import arrayReduce from './_arrayReduce';
3import 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 */
14function cloneSet(set, isDeep, cloneFunc) {
15 var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
16 return arrayReduce(array, addSetEntry, new set.constructor);
17}
18
19export default cloneSet;