UNPKG

vuestic-ui

Version:
36 lines (35 loc) 929 B
import { i as isObject } from "./is-object.mjs"; const cloneDeep = (source) => { if (source === null || typeof source !== "object") { return source; } if (Array.isArray(source)) { return source.map(cloneDeep); } if (source instanceof Date) { return new Date(source.getTime()); } if (source instanceof RegExp) { return new RegExp(source.source, source.flags); } if (source instanceof Map) { return new Map(Array.from(source.entries()).map(([key, value]) => [key, cloneDeep(value)])); } if (source instanceof Set) { return new Set(Array.from(source.values()).map(cloneDeep)); } if (isObject(source)) { return Object.keys(source).reduce((acc, key) => { acc[key] = cloneDeep(source[key]); return acc; }, {}); } if (typeof source === "function") { return source; } return source; }; export { cloneDeep as c }; //# sourceMappingURL=clone-deep.mjs.map