@visulima/deep-clone 1.0.0
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 +6 -0
- package/LICENSE.md +21 -0
- package/README.md +154 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/package.json +155 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 visulima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h3>Visulima Deep Clone</h3>
|
|
3
|
+
<p>
|
|
4
|
+
Really Fast Deep Clone.
|
|
5
|
+
</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<br />
|
|
9
|
+
|
|
10
|
+
<div align="center">
|
|
11
|
+
|
|
12
|
+
[![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
<p>
|
|
20
|
+
<sup>
|
|
21
|
+
Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
|
|
22
|
+
</sup>
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install @visulima/deep-clone
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
yarn add @visulima/deep-clone
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
pnpm add @visulima/deep-clone
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
Copy or deep clone an input value to an arbitrary depth. The function accepts both objects and primitives.
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import deepClone from "@visulima/deep-clone";
|
|
48
|
+
|
|
49
|
+
const cloned = deepClone({ a: 1, b: { c: 2 } });
|
|
50
|
+
|
|
51
|
+
console.log(cloned); // => {a: 1, b: {c: 2}}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Notes
|
|
55
|
+
|
|
56
|
+
- List of **supported** values/types:
|
|
57
|
+
|
|
58
|
+
- `undefined`
|
|
59
|
+
- `null`
|
|
60
|
+
- `boolean`/`Boolean`
|
|
61
|
+
- `string`/`String`
|
|
62
|
+
- `number`/`Number`
|
|
63
|
+
- `function`
|
|
64
|
+
- `Object`
|
|
65
|
+
- `Date`
|
|
66
|
+
- `RegExp`
|
|
67
|
+
- `Set`
|
|
68
|
+
- `Map`
|
|
69
|
+
- [`Error`][mdn-error]
|
|
70
|
+
- [`URIError`][mdn-uri-error]
|
|
71
|
+
- [`ReferenceError`][mdn-reference-error]
|
|
72
|
+
- [`SyntaxError`][mdn-syntax-error]
|
|
73
|
+
- [`RangeError`][mdn-range-error]
|
|
74
|
+
- [`EvalError`][mdn-eval-error]
|
|
75
|
+
- [`TypeError`][mdn-type-error]
|
|
76
|
+
- [`System Error`][node-system-error] (Node.js)
|
|
77
|
+
- `Array`
|
|
78
|
+
- `Int8Array`
|
|
79
|
+
- `Uint8Array`
|
|
80
|
+
- `Uint8ClampedArray`
|
|
81
|
+
- `Init16Array`
|
|
82
|
+
- `Uint16Array`
|
|
83
|
+
- `Int32Array`
|
|
84
|
+
- `Uint32Array`
|
|
85
|
+
- `Float32Array`
|
|
86
|
+
- `Float64Array`
|
|
87
|
+
- `Buffer` ([Node.js][node-buffer])
|
|
88
|
+
|
|
89
|
+
- List of **unsupported** values/types:
|
|
90
|
+
|
|
91
|
+
- `DOMElement`: to copy DOM elements, use `element.cloneNode()`.
|
|
92
|
+
- `Symbol`
|
|
93
|
+
- `WeakMap`
|
|
94
|
+
- `WeakSet`
|
|
95
|
+
- `Blob`
|
|
96
|
+
- `File`
|
|
97
|
+
- `FileList`
|
|
98
|
+
- `ImageData`
|
|
99
|
+
- `ImageBitmap`
|
|
100
|
+
- `DataView`
|
|
101
|
+
- `Promise`
|
|
102
|
+
- `SharedArrayBuffer`
|
|
103
|
+
|
|
104
|
+
- The implementation **can** handle circular references.
|
|
105
|
+
- If a `Number`, `String`, or `Boolean` object is encountered, the value is cloned as a **primitive**. This behavior is intentional. The implementation is opinionated in wanting to **avoid** creating `numbers`, `strings`, and `booleans` via the `new` operator and a constructor.
|
|
106
|
+
- The implementation **only** checks whether basic `Objects`, `Arrays`, and class instances are `extensible`, `sealed`, and/or `frozen`.
|
|
107
|
+
- `functions` are **not** cloned; their reference is copied.
|
|
108
|
+
- The implementation supports custom [`error`][mdn-error] types which are [`Error`][mdn-error] instances (e.g., ES2015 subclasses).
|
|
109
|
+
|
|
110
|
+
## Benchmarks
|
|
111
|
+
|
|
112
|
+
Note:
|
|
113
|
+
|
|
114
|
+
It is true that `jsondiffpatch.clone()` from [jsondiffpatch](https://www.npmjs.com/package/jsondiffpatch) is faster than `@visulima/deep-clonse` in this particular benchmark, but it cannot handle as many situations as `@visulima/deep-clonse` can.
|
|
115
|
+
|
|
116
|
+
It is true that [fastest-json-copy](https://www.npmjs.com/package/fastest-json-copy) is faster than `@visulima/deep-clonse` in this particular benchmark. Also, fastest-json-copy has such huge limitations that it is rarely useful. For example, it treats things like `Date` and `Map` instances the same as empty `{}`. It can't handle circular references.
|
|
117
|
+
|
|
118
|
+
[plain-object-clone](https://www.npmjs.com/package/plain-object-clone) is also really limited in capability.
|
|
119
|
+
|
|
120
|
+
## Supported Node.js Versions
|
|
121
|
+
|
|
122
|
+
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
|
123
|
+
Here’s [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
124
|
+
|
|
125
|
+
## Contributing
|
|
126
|
+
|
|
127
|
+
If you would like to help take a look at the [list of issues](https://github.com/visulima/visulima/issues) and check our [Contributing](.github/CONTRIBUTING.md) guild.
|
|
128
|
+
|
|
129
|
+
> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
|
130
|
+
|
|
131
|
+
## Credits
|
|
132
|
+
|
|
133
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
134
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
The visulima readdir is open-sourced software licensed under the [MIT][license-url]
|
|
139
|
+
|
|
140
|
+
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
141
|
+
[typescript-url]: "typescript"
|
|
142
|
+
[license-image]: https://img.shields.io/npm/l/@visulima/readdir?color=blueviolet&style=for-the-badge
|
|
143
|
+
[license-url]: LICENSE.md "license"
|
|
144
|
+
[npm-image]: https://img.shields.io/npm/v/@visulima/readdir/latest.svg?style=for-the-badge&logo=npm
|
|
145
|
+
[npm-url]: https://www.npmjs.com/package/@visulima/readdir/v/latest "npm"
|
|
146
|
+
[mdn-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
|
|
147
|
+
[mdn-type-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError
|
|
148
|
+
[mdn-syntax-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError
|
|
149
|
+
[mdn-range-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError
|
|
150
|
+
[mdn-reference-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError
|
|
151
|
+
[mdn-uri-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError
|
|
152
|
+
[mdn-eval-error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError
|
|
153
|
+
[node-system-error]: https://nodejs.org/api/errors.html#errors_class_system_error
|
|
154
|
+
[node-buffer]: http://nodejs.org/api/buffer.html
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type DeepReadwrite<T> = T extends object | [] ? {
|
|
2
|
+
-readonly [P in keyof T]: DeepReadwrite<T[P]>;
|
|
3
|
+
} : T;
|
|
4
|
+
interface Options {
|
|
5
|
+
circles?: boolean;
|
|
6
|
+
proto?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const deepClone: <T = unknown>(originalData: T, options?: Options) => DeepReadwrite<T>;
|
|
9
|
+
|
|
10
|
+
export { deepClone };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var w=e=>typeof e=="object"&&e!==null||typeof e=="function",k=e=>{let t={BigInt64Array,BigUint64Array,Buffer:Buffer.from,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array};if(e instanceof ArrayBuffer){let r=new ArrayBuffer(e.byteLength),n=new Uint8Array(e);return new Uint8Array(r).set(n),r}let o=t[e.constructor.name];return o?new o(e):new e.constructor([...e.buffer],e.byteOffset,e.length)},d=[{checker:e=>e instanceof Date,handler:e=>new Date(e),type:"date"},{checker:e=>e instanceof RegExp,handler:e=>{let t=new RegExp(e);return typeof e!="string"&&Object.keys(e).forEach(o=>{let r=Object.getOwnPropertyDescriptor(e,o);r&&(r.hasOwnProperty("value")&&(r.value=l(e[o])),Object.defineProperty(t,o,r));}),t},type:"regex"},{checker:e=>e instanceof Error,handler:e=>{let t=new e.constructor(e.message);return e.stack&&(t.stack=e.stack),e.code&&(t.code=e.code),e.errno&&(t.errno=e.errno),e.syscall&&(t.syscall=e.syscall),Object.keys(e).forEach(o=>{let r=Object.getOwnPropertyDescriptor(e,o);r&&(r.hasOwnProperty("value")&&(r.value=l(e[o])),Object.defineProperty(t,o,r));}),t},type:"error"},{checker:e=>e?.nodeType!==void 0&&e.cloneNode!==void 0,handler:e=>e.cloneNode(!0),type:"jsdom"},{checker:e=>ArrayBuffer.isView(e),handler:e=>k(e),type:"buffer"},{checker:e=>typeof e!="object"||e===null,handler:e=>typeof e=="number"||typeof e=="boolean"||typeof e=="string"?e.valueOf():e,type:"primitive"}],p=[...d,{checker:e=>e instanceof Map,handler:(e,t,o,r,n)=>new Map(f([...e],r,y(t,o,r,n))),type:"map"},{checker:e=>e instanceof Set,handler:(e,t,o,r,n)=>new Set(f([...e],r,y(t,o,r,n))),type:"set"}],E=e=>[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)],f=(e,t,o)=>{let r=Array.from({length:e.length});for(let n=0;n<e.length;n++){let c=e[n],a=d.find(s=>s.checker(c));a?r[n]=a.handler(c):t(o,e,r,n);}return r},h=[e=>e instanceof WeakMap,e=>e instanceof WeakSet,e=>e instanceof SharedArrayBuffer,e=>e instanceof DataView,e=>e instanceof Promise,e=>e instanceof Blob],y=(e,t,o,r)=>n=>{if(typeof n!="object"||n===null||typeof n=="function")return n;for(let a of p)if(a.checker(n))return a.handler(n,e??!1,t,o,r);for(let a of h)if(a(n))throw new TypeError(`${n.constructor.name} objects cannot be cloned`);if(Array.isArray(n))return f(n,o,y(e,t,o,r));let c={};t(n,c);for(let a of E(n)){let s=Object.getOwnPropertyDescriptor(n,a).value;if(typeof s!="object"||s===null)c[a]=s;else {let i=p.find(u=>u.checker(s));i?c[a]=i.handler(s,e??!1,t,o,r):o(y(e,t,o,r),n,c,a);}}if(e){let a=Object.getPrototypeOf(n);Object.getPrototypeOf(c)!==a&&Object.setPrototypeOf(c,a);}return r(),Object.isExtensible(n)||Object.preventExtensions(c),Object.isSealed(n)&&Object.seal(c),Object.isFrozen(n)&&Object.freeze(c),c},O=(e,t)=>{let o=new Map;return y(t,(r,n)=>{o.set(r,n);},(r,n,c,a)=>{if(o.has(n[a]))c[a]=o.get(n[a]);else if(Array.isArray(n))c[a]=r(n[a]);else {let s=Object.getOwnPropertyDescriptor(n,a);s?.value&&(s.value=r(s.value),Object.defineProperty(c,a,s));}},()=>{o.delete(e);})(e)},l=(e,t)=>w(e)?t?.circles?O(e,t?.proto):y(t?.proto,()=>{},(o,r,n,c)=>{let a=r[c];n[c]=o(a);},()=>{})(e):e;
|
|
2
|
+
|
|
3
|
+
export { l as deepClone };
|
|
4
|
+
//# sourceMappingURL=out.js.map
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["canValueHaveProperties","value","copyBuffer","current","typeHandlers","newBuffer","origView","Ctor","arrayCheckerHandlers","object","regexClone","key","desc","deepClone","error","objectCheckerHandlers","useProto","beforeIteration","onIteration","afterIteration","cloneArray","clone","getPropertyKeys","array","function_","cloned","index","handlerData","ch","invalidCloneTypeCheckers","data","invalidTypeChecker","clonedObject","propertyKey","objectPrototype","cloneCircles","originalData","references","object_","propertyDescriptor","options","propertyValue"],"mappings":"AA6BA,IAAMA,EAA0BC,GAC3B,OAAOA,GAAU,UAAYA,IAAU,MAAS,OAAOA,GAAU,WAQhEC,EAAcC,GAAsH,CACtI,IAAMC,EAAyD,CAC3D,cACA,eAGA,OAAQ,OAAO,KACf,aACA,aACA,UACA,WACA,WACA,WACA,kBACA,YACA,WACJ,EAEA,GAAID,aAAmB,YAAa,CAChC,IAAME,EAAY,IAAI,YAAYF,EAAQ,UAAU,EAC9CG,EAAW,IAAI,WAAWH,CAAO,EAGvC,OAFgB,IAAI,WAAWE,CAAS,EAEhC,IAAIC,CAAQ,EAEbD,CACX,CAEA,IAAME,EAAOH,EAAaD,EAAQ,YAAY,IAAI,EAElD,OAAII,EAEO,IAAIA,EAAKJ,CAAO,EAKpB,IAAKA,EAA4B,YAAY,CAAC,GAAGA,EAAQ,MAAM,EAAGA,EAAQ,WAAYA,EAAQ,MAAM,CAC/G,EAYMK,EAA+C,CACjD,CACI,QAAUC,GAAgBA,aAAkB,KAC5C,QAAUA,GAAgB,IAAI,KAAKA,CAAc,EACjD,KAAM,MACV,EACA,CACI,QAAUA,GAAgBA,aAAkB,OAC5C,QAAUA,GAA4B,CAElC,IAAMC,EAAa,IAAI,OAAOD,CAAM,EAGpC,OAAI,OAAOA,GAAW,UAClB,OAAO,KAAKA,CAAM,EAAE,QAASE,GAAQ,CACjC,IAAMC,EAAO,OAAO,yBAAyBH,EAAQE,CAAG,EAEpDC,IAEIA,EAAK,eAAe,OAAO,IAE3BA,EAAK,MAAQC,EAAUJ,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AAG,CAAC,UACpE,MAAM,QAAQmB,CAAI,EAGzBE,EAAarB,CAAa,EAAIa,EAAUM,EAAKnB,CAAG,CAAC,MAC9C,CACH,IAAM4B,EAAqB,OAAO,yBAAyBT,EAAMnB,CAAG,EAEhE4B,GAAoB,QACpBA,EAAmB,MAAQf,EAAUe,EAAmB,KAAK,EAE7D,OAAO,eAAeP,EAAcrB,EAAK4B,CAAkB,EAEnE,CACJ,EACA,IAAM,CACFF,EAAW,OAAOD,CAAY,CAClC,CACJ,EAAEA,CAAY,CAClB,EAkBavB,EAAY,CAAcuB,EAAiBI,IAC/CxC,EAAuBoC,CAAY,EAIpCI,GAAS,QAEFL,EAAgBC,EAAcI,GAAS,KAAK,EAGhDnB,EACHmB,GAAS,MACT,IAAM,CAAC,EACP,CAAChB,EAAWM,EAAME,EAAcrB,IAAQ,CAGpC,IAAM8B,EAAgBX,EAAKnB,CAAG,EAE1B,MAAM,QAAQmB,CAAI,EAElBE,EAAarB,CAAa,EAAIa,EAAUiB,CAAa,CAO7D,EACA,IAAM,CAAC,CACX,EAAEL,CAAY,EA3BHA","sourcesContent":["import type { TypedArray, UnknownRecord } from \"type-fest\";\n\ntype OnIteration = (function_: (oData: any) => unknown, levelData: unknown[] | UnknownRecord, clonedData: unknown[] | UnknownRecord, key: PropertyKey) => void;\n\ntype DataType = \"buffer\" | \"date\" | \"error\" | \"jsdom\" | \"map\" | \"object\" | \"primitive\" | \"regex\" | \"set\" | \"unknown\";\n\ntype DataTypeChecker = (object: any) => boolean;\n\ntype ObjectDataTypeHandler = (\n object: any,\n useProto: boolean,\n beforeIteration: (data: unknown, clonedData: unknown) => void,\n onIteration: OnIteration,\n afterIteration: () => void,\n) => any;\n\ninterface ArrayDataTypeMapping {\n checker: DataTypeChecker;\n handler: (object: any) => any;\n type: DataType;\n}\n\ninterface ObjectDataTypeMapping {\n checker: DataTypeChecker;\n handler: ObjectDataTypeHandler;\n type: DataType;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nconst canValueHaveProperties = (value: unknown): value is NonNullable<Function | object> =>\n (typeof value === \"object\" && value !== null) || typeof value === \"function\";\n\n/**\n * Copy buffer function for cloning ArrayBuffer, ArrayBufferView, Buffer, or TypedArray objects.\n *\n * @param current - The buffer object to be copied. The type of `current` is `ArrayBuffer | ArrayBufferView | Buffer | TypedArray`.\n * @returns The copied buffer object. The return type of the function is `ArrayBuffer | ArrayBufferView | Buffer | TypedArray`.\n */\nconst copyBuffer = (current: ArrayBuffer | ArrayBufferView | Buffer | TypedArray): ArrayBuffer | ArrayBufferView | Buffer | TypedArray => {\n const typeHandlers: Record<string, new (buffer: any) => any> = {\n BigInt64Array,\n BigUint64Array,\n // @ts-expect-error - Buffer has no constructor\n // eslint-disable-next-line @typescript-eslint/unbound-method\n Buffer: Buffer.from,\n Float32Array,\n Float64Array,\n Int8Array,\n Int16Array,\n Int32Array,\n Uint8Array,\n Uint8ClampedArray,\n Uint16Array,\n Uint32Array,\n };\n\n if (current instanceof ArrayBuffer) {\n const newBuffer = new ArrayBuffer(current.byteLength);\n const origView = new Uint8Array(current);\n const newView = new Uint8Array(newBuffer);\n\n newView.set(origView);\n\n return newBuffer;\n }\n\n const Ctor = typeHandlers[current.constructor.name];\n\n if (Ctor) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return new Ctor(current);\n }\n\n // @ts-expect-error - Fallback to ArrayBufferView\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return new (current as ArrayBufferView).constructor([...current.buffer], current.byteOffset, current.length);\n};\n\ninterface FakeJSDOM {\n cloneNode?: (check: boolean) => unknown;\n nodeType?: unknown;\n}\n\ntype ExtendedError = Error & { code?: any; errno?: any; syscall?: any };\n\n/**\n * An Array of checker and handler mappings for different data types.\n */\nconst arrayCheckerHandlers: ArrayDataTypeMapping[] = [\n {\n checker: (object: any) => object instanceof Date,\n handler: (object: any) => new Date(object as Date),\n type: \"date\",\n },\n {\n checker: (object: any) => object instanceof RegExp,\n handler: (object: RegExp | string) => {\n // eslint-disable-next-line require-unicode-regexp,@rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n const regexClone = new RegExp(object);\n\n // Any enumerable properties...\n if (typeof object !== \"string\") {\n Object.keys(object).forEach((key) => {\n const desc = Object.getOwnPropertyDescriptor(object, key);\n\n if (desc) {\n // eslint-disable-next-line no-prototype-builtins\n if (desc.hasOwnProperty(\"value\")) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n desc.value = deepClone(object[key as keyof RegExp]);\n }\n\n Object.defineProperty(regexClone, key, desc);\n }\n });\n }\n\n return regexClone;\n },\n type: \"regex\",\n },\n {\n checker: (object: any) => object instanceof Error,\n handler: (object: EvalError | ExtendedError | RangeError | ReferenceError | SyntaxError | TypeError | URIError) => {\n // @ts-expect-error - We don't know the type of the object, can be an error\n const error = new object.constructor(object.message) as\n | EvalError\n | ExtendedError\n | RangeError\n | ReferenceError\n | SyntaxError\n | TypeError\n | URIError;\n\n // If a `stack` property is present, copy it over...\n if (object.stack) {\n error.stack = object.stack;\n }\n\n // Node.js specific (system errors)...\n if ((object as ExtendedError).code) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n (error as ExtendedError).code = (object as ExtendedError).code;\n }\n\n if ((object as ExtendedError).errno) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n (error as ExtendedError).errno = (object as ExtendedError).errno;\n }\n\n if ((object as ExtendedError).syscall) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n (error as ExtendedError).syscall = (object as ExtendedError).syscall;\n }\n\n // Any enumerable properties...\n Object.keys(object).forEach((key) => {\n const desc = Object.getOwnPropertyDescriptor(object, key);\n\n if (desc) {\n // eslint-disable-next-line no-prototype-builtins\n if (desc.hasOwnProperty(\"value\")) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n desc.value = deepClone(object[key as keyof Error]);\n }\n\n Object.defineProperty(error, key, desc);\n }\n });\n\n return error;\n },\n type: \"error\",\n },\n {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n checker: (object: FakeJSDOM): object is FakeJSDOM => object?.nodeType !== undefined && object.cloneNode !== undefined,\n handler: (object: Required<FakeJSDOM>) => object.cloneNode(true),\n type: \"jsdom\",\n },\n {\n checker: (object: any) => ArrayBuffer.isView(object),\n handler: (object: ArrayBuffer | ArrayBufferView | Buffer | TypedArray) => copyBuffer(object),\n type: \"buffer\",\n },\n {\n checker: (object: any) => typeof object !== \"object\" || object === null,\n // eslint-disable-next-line @typescript-eslint/ban-types\n handler: (object: Function | bigint | boolean | number | string | symbol | null | undefined) => {\n if (typeof object === \"number\" || typeof object === \"boolean\" || typeof object === \"string\") {\n return object.valueOf();\n }\n\n return object;\n },\n type: \"primitive\",\n },\n];\n\nconst objectCheckerHandlers: ObjectDataTypeMapping[] = [\n ...(arrayCheckerHandlers as unknown as ObjectDataTypeMapping[]),\n {\n checker: (object: any) => object instanceof Map,\n handler: (\n object: any,\n useProto: boolean,\n beforeIteration: (data: unknown, clonedData: unknown) => void,\n onIteration: OnIteration,\n afterIteration: () => void,\n ) =>\n new Map(\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n cloneArray([...(object as [])], onIteration, clone(useProto, beforeIteration, onIteration, afterIteration)) as ReadonlyArray<\n [unknown, unknown]\n >,\n ),\n type: \"map\",\n },\n {\n checker: (object) => object instanceof Set,\n handler: (\n object: any,\n useProto: boolean,\n beforeIteration: (data: unknown, clonedData: unknown) => void,\n onIteration: OnIteration,\n afterIteration: () => void,\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n ) => new Set(cloneArray([...(object as [])], onIteration, clone(useProto, beforeIteration, onIteration, afterIteration))),\n type: \"set\",\n },\n];\n\nconst getPropertyKeys = (object: any): (string | symbol)[] => [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];\n\n/**\n * Clones an array by iterating through its elements and applying a function to each element.\n * If an element matches a defined checker function, the element is handled by a corresponding handler function.\n * Otherwise, the element is passed to the provided function for further processing.\n *\n * @param array - The array to clone. The type of `array` is `unknown[]`.\n * @param onIteration - A callback function called for each iteration. It is invoked with the provided function,\n * the original array, the cloned array, and the index of the current element. The type of `onIteration` is a function\n * that accepts four parameters: the provided function of type `(element: unknown) => unknown`, the original array of type `unknown[]`,\n * the cloned array of type `unknown[]`, and the index of the current element of type `number`.\n * @param function_ - The function to apply to each element that does not match a checker function. The type of `function_` is\n * a function that accepts one parameter of type `unknown`.\n * @returns A new array containing the cloned elements. The return type of the function is `unknown[]`.\n */\nconst cloneArray = (array: any[], onIteration: OnIteration, function_: (values: unknown) => unknown): unknown[] => {\n const cloned = Array.from({ length: array.length });\n\n // eslint-disable-next-line no-plusplus,no-loops/no-loops\n for (let index = 0; index < array.length; index++) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const current = array[index];\n const handlerData = arrayCheckerHandlers.find((ch) => ch.checker(current));\n\n if (handlerData) {\n cloned[index] = handlerData.handler(current);\n } else {\n onIteration(function_, array, cloned, index);\n }\n }\n\n return cloned;\n};\n\nconst invalidCloneTypeCheckers: ((object: any) => boolean)[] = [\n (object: any) => object instanceof WeakMap,\n (object: any) => object instanceof WeakSet,\n (object: any) => object instanceof SharedArrayBuffer,\n (object: any) => object instanceof DataView,\n (object: any) => object instanceof Promise,\n (object: any) => object instanceof Blob,\n];\n\n/**\n * Function that clones a given object with optional configuration parameters.\n * It creates a deep clone of the object, including arrays and nested objects.\n * It applies handlers for specific object types, before and after iteration functions,\n * and provides a callback function for each iteration step.\n *\n * @param useProto - Flag indicating whether to use the prototype of the object. The type of `useProto` is `boolean`.\n * @param beforeIteration - Function to be called before each iteration step with the current data\n * being iterated and the cloned data object. The type of `beforeIteration` is a function that\n * accepts two parameters of type `unknown`.\n * @param onIteration - Function to be called for each iteration step with the current data being\n * iterated, the cloned data object, and the property key. The type of `onIteration` is a function\n * that accepts two parameters of type `unknown[] | UnknownRecord` and one parameter of type `string | number`.\n * @param afterIteration - Function to be called after all iterations have completed. The type\n * of `afterIteration` is a function that accepts no parameters.\n * @returns The cloned object. The return type of the function is `unknown`.\n */\nconst clone =\n (useProto: boolean | undefined, beforeIteration: (data: unknown, clonedData: unknown) => void, onIteration: OnIteration, afterIteration: () => void) =>\n // eslint-disable-next-line sonarjs/cognitive-complexity\n (data: any): unknown => {\n if (typeof data !== \"object\" || data === null || typeof data === \"function\") {\n return data;\n }\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const handlerData of objectCheckerHandlers) {\n if (handlerData.checker(data)) {\n return handlerData.handler(data, useProto ?? false, beforeIteration, onIteration, afterIteration);\n }\n }\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const invalidTypeChecker of invalidCloneTypeCheckers) {\n if (invalidTypeChecker(data)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n throw new TypeError(`${data.constructor.name} objects cannot be cloned`);\n }\n }\n\n if (Array.isArray(data)) {\n return cloneArray(data, onIteration, clone(useProto, beforeIteration, onIteration, afterIteration));\n }\n\n const clonedObject: UnknownRecord = {};\n\n beforeIteration(data, clonedObject);\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const propertyKey of getPropertyKeys(data)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const current = (Object.getOwnPropertyDescriptor(data, propertyKey) as PropertyDescriptor).value;\n\n if (typeof current !== \"object\" || current === null) {\n clonedObject[propertyKey] = current;\n } else {\n const handlerData = objectCheckerHandlers.find((ch) => ch.checker(current));\n\n if (handlerData) {\n clonedObject[propertyKey] = handlerData.handler(current, useProto ?? false, beforeIteration, onIteration, afterIteration);\n } else {\n onIteration(clone(useProto, beforeIteration, onIteration, afterIteration), data as unknown[] | UnknownRecord, clonedObject, propertyKey);\n }\n }\n }\n\n if (useProto) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const objectPrototype: object | null = Object.getPrototypeOf(data);\n\n if (Object.getPrototypeOf(clonedObject) !== objectPrototype) {\n Object.setPrototypeOf(clonedObject, objectPrototype);\n }\n }\n\n afterIteration();\n\n if (!Object.isExtensible(data)) {\n Object.preventExtensions(clonedObject);\n }\n\n if (Object.isSealed(data)) {\n Object.seal(clonedObject);\n }\n\n if (Object.isFrozen(data)) {\n Object.freeze(clonedObject);\n }\n\n return clonedObject;\n };\n\n/**\n * Function that clones the given data object, including circular references.\n *\n * @template T - The type of the original data.\n * @param originalData - The original data object to clone. It uses the generic parameter `T`.\n * @param useProto - Optional. Whether to use `__proto__` when cloning objects. The type of `useProto` is `boolean`.\n * @returns The cloned data object. The return type is defined by the generic parameter `T`.\n */\nconst cloneCircles = <T>(originalData: T, useProto: boolean | undefined) => {\n const references = new Map<unknown, unknown>();\n\n return clone(\n useProto,\n (object_, clonedObject) => {\n references.set(object_, clonedObject);\n },\n (function_, data, clonedObject, key) => {\n // @ts-expect-error - We don't know the type of the data, can be an object or array\n if (references.has(data[key])) {\n // @ts-expect-error - We don't know the type of the data, can be an object or array\n // eslint-disable-next-line no-param-reassign\n (clonedObject as unknown[] | UnknownRecord)[key] = references.get(data[key]);\n } else if (Array.isArray(data)) {\n // @ts-expect-error - We don't know the type of the data, can be an object or array\n // eslint-disable-next-line no-param-reassign\n clonedObject[key as number] = function_(data[key]);\n } else {\n const propertyDescriptor = Object.getOwnPropertyDescriptor(data, key);\n\n if (propertyDescriptor?.value) {\n propertyDescriptor.value = function_(propertyDescriptor.value);\n\n Object.defineProperty(clonedObject, key, propertyDescriptor);\n }\n }\n },\n () => {\n references.delete(originalData);\n },\n )(originalData);\n};\n\ntype DeepReadwrite<T> = T extends object | [] ? { -readonly [P in keyof T]: DeepReadwrite<T[P]> } : T;\n\ninterface Options {\n circles?: boolean;\n proto?: boolean;\n}\n\n/**\n * Function that creates a deep clone of an object or array.\n *\n * @template T - The type of the original data.\n * @param originalData - The original data to be cloned. It uses the generic parameter `T`.\n * @param options - Optional. The cloning options. Type of this parameter is `Options`.\n * @returns The deep cloned data with its type as `DeepReadwrite<T>`.\n */\n// eslint-disable-next-line import/prefer-default-export,import/no-unused-modules\nexport const deepClone = <T = unknown>(originalData: T, options?: Options): DeepReadwrite<T> => {\n if (!canValueHaveProperties(originalData)) {\n return originalData as DeepReadwrite<T>;\n }\n\n if (options?.circles) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n return cloneCircles<T>(originalData, options?.proto) as DeepReadwrite<T>;\n }\n\n return clone(\n options?.proto,\n () => {},\n (function_, data, clonedObject, key) => {\n // @ts-expect-error - We don't know the type of the data, can be an object or array\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const propertyValue = data[key];\n\n if (Array.isArray(data)) {\n // eslint-disable-next-line no-param-reassign\n clonedObject[key as number] = function_(propertyValue);\n } else {\n // Assign properties if possible to avoid expensive operations\n // @ts-expect-error - We don't know the type of the data, can be an object or array\n // eslint-disable-next-line no-param-reassign\n clonedObject[key] = function_(propertyValue);\n }\n },\n () => {},\n )(originalData) as DeepReadwrite<T>;\n};\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@visulima/deep-clone",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Fastest deep clone implementation.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"anolilab",
|
|
7
|
+
"deep-clone",
|
|
8
|
+
"clone",
|
|
9
|
+
"fast-clone",
|
|
10
|
+
"object",
|
|
11
|
+
"obj",
|
|
12
|
+
"properties",
|
|
13
|
+
"copy",
|
|
14
|
+
"deep",
|
|
15
|
+
"recursive",
|
|
16
|
+
"key",
|
|
17
|
+
"keys",
|
|
18
|
+
"values",
|
|
19
|
+
"prop",
|
|
20
|
+
"deepclone",
|
|
21
|
+
"deep-copy",
|
|
22
|
+
"deepcopy",
|
|
23
|
+
"fast",
|
|
24
|
+
"performance",
|
|
25
|
+
"performant",
|
|
26
|
+
"fastclone",
|
|
27
|
+
"fastcopy",
|
|
28
|
+
"fast-deep-clone",
|
|
29
|
+
"fast-copy",
|
|
30
|
+
"fast-deep-copy",
|
|
31
|
+
"clone-deep",
|
|
32
|
+
"fastest-json-copy",
|
|
33
|
+
"lodash.clonedeep",
|
|
34
|
+
"nano-copy",
|
|
35
|
+
"plain-object-clone",
|
|
36
|
+
"ramda",
|
|
37
|
+
"standard"
|
|
38
|
+
],
|
|
39
|
+
"homepage": "https://visulima.com/packages/deep-clone",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/visulima/visulima.git",
|
|
43
|
+
"directory": "packages/deep-clone"
|
|
44
|
+
},
|
|
45
|
+
"funding": [
|
|
46
|
+
{
|
|
47
|
+
"type": "github",
|
|
48
|
+
"url": "https://github.com/sponsors/prisis"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"type": "consulting",
|
|
52
|
+
"url": "https://anolilab.com/support"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"author": {
|
|
57
|
+
"name": "Daniel Bannert",
|
|
58
|
+
"email": "d.bannert@anolilab.de"
|
|
59
|
+
},
|
|
60
|
+
"sideEffects": false,
|
|
61
|
+
"type": "module",
|
|
62
|
+
"exports": {
|
|
63
|
+
".": {
|
|
64
|
+
"import": {
|
|
65
|
+
"types": "./dist/index.d.ts",
|
|
66
|
+
"default": "./dist/index.js"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"./package.json": "./package.json"
|
|
70
|
+
},
|
|
71
|
+
"module": "dist/index.js",
|
|
72
|
+
"source": "src/index.ts",
|
|
73
|
+
"types": "dist/index.d.ts",
|
|
74
|
+
"files": [
|
|
75
|
+
"dist/**",
|
|
76
|
+
"README.md",
|
|
77
|
+
"CHANGELOG.md",
|
|
78
|
+
"LICENSE.md"
|
|
79
|
+
],
|
|
80
|
+
"scripts": {
|
|
81
|
+
"build": "cross-env NODE_ENV=development tsup",
|
|
82
|
+
"build:prod": "cross-env NODE_ENV=production tsup",
|
|
83
|
+
"clean": "rimraf node_modules dist .eslintcache",
|
|
84
|
+
"coverage": "vitest run --coverage",
|
|
85
|
+
"dev": "pnpm run build --watch",
|
|
86
|
+
"lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
|
|
87
|
+
"lint:eslint:fix": "pnpm run lint:eslint --fix",
|
|
88
|
+
"lint:packagejson": "publint --strict",
|
|
89
|
+
"lint:prettier": "prettier --config=.prettierrc.cjs --check .",
|
|
90
|
+
"lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
|
|
91
|
+
"lint:types": "tsc --noEmit",
|
|
92
|
+
"test": "vitest run",
|
|
93
|
+
"test:bench": "vitest bench",
|
|
94
|
+
"test:watch": "vitest"
|
|
95
|
+
},
|
|
96
|
+
"devDependencies": {
|
|
97
|
+
"@anolilab/eslint-config": "^14.0.24",
|
|
98
|
+
"@anolilab/prettier-config": "^5.0.11",
|
|
99
|
+
"@anolilab/semantic-release-preset": "^8.0.0",
|
|
100
|
+
"@mfederczuk/deeptools": "2.1.0-indev01",
|
|
101
|
+
"@rushstack/eslint-plugin-security": "^0.7.1",
|
|
102
|
+
"@total-typescript/ts-reset": "^0.5.1",
|
|
103
|
+
"@types/lodash.clonedeep": "^4.5.7",
|
|
104
|
+
"@types/node": "18.17.12",
|
|
105
|
+
"@vitest/coverage-v8": "^0.34.6",
|
|
106
|
+
"clone-deep": "^4.0.1",
|
|
107
|
+
"cross-env": "^7.0.3",
|
|
108
|
+
"deep-copy": "^1.4.2",
|
|
109
|
+
"eslint": "^8.51.0",
|
|
110
|
+
"eslint-plugin-etc": "^2.0.3",
|
|
111
|
+
"eslint-plugin-mdx": "^2.2.0",
|
|
112
|
+
"eslint-plugin-tsdoc": "^0.2.17",
|
|
113
|
+
"eslint-plugin-vitest": "^0.3.2",
|
|
114
|
+
"eslint-plugin-vitest-globals": "^1.4.0",
|
|
115
|
+
"eslint-plugin-deprecation": "^2.0.0",
|
|
116
|
+
"fast-copy": "^3.0.1",
|
|
117
|
+
"jsdom": "^22.1.0",
|
|
118
|
+
"jsondiffpatch": "^0.5.0",
|
|
119
|
+
"lodash.clonedeep": "^4.5.0",
|
|
120
|
+
"nano-copy": "^0.1.0",
|
|
121
|
+
"nanoclone": "^1.0.2",
|
|
122
|
+
"plain-object-clone": "^2.0.0",
|
|
123
|
+
"prettier": "^3.0.3",
|
|
124
|
+
"ramda": "^0.29.1",
|
|
125
|
+
"rfdc": "^1.3.0",
|
|
126
|
+
"rimraf": "^5.0.5",
|
|
127
|
+
"semantic-release": "^22.0.5",
|
|
128
|
+
"sort-package-json": "^2.6.0",
|
|
129
|
+
"standard": "^17.1.0",
|
|
130
|
+
"tsup": "^7.2.0",
|
|
131
|
+
"@ungap/structured-clone": "^1.2.0",
|
|
132
|
+
"type-fest": "^4.4.0",
|
|
133
|
+
"typescript": "^5.2.2",
|
|
134
|
+
"vitest": "^0.34.6"
|
|
135
|
+
},
|
|
136
|
+
"engines": {
|
|
137
|
+
"node": ">=18.* <=20.*"
|
|
138
|
+
},
|
|
139
|
+
"publishConfig": {
|
|
140
|
+
"access": "public",
|
|
141
|
+
"provenance": true
|
|
142
|
+
},
|
|
143
|
+
"anolilab": {
|
|
144
|
+
"eslint-config": {
|
|
145
|
+
"plugin": {
|
|
146
|
+
"tsdoc": false
|
|
147
|
+
},
|
|
148
|
+
"warn_on_unsupported_typescript_version": false,
|
|
149
|
+
"info_on_disabling_jsx_react_rule": false,
|
|
150
|
+
"info_on_disabling_prettier_conflict_rule": false,
|
|
151
|
+
"info_on_disabling_jsonc_sort_keys_rule": false,
|
|
152
|
+
"info_on_disabling_etc_no_deprecated": false
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|