9 lines
342 B
TypeScript
Raw Permalink Normal View History

2024-11-05 10:09:18 +08:00
import { addSetEntry } from './_addSetEntry'
import { arrayReduce } from './_arrayReduce'
import { setToArray } from './_setToArray'
export function cloneSet(set: any, isDeep: any, cloneFunc: any) {
const array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set)
return arrayReduce(array, addSetEntry, new set.constructor())
}