bunshin-clone 1.0.2 → 1.0.3
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/README.md +13 -3
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +26 -1
package/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Bunshin Clone
|
|
2
2
|
|
|
3
3
|
High-performance deep clone utility with descriptor support. Supports circular references and complex built-in types.
|
|
4
4
|
|
|
5
5
|
* ⚡ Fast (no unnecessary overhead)
|
|
6
6
|
* ♻️ Deep clone (no structural sharing)
|
|
7
|
-
* 🔁 Supports circular
|
|
7
|
+
* 🔁 Supports circular ref
|
|
8
8
|
* 🧠 Handles Map, Set, Array, TypedArray, Date, RegExp, etc.
|
|
9
9
|
* 🧩 Optional descriptor preservation
|
|
10
10
|
|
|
11
|
+
---
|
|
12
|
+
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
15
|
```ts
|
|
@@ -45,6 +47,9 @@ interface BunshinCloneOptions {
|
|
|
45
47
|
* `false` (default): use standard merge (faster, ignores property descriptors)
|
|
46
48
|
* `true`: preserve property descriptors (getters/setters, etc.)
|
|
47
49
|
|
|
50
|
+
<details>
|
|
51
|
+
<summary>Example</summary>
|
|
52
|
+
|
|
48
53
|
```ts
|
|
49
54
|
const source = {};
|
|
50
55
|
Object.defineProperty(source, 'x', {
|
|
@@ -57,18 +62,23 @@ const result = bunshinClone(source, { preserveDescriptors: true });
|
|
|
57
62
|
Object.getOwnPropertyDescriptor(result, 'x')?.get;
|
|
58
63
|
// => function
|
|
59
64
|
```
|
|
65
|
+
</details>
|
|
60
66
|
|
|
61
67
|
### strictDescriptors
|
|
62
68
|
|
|
63
69
|
* `false` (default): skip incompatible descriptors
|
|
64
70
|
* `true`: throw if descriptor cannot be merged (e.g. non-configurable or non-writable)
|
|
65
71
|
|
|
72
|
+
<details>
|
|
73
|
+
<summary>Example</summary>
|
|
74
|
+
|
|
66
75
|
```ts
|
|
67
76
|
Object.freeze(obj);
|
|
68
77
|
|
|
69
78
|
bunshinClone(obj, { strictDescriptors: true });
|
|
70
79
|
// => may throw TypeError
|
|
71
80
|
```
|
|
81
|
+
</details>
|
|
72
82
|
|
|
73
83
|
## Supported Types
|
|
74
84
|
|
|
@@ -186,7 +196,7 @@ When `preserveDescriptors` is enabled:
|
|
|
186
196
|
|
|
187
197
|
## Comparison
|
|
188
198
|
|
|
189
|
-
| Feature |
|
|
199
|
+
| Feature | Bunshin Clone | structuredClone | lodash.clonedeep |
|
|
190
200
|
|---------------------|--------------|----------------|------------------|
|
|
191
201
|
| Circular refs | ✅ | ✅ | ✅ |
|
|
192
202
|
| Map / Set | ✅ | ✅ | ⚠️ (partial) |
|
package/dist/index.cjs
CHANGED
|
@@ -191,11 +191,11 @@ function isUnsafeKey(key) {
|
|
|
191
191
|
return typeof key === "string" && (key === "__proto__" || key === "prototype" || key === "constructor");
|
|
192
192
|
}
|
|
193
193
|
/**
|
|
194
|
-
*
|
|
194
|
+
* Bunshin Clone
|
|
195
195
|
* High-performance deep clone utility with descriptor support.
|
|
196
196
|
* Supports circular ref and complex built-in types.
|
|
197
197
|
*
|
|
198
|
-
* @version 1.0.
|
|
198
|
+
* @version 1.0.3
|
|
199
199
|
* @author Yusuke Kamiyamane
|
|
200
200
|
* @license MIT
|
|
201
201
|
* @copyright Copyright (c) 2026 Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Bunshin Clone
|
|
3
3
|
* High-performance deep clone utility with descriptor support.
|
|
4
4
|
* Supports circular ref and complex built-in types.
|
|
5
5
|
*
|
|
6
|
-
* @version 1.0.
|
|
6
|
+
* @version 1.0.3
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) 2026 Yusuke Kamiyamane
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Bunshin Clone
|
|
3
3
|
* High-performance deep clone utility with descriptor support.
|
|
4
4
|
* Supports circular ref and complex built-in types.
|
|
5
5
|
*
|
|
6
|
-
* @version 1.0.
|
|
6
|
+
* @version 1.0.3
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) 2026 Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -187,11 +187,11 @@ function isUnsafeKey(key) {
|
|
|
187
187
|
return typeof key === "string" && (key === "__proto__" || key === "prototype" || key === "constructor");
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
|
-
*
|
|
190
|
+
* Bunshin Clone
|
|
191
191
|
* High-performance deep clone utility with descriptor support.
|
|
192
192
|
* Supports circular ref and complex built-in types.
|
|
193
193
|
*
|
|
194
|
-
* @version 1.0.
|
|
194
|
+
* @version 1.0.3
|
|
195
195
|
* @author Yusuke Kamiyamane
|
|
196
196
|
* @license MIT
|
|
197
197
|
* @copyright Copyright (c) 2026 Yusuke Kamiyamane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunshin-clone",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "High-performance deep clone utility with descriptor support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -25,8 +25,33 @@
|
|
|
25
25
|
"lint": "tsc --noEmit"
|
|
26
26
|
},
|
|
27
27
|
"keywords": [
|
|
28
|
+
"array",
|
|
29
|
+
"buffer",
|
|
30
|
+
"circular-reference",
|
|
28
31
|
"clone",
|
|
32
|
+
"clone-array",
|
|
33
|
+
"clone-array-deep",
|
|
34
|
+
"clone-buffer",
|
|
35
|
+
"clone-date",
|
|
36
|
+
"clone-deep",
|
|
37
|
+
"clone-map",
|
|
38
|
+
"clone-object",
|
|
39
|
+
"clone-object-deep",
|
|
40
|
+
"clone-regexp",
|
|
41
|
+
"clone-set",
|
|
42
|
+
"copy",
|
|
43
|
+
"copy-deep",
|
|
44
|
+
"date",
|
|
29
45
|
"deep",
|
|
46
|
+
"deep-clone",
|
|
47
|
+
"deep-copy",
|
|
48
|
+
"descriptor",
|
|
49
|
+
"map",
|
|
50
|
+
"object",
|
|
51
|
+
"property-descriptor",
|
|
52
|
+
"regexp",
|
|
53
|
+
"set",
|
|
54
|
+
"structured-clone",
|
|
30
55
|
"typescript"
|
|
31
56
|
],
|
|
32
57
|
"author": "Yusuke Kamiyamane",
|