@visulima/deep-clone 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## @visulima/deep-clone [3.0.4](https://github.com/visulima/visulima/compare/@visulima/deep-clone@3.0.3...@visulima/deep-clone@3.0.4) (2025-11-12)
2
+
3
+ ### Bug Fixes
4
+
5
+ * update package configurations and TypeScript definitions ([b59aa59](https://github.com/visulima/visulima/commit/b59aa59dac1508216b944f4b917fb4a7ab1f70a4))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * Add jsr file to all packages for release ([#565](https://github.com/visulima/visulima/issues/565)) ([ec91652](https://github.com/visulima/visulima/commit/ec91652b4e4112adf14ba152c1239a7703ba425a))
10
+
11
+ ## @visulima/deep-clone [3.0.3](https://github.com/visulima/visulima/compare/@visulima/deep-clone@3.0.2...@visulima/deep-clone@3.0.3) (2025-11-07)
12
+
13
+ ### Bug Fixes
14
+
15
+ * update TypeScript configurations and improve linting across multiple packages ([6f25ec7](https://github.com/visulima/visulima/commit/6f25ec7841da7246f8f9166efc5292a7089d37ee))
16
+
17
+ ### Miscellaneous Chores
18
+
19
+ * update npm and pnpm configurations for monorepo optimization ([#564](https://github.com/visulima/visulima/issues/564)) ([5512b42](https://github.com/visulima/visulima/commit/5512b42f672c216b6a3c9e39035199a4ebd9a4b8))
20
+
1
21
  ## @visulima/deep-clone [3.0.2](https://github.com/visulima/visulima/compare/@visulima/deep-clone@3.0.1...@visulima/deep-clone@3.0.2) (2025-11-05)
2
22
 
3
23
  ### Bug Fixes
package/README.md CHANGED
@@ -190,51 +190,51 @@ console.log(clean); // => {}
190
190
 
191
191
  Performance comparison for shallow object cloning `{ a: "a", b: "b", c: "c" }`:
192
192
 
193
- | Library | Operations/sec | Relative Performance |
194
- |---------|----------------|---------------------|
195
- | **plain-object-clone** | 5,650,888 | **1.00x** (fastest) |
196
- | fast-copy | 5,056,607 | 0.89x |
197
- | rfdc - default | 4,674,249 | 0.83x |
198
- | deep-copy | 4,522,595 | 0.80x |
199
- | rfdc - proto | 4,371,388 | 0.77x |
200
- | nanoclone | 4,282,256 | 0.76x |
201
- | **@visulima/deep-clone - loose** | 3,551,940 | 0.63x |
202
- | clone-deep | 3,740,025 | 0.66x |
203
- | nano-copy | 3,673,002 | 0.65x |
204
- | rfdc - circles and proto | 3,423,507 | 0.61x |
205
- | rfdc - circles | 3,235,513 | 0.57x |
206
- | ramda.clone | 2,514,785 | 0.44x |
207
- | lodash.clonedeep | 2,236,361 | 0.40x |
208
- | structured-clone | 1,503,190 | 0.27x |
209
- | @mfederczuk/deeptools | 1,305,034 | 0.23x |
210
- | @ungap/structured-clone | 1,231,364 | 0.22x |
211
- | fast-copy strict | 1,196,932 | 0.21x |
212
- | @visulima/deep-clone - strict | 930,414 | 0.16x |
193
+ | Library | Operations/sec | Relative Performance |
194
+ | -------------------------------- | -------------- | -------------------- |
195
+ | **plain-object-clone** | 5,650,888 | **1.00x** (fastest) |
196
+ | fast-copy | 5,056,607 | 0.89x |
197
+ | rfdc - default | 4,674,249 | 0.83x |
198
+ | deep-copy | 4,522,595 | 0.80x |
199
+ | rfdc - proto | 4,371,388 | 0.77x |
200
+ | nanoclone | 4,282,256 | 0.76x |
201
+ | **@visulima/deep-clone - loose** | 3,551,940 | 0.63x |
202
+ | clone-deep | 3,740,025 | 0.66x |
203
+ | nano-copy | 3,673,002 | 0.65x |
204
+ | rfdc - circles and proto | 3,423,507 | 0.61x |
205
+ | rfdc - circles | 3,235,513 | 0.57x |
206
+ | ramda.clone | 2,514,785 | 0.44x |
207
+ | lodash.clonedeep | 2,236,361 | 0.40x |
208
+ | structured-clone | 1,503,190 | 0.27x |
209
+ | @mfederczuk/deeptools | 1,305,034 | 0.23x |
210
+ | @ungap/structured-clone | 1,231,364 | 0.22x |
211
+ | fast-copy strict | 1,196,932 | 0.21x |
212
+ | @visulima/deep-clone - strict | 930,414 | 0.16x |
213
213
 
214
214
  ### Deep Clone Performance
215
215
 
216
216
  Performance comparison for deep object cloning (complex nested structure):
217
217
 
218
- | Library | Operations/sec | Relative Performance |
219
- |---------|----------------|---------------------|
220
- | **rfdc - proto** | 412,630 | **1.00x** (fastest) |
221
- | rfdc - default | 400,110 | 0.97x |
222
- | rfdc - circles | 369,861 | 0.90x |
223
- | rfdc - circles and proto | 367,846 | 0.89x |
224
- | nanoclone | 314,105 | 0.76x |
225
- | deep-copy | 301,609 | 0.73x |
226
- | plain-object-clone | 249,603 | 0.60x |
227
- | nano-copy | 248,646 | 0.60x |
228
- | fast-copy | 228,871 | 0.55x |
229
- | clone-deep | 217,880 | 0.53x |
230
- | **@visulima/deep-clone - loose** | 194,650 | 0.47x |
231
- | lodash.clonedeep | 130,934 | 0.32x |
232
- | structured-clone | 90,495 | 0.22x |
233
- | @ungap/structured-clone | 88,710 | 0.21x |
234
- | ramda.clone | 58,385 | 0.14x |
235
- | fast-copy strict | 34,771 | 0.08x |
236
- | @visulima/deep-clone - strict | 33,065 | 0.08x |
237
- | @mfederczuk/deeptools | 15,357 | 0.04x |
218
+ | Library | Operations/sec | Relative Performance |
219
+ | -------------------------------- | -------------- | -------------------- |
220
+ | **rfdc - proto** | 412,630 | **1.00x** (fastest) |
221
+ | rfdc - default | 400,110 | 0.97x |
222
+ | rfdc - circles | 369,861 | 0.90x |
223
+ | rfdc - circles and proto | 367,846 | 0.89x |
224
+ | nanoclone | 314,105 | 0.76x |
225
+ | deep-copy | 301,609 | 0.73x |
226
+ | plain-object-clone | 249,603 | 0.60x |
227
+ | nano-copy | 248,646 | 0.60x |
228
+ | fast-copy | 228,871 | 0.55x |
229
+ | clone-deep | 217,880 | 0.53x |
230
+ | **@visulima/deep-clone - loose** | 194,650 | 0.47x |
231
+ | lodash.clonedeep | 130,934 | 0.32x |
232
+ | structured-clone | 90,495 | 0.22x |
233
+ | @ungap/structured-clone | 88,710 | 0.21x |
234
+ | ramda.clone | 58,385 | 0.14x |
235
+ | fast-copy strict | 34,771 | 0.08x |
236
+ | @visulima/deep-clone - strict | 33,065 | 0.08x |
237
+ | @mfederczuk/deeptools | 15,357 | 0.04x |
238
238
 
239
239
  ### Important Notes
240
240
 
@@ -242,9 +242,9 @@ Performance comparison for deep object cloning (complex nested structure):
242
242
  - **Loose mode** (default): Fast performance with standard cloning behavior
243
243
  - **Strict mode**: Slower but clones all properties including non-enumerable ones and symbols
244
244
  - Libraries like `plain-object-clone` and `fastest-json-copy` are faster but have significant limitations:
245
- - Cannot handle circular references
246
- - Treat complex objects (Date, Map, etc.) as plain objects
247
- - Limited type support
245
+ - Cannot handle circular references
246
+ - Treat complex objects (Date, Map, etc.) as plain objects
247
+ - Limited type support
248
248
  - **rfdc** is very fast but has fewer features than @visulima/deep-clone
249
249
 
250
250
  ## Supported Node.js Versions
@@ -0,0 +1,3 @@
1
+ import type { TypedArray } from "../types.d.ts";
2
+ declare const copyArrayBuffer: <Value extends ArrayBuffer | ArrayBufferView | Buffer | TypedArray>(arrayBuffer: Value) => Value;
3
+ export default copyArrayBuffer;
@@ -0,0 +1,6 @@
1
+ import type { State } from "../types.d.ts";
2
+ export declare const copyArrayLoose: <Value extends unknown[]>(array: Value, state: State) => Value;
3
+ /**
4
+ * Deeply copy the indexed values in the array, as well as any custom properties.
5
+ */
6
+ export declare const copyArrayStrict: <Value extends unknown[]>(array: Value, state: State) => Value;
@@ -0,0 +1,2 @@
1
+ declare const copyBlob: <Value extends Blob>(blob: Value) => Value;
2
+ export default copyBlob;
@@ -0,0 +1,2 @@
1
+ declare const copyDataView: <Value extends DataView>(dataView: Value) => Value;
2
+ export default copyDataView;
@@ -0,0 +1,2 @@
1
+ declare const copyDate: <Value extends Date>(date: Value) => Value;
2
+ export default copyDate;
@@ -0,0 +1,8 @@
1
+ import type { State } from "../types.d.ts";
2
+ type ExtendedError = Error & {
3
+ code?: any;
4
+ errno?: any;
5
+ syscall?: any;
6
+ };
7
+ declare const copyError: <Value extends EvalError | ExtendedError | RangeError | ReferenceError | SyntaxError | TypeError | URIError>(object: Value, state: State) => Value;
8
+ export default copyError;
@@ -0,0 +1,6 @@
1
+ import type { State } from "../types.d.ts";
2
+ export declare const copyMapLoose: <Value extends Map<unknown, unknown>>(map: Value, state: State) => Value;
3
+ /**
4
+ * Deeply copy the keys and values of the original, as well as any custom properties.
5
+ */
6
+ export declare const copyMapStrict: <Value extends Map<unknown, unknown>>(map: Value, state: State) => Value;
@@ -0,0 +1,7 @@
1
+ import type { State } from "../types.d.ts";
2
+ export declare const copyObjectLoose: <Value extends Record<PropertyKey, unknown>>(object: Value, state: State) => Value;
3
+ /**
4
+ * Deeply copy the properties (keys and symbols) and values of the original, as well
5
+ * as any hidden or non-enumerable properties.
6
+ */
7
+ export declare const copyObjectStrict: <Value extends Record<PropertyKey, unknown>>(object: Value, state: State) => Value;
@@ -0,0 +1,3 @@
1
+ import type { State } from "../types.d.ts";
2
+ export declare const copyRegExpLoose: <Value extends RegExp>(regExp: Value) => Value;
3
+ export declare const copyRegExpStrict: <Value extends RegExp>(regExp: Value, state: State) => Value;
@@ -0,0 +1,6 @@
1
+ import type { State } from "../types.d.ts";
2
+ export declare const copySetLoose: <Value extends Set<unknown>>(set: Value, state: State) => Value;
3
+ /**
4
+ * Deeply copy the values of the original, as well as any custom properties.
5
+ */
6
+ export declare const copySetStrict: <Value extends Set<unknown>>(set: Value, state: State) => Value;
package/dist/handler.d.ts CHANGED
@@ -1,33 +1,10 @@
1
- import { S as State, T as TypedArray } from './packem_shared/types-_Qve7nv8.js';
2
-
3
- declare const copyArrayLoose: <Value extends unknown[]>(array: Value, state: State) => Value;
4
- declare const copyArrayStrict: <Value extends unknown[]>(array: Value, state: State) => Value;
5
-
6
- declare const copyArrayBuffer: <Value extends ArrayBuffer | ArrayBufferView | Buffer | TypedArray>(arrayBuffer: Value) => Value;
7
-
8
- declare const copyBlob: <Value extends Blob>(blob: Value) => Value;
9
-
10
- declare const copyDataView: <Value extends DataView>(dataView: Value) => Value;
11
-
12
- declare const copyDate: <Value extends Date>(date: Value) => Value;
13
-
14
- type ExtendedError = Error & {
15
- code?: any;
16
- errno?: any;
17
- syscall?: any;
18
- };
19
- declare const copyError: <Value extends EvalError | ExtendedError | RangeError | ReferenceError | SyntaxError | TypeError | URIError>(object: Value, state: State) => Value;
20
-
21
- declare const copyMapLoose: <Value extends Map<unknown, unknown>>(map: Value, state: State) => Value;
22
- declare const copyMapStrict: <Value extends Map<unknown, unknown>>(map: Value, state: State) => Value;
23
-
24
- declare const copyObjectLoose: <Value extends Record<PropertyKey, unknown>>(object: Value, state: State) => Value;
25
- declare const copyObjectStrict: <Value extends Record<PropertyKey, unknown>>(object: Value, state: State) => Value;
26
-
27
- declare const copyRegExpLoose: <Value extends RegExp>(regExp: Value) => Value;
28
- declare const copyRegExpStrict: <Value extends RegExp>(regExp: Value, state: State) => Value;
29
-
30
- declare const copySetLoose: <Value extends Set<unknown>>(set: Value, state: State) => Value;
31
- declare const copySetStrict: <Value extends Set<unknown>>(set: Value, state: State) => Value;
32
-
33
- export { copyArrayBuffer, copyArrayLoose, copyArrayStrict, copyBlob, copyDataView, copyDate, copyError, copyMapLoose, copyMapStrict, copyObjectLoose, copyObjectStrict, copyRegExpLoose, copyRegExpStrict, copySetLoose, copySetStrict };
1
+ export { copyArrayLoose, copyArrayStrict } from "./handler/copy-array.d.ts";
2
+ export { default as copyArrayBuffer } from "./handler/copy-array-buffer.d.ts";
3
+ export { default as copyBlob } from "./handler/copy-blob.d.ts";
4
+ export { default as copyDataView } from "./handler/copy-data-view.d.ts";
5
+ export { default as copyDate } from "./handler/copy-date.d.ts";
6
+ export { default as copyError } from "./handler/copy-error.d.ts";
7
+ export { copyMapLoose, copyMapStrict } from "./handler/copy-map.d.ts";
8
+ export { copyObjectLoose, copyObjectStrict } from "./handler/copy-object.d.ts";
9
+ export { copyRegExpLoose, copyRegExpStrict } from "./handler/copy-regexp.d.ts";
10
+ export { copySetLoose, copySetStrict } from "./handler/copy-set.d.ts";
package/dist/handler.js CHANGED
@@ -1 +1 @@
1
- import{copyArrayLoose as t,copyArrayStrict as e}from"./packem_shared/copyArrayLoose-BEBF0PeG.js";import{default as c}from"./packem_shared/copyArrayBuffer-_dUBQIVn.js";import{default as y}from"./packem_shared/copyBlob-S-Z7ux38.js";import{default as x}from"./packem_shared/copyDataView-EF9L1_xC.js";import{default as s}from"./packem_shared/copyDate-b-cxY0ZF.js";import{default as i}from"./packem_shared/copyError-Bdcealjm.js";import{copyMapLoose as u,copyMapStrict as d}from"./packem_shared/copyMapLoose-BodEbKp7.js";import{copyObjectLoose as b,copyObjectStrict as A}from"./packem_shared/copyObjectLoose-C5x-tHKP.js";import{copyRegExpLoose as g,copyRegExpStrict as j}from"./packem_shared/copyRegExpLoose-Cio6jQWx.js";import{copySetLoose as D,copySetStrict as M}from"./packem_shared/copySetLoose-L-swSTFR.js";export{c as copyArrayBuffer,t as copyArrayLoose,e as copyArrayStrict,y as copyBlob,x as copyDataView,s as copyDate,i as copyError,u as copyMapLoose,d as copyMapStrict,b as copyObjectLoose,A as copyObjectStrict,g as copyRegExpLoose,j as copyRegExpStrict,D as copySetLoose,M as copySetStrict};
1
+ import{copyArrayLoose as t,copyArrayStrict as e}from"./packem_shared/copyArrayLoose-BEBF0PeG.js";import{default as c}from"./packem_shared/copyArrayBuffer-_dUBQIVn.js";import{default as y}from"./packem_shared/copyBlob-S-Z7ux38.js";import{default as x}from"./packem_shared/copyDataView-Ww3lwn8t.js";import{default as s}from"./packem_shared/copyDate-b-cxY0ZF.js";import{default as i}from"./packem_shared/copyError-Bdcealjm.js";import{copyMapLoose as u,copyMapStrict as d}from"./packem_shared/copyMapLoose-BodEbKp7.js";import{copyObjectLoose as b,copyObjectStrict as A}from"./packem_shared/copyObjectLoose-C5x-tHKP.js";import{copyRegExpLoose as g,copyRegExpStrict as j}from"./packem_shared/copyRegExpLoose-Cio6jQWx.js";import{copySetLoose as D,copySetStrict as M}from"./packem_shared/copySetLoose-L-swSTFR.js";export{c as copyArrayBuffer,t as copyArrayLoose,e as copyArrayStrict,y as copyBlob,x as copyDataView,s as copyDate,i as copyError,u as copyMapLoose,d as copyMapStrict,b as copyObjectLoose,A as copyObjectStrict,g as copyRegExpLoose,j as copyRegExpStrict,D as copySetLoose,M as copySetStrict};
package/dist/index.d.ts CHANGED
@@ -1,9 +1,13 @@
1
- import { O as Options } from './packem_shared/types-_Qve7nv8.js';
2
- export { S as State } from './packem_shared/types-_Qve7nv8.js';
3
-
1
+ import type { Options } from "./types.d.ts";
4
2
  type DeepReadwrite<T> = T extends object | [] ? {
5
3
  -readonly [P in keyof T]: DeepReadwrite<T[P]>;
6
4
  } : T;
7
- declare const deepClone: <T>(originalData: T, options?: Options) => DeepReadwrite<T>;
8
-
9
- export { Options, deepClone };
5
+ /**
6
+ * Function that creates a deep clone of an object or array.
7
+ * @template T - The type of the original data.
8
+ * @param originalData The original data to be cloned. It uses the generic parameter `T`.
9
+ * @param options Optional. The cloning options. Type of this parameter is `Options`.
10
+ * @returns The deep cloned data with its type as `DeepReadwrite&lt;T>`.
11
+ */
12
+ export declare const deepClone: <T>(originalData: T, options?: Options) => DeepReadwrite<T>;
13
+ export type { Options, State } from "./types.d.ts";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var s=Object.defineProperty;var f=(t,n)=>s(t,"name",{value:n,configurable:!0});import{copyArrayStrict as u,copyArrayLoose as m}from"./packem_shared/copyArrayLoose-BEBF0PeG.js";import b from"./packem_shared/copyArrayBuffer-_dUBQIVn.js";import l from"./packem_shared/copyBlob-S-Z7ux38.js";import A from"./packem_shared/copyDataView-EF9L1_xC.js";import d from"./packem_shared/copyDate-b-cxY0ZF.js";import S from"./packem_shared/copyError-Bdcealjm.js";import{copyMapStrict as j,copyMapLoose as h}from"./packem_shared/copyMapLoose-BodEbKp7.js";import{copyObjectStrict as w,copyObjectLoose as E}from"./packem_shared/copyObjectLoose-C5x-tHKP.js";import{copyRegExpStrict as M,copyRegExpLoose as B}from"./packem_shared/copyRegExpLoose-Cio6jQWx.js";import{copySetStrict as k,copySetLoose as W}from"./packem_shared/copySetLoose-L-swSTFR.js";var g=Object.defineProperty,a=f((t,n)=>g(t,"name",{value:n,configurable:!0}),"t");const p=a(t=>typeof t=="object"&&t!==null||typeof t=="function","canValueHaveProperties"),v={Array:m,ArrayBuffer:b,Blob:l,DataView:A,Date:d,Error:S,Function:a((t,n)=>t,"Function"),Map:h,Object:E,Promise:a(t=>{throw new TypeError(`${t.constructor.name} objects cannot be cloned`)},"Promise"),RegExp:B,Set:W,SharedArrayBuffer:a((t,n)=>{throw new TypeError(`${t.constructor.name} objects cannot be cloned`)},"SharedArrayBuffer"),WeakMap:a(t=>{throw new TypeError(`${t.constructor.name} objects cannot be cloned`)},"WeakMap"),WeakSet:a(t=>{throw new TypeError(`${t.constructor.name} objects cannot be cloned`)},"WeakSet")},C=a((t,n)=>{if(!p(t))return t;const r={...v,...n?.strict?{Array:u,Map:j,Object:w,RegExp:M,Set:k}:{},...n?.handler};let c=new WeakMap;const i=a((e,o)=>{if(!p(e))return e;if(o.cache.has(e))return o.cache.get(e);if(Array.isArray(e))return r.Array(e,o);if(typeof e=="object"&&e.constructor===Object&&e.nodeType===void 0)return r.Object(e,o);if(e.nodeType!==void 0&&e.cloneNode!==void 0)return e.cloneNode(!0);if(e instanceof Date)return r.Date(e,o);if(e instanceof RegExp)return r.RegExp(e,o);if(e instanceof Map)return r.Map(e,o);if(e instanceof Set)return r.Set(e,o);if(e instanceof Error)return r.Error(e,o);if(e instanceof ArrayBuffer||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Uint32Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array)return r.ArrayBuffer(e,o);if(e instanceof Blob)return r.Blob(e,o);if(e instanceof DataView)return r.DataView(e,o);if(e instanceof SharedArrayBuffer)return r.SharedArrayBuffer(e,o);if(e instanceof Promise)return r.Promise(e,o);if(e instanceof WeakMap)return r.WeakMap(e,o);if(e instanceof WeakSet)return r.WeakSet(e,o);if(typeof e=="function")return r.Function(e,o);if(typeof e=="object")return r.Object(e,o);throw new TypeError(`Type of ${typeof e} cannot be cloned`,e)},"clone"),y=i(t,{cache:c,clone:i});return c=void 0,y},"deepClone");export{C as deepClone};
1
+ var b=Object.defineProperty;var p=(t,n)=>b(t,"name",{value:n,configurable:!0});import{copyArrayStrict as l,copyArrayLoose as A}from"./packem_shared/copyArrayLoose-BEBF0PeG.js";import d from"./packem_shared/copyArrayBuffer-_dUBQIVn.js";import S from"./packem_shared/copyBlob-S-Z7ux38.js";import h from"./packem_shared/copyDataView-Ww3lwn8t.js";import w from"./packem_shared/copyDate-b-cxY0ZF.js";import j from"./packem_shared/copyError-Bdcealjm.js";import{copyMapStrict as E,copyMapLoose as B}from"./packem_shared/copyMapLoose-BodEbKp7.js";import{copyObjectStrict as M,copyObjectLoose as g}from"./packem_shared/copyObjectLoose-C5x-tHKP.js";import{copyRegExpStrict as k,copyRegExpLoose as O}from"./packem_shared/copyRegExpLoose-Cio6jQWx.js";import{copySetStrict as T,copySetLoose as W}from"./packem_shared/copySetLoose-L-swSTFR.js";var v=Object.defineProperty,a=p((t,n)=>v(t,"name",{value:n,configurable:!0}),"t");const y=a(t=>typeof t=="object"&&t!==null||typeof t=="function","canValueHaveProperties"),x={Array:A,ArrayBuffer:d,Blob:S,DataView:h,Date:w,Error:j,Function:a((t,n)=>t,"Function"),Map:B,Object:g,Promise:a(t=>{throw new TypeError(`${t.constructor.name} objects cannot be cloned`)},"Promise"),RegExp:O,Set:W,SharedArrayBuffer:a((t,n)=>{throw new TypeError(`${t.constructor.name} objects cannot be cloned`)},"SharedArrayBuffer"),WeakMap:a(t=>{throw new TypeError(`${t.constructor.name} objects cannot be cloned`)},"WeakMap"),WeakSet:a(t=>{throw new TypeError(`${t.constructor.name} objects cannot be cloned`)},"WeakSet")},H=a((t,n)=>{if(!y(t))return t;const r={...x,...n?.strict?{Array:l,Map:E,Object:M,RegExp:k,Set:T}:{},...n?.handler};let c=new WeakMap;const f=a((e,o)=>{if(!y(e))return e;if(o.cache.has(e))return o.cache.get(e);if(Array.isArray(e))return r.Array(e,o);if(typeof e=="object"&&e.constructor===Object&&e.nodeType===void 0)return r.Object(e,o);if(e.nodeType!==void 0&&e.cloneNode!==void 0)return e.cloneNode(!0);if(e instanceof Date)return r.Date(e,o);if(e instanceof RegExp)return r.RegExp(e,o);if(e instanceof Map)return r.Map(e,o);if(e instanceof Set)return r.Set(e,o);if(e instanceof Error)return r.Error(e,o);if(e instanceof ArrayBuffer)return r.ArrayBuffer(e,o);if(e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Uint32Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array){const{buffer:i}=e;if(i instanceof SharedArrayBuffer)throw new TypeError("SharedArrayBuffer cannot be cloned");const u=r.ArrayBuffer(i,o),m=e.constructor;return new m(u,e.byteOffset,e.length)}if(e instanceof Blob)return r.Blob(e,o);if(e instanceof DataView)return r.DataView(e,o);if(e instanceof SharedArrayBuffer)return r.SharedArrayBuffer(e,o);if(e instanceof Promise)return r.Promise(e,o);if(e instanceof WeakMap)return r.WeakMap(e,o);if(e instanceof WeakSet)return r.WeakSet(e,o);if(typeof e=="function")return r.Function(e,o);if(typeof e=="object")return r.Object(e,o);throw new TypeError(`Type of ${typeof e} cannot be cloned`,e)},"clone"),s=f(t,{cache:c,clone:f});return c=null,s},"deepClone");export{H as deepClone};
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var t=(e,r)=>n(e,"name",{value:r,configurable:!0});import f from"./copyArrayBuffer-_dUBQIVn.js";var o=Object.defineProperty,c=t((e,r)=>o(e,"name",{value:r,configurable:!0}),"f");const y=c(e=>{const{buffer:r}=e;if(r instanceof SharedArrayBuffer)throw new TypeError("SharedArrayBuffer cannot be cloned");const a=f(r);return new DataView(a,e.byteOffset,e.byteLength)},"copyDataView");export{y as default};
@@ -1,9 +1,9 @@
1
1
  type InternalHandler<Value> = (value: Value, state: State) => Value;
2
- interface State {
2
+ export interface State {
3
3
  cache: WeakMap<any, unknown>;
4
4
  clone: InternalHandler<unknown>;
5
5
  }
6
- type Options = {
6
+ export type Options = {
7
7
  handler?: {
8
8
  Array: InternalHandler<unknown[]>;
9
9
  ArrayBuffer: InternalHandler<ArrayBuffer>;
@@ -26,6 +26,5 @@ type Options = {
26
26
  };
27
27
  strict?: boolean;
28
28
  };
29
- type TypedArray = BigInt64Array | BigUint64Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array;
30
-
31
- export type { Options as O, State as S, TypedArray as T };
29
+ export type TypedArray = BigInt64Array | BigUint64Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array;
30
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { State } from "../types.d.ts";
2
+ /**
3
+ * Strict copy all properties contained on the object.
4
+ */
5
+ declare const copyOwnProperties: <Value>(value: Value, clone: Value, state: State) => Value;
6
+ export default copyOwnProperties;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Get an empty version of the object with the same prototype it has.
3
+ */
4
+ declare const getCleanClone: (input: unknown) => any;
5
+ export default getCleanClone;
package/dist/utils.d.ts CHANGED
@@ -1,7 +1,2 @@
1
- import { S as State } from './packem_shared/types-_Qve7nv8.js';
2
-
3
- declare const copyOwnProperties: <Value>(value: Value, clone: Value, state: State) => Value;
4
-
5
- declare const getCleanClone: (input: unknown) => any;
6
-
7
- export { copyOwnProperties, getCleanClone };
1
+ export { default as copyOwnProperties } from "./utils/copy-own-properties.d.ts";
2
+ export { default as getCleanClone } from "./utils/get-clean-clone.d.ts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/deep-clone",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "Fastest deep clone implementation.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -1 +0,0 @@
1
- var t=Object.defineProperty;var r=(e,a)=>t(e,"name",{value:a,configurable:!0});import o from"./copyArrayBuffer-_dUBQIVn.js";var f=Object.defineProperty,i=r((e,a)=>f(e,"name",{value:a,configurable:!0}),"a");const c=i(e=>new DataView(o(e.buffer)),"copyDataView");export{c as default};