bunshin-clone 1.2.8 → 1.2.10
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 +3 -3
- package/dist/index.cjs +11 -14
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,11 +13,11 @@ npm i bunshin-clone
|
|
|
13
13
|
import { bunshinClone } from 'bunshin-clone';
|
|
14
14
|
|
|
15
15
|
// CDNs
|
|
16
|
-
import { bunshinClone } from 'https://esm.sh/bunshin-clone@1.2.
|
|
16
|
+
import { bunshinClone } from 'https://esm.sh/bunshin-clone@1.2.10';
|
|
17
17
|
// or
|
|
18
|
-
import { bunshinClone } from 'https://cdn.jsdelivr.net/npm/bunshin-clone@1.2.
|
|
18
|
+
import { bunshinClone } from 'https://cdn.jsdelivr.net/npm/bunshin-clone@1.2.10/+esm';
|
|
19
19
|
// or
|
|
20
|
-
import { bunshinClone } from 'https://esm.unpkg.com/bunshin-clone@1.2.
|
|
20
|
+
import { bunshinClone } from 'https://esm.unpkg.com/bunshin-clone@1.2.10';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 📦 APIs
|
package/dist/index.cjs
CHANGED
|
@@ -89,12 +89,10 @@ function clone(node, options, refs) {
|
|
|
89
89
|
return result;
|
|
90
90
|
}
|
|
91
91
|
if (typeof ImageData !== "undefined" && node instanceof ImageData) {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
{ colorSpace: node.colorSpace }
|
|
97
|
-
);
|
|
92
|
+
const { data, width, height, colorSpace } = node;
|
|
93
|
+
const result = new ImageData(new Uint8ClampedArray(data), width, height, {
|
|
94
|
+
colorSpace
|
|
95
|
+
});
|
|
98
96
|
refs.set(node, result);
|
|
99
97
|
return result;
|
|
100
98
|
}
|
|
@@ -115,13 +113,12 @@ function clone(node, options, refs) {
|
|
|
115
113
|
return node;
|
|
116
114
|
}
|
|
117
115
|
function cloneError(value, options, refs) {
|
|
116
|
+
const { name, message, cause, stack } = value;
|
|
118
117
|
if (value instanceof DOMException) {
|
|
119
|
-
const result2 = new DOMException(
|
|
118
|
+
const result2 = new DOMException(message, name);
|
|
120
119
|
refs.set(value, result2);
|
|
121
120
|
return result2;
|
|
122
121
|
}
|
|
123
|
-
const name = value.name || "Error";
|
|
124
|
-
const message = value.message || "";
|
|
125
122
|
let result;
|
|
126
123
|
switch (name) {
|
|
127
124
|
case "EvalError":
|
|
@@ -147,14 +144,14 @@ function cloneError(value, options, refs) {
|
|
|
147
144
|
result.name = name;
|
|
148
145
|
}
|
|
149
146
|
refs.set(value, result);
|
|
150
|
-
if (
|
|
147
|
+
if (stack) {
|
|
151
148
|
try {
|
|
152
|
-
result.stack =
|
|
149
|
+
result.stack = stack;
|
|
153
150
|
} catch {
|
|
154
151
|
}
|
|
155
152
|
}
|
|
156
|
-
if ("cause" in value &&
|
|
157
|
-
result.cause = clone(
|
|
153
|
+
if ("cause" in value && cause !== void 0) {
|
|
154
|
+
result.cause = clone(cause, options, refs);
|
|
158
155
|
}
|
|
159
156
|
for (const key of Object.keys(value)) {
|
|
160
157
|
result[key] = clone(value[key], options, refs);
|
|
@@ -209,7 +206,7 @@ function isUnsafeKey(key) {
|
|
|
209
206
|
* High-performance deep clone utility with descriptor support.
|
|
210
207
|
* Handles circular ref and complex built-in types.
|
|
211
208
|
*
|
|
212
|
-
* @version 1.2.
|
|
209
|
+
* @version 1.2.10
|
|
213
210
|
* @author Yusuke Kamiyamane
|
|
214
211
|
* @license MIT
|
|
215
212
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -87,12 +87,10 @@ function clone(node, options, refs) {
|
|
|
87
87
|
return result;
|
|
88
88
|
}
|
|
89
89
|
if (typeof ImageData !== "undefined" && node instanceof ImageData) {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
{ colorSpace: node.colorSpace }
|
|
95
|
-
);
|
|
90
|
+
const { data, width, height, colorSpace } = node;
|
|
91
|
+
const result = new ImageData(new Uint8ClampedArray(data), width, height, {
|
|
92
|
+
colorSpace
|
|
93
|
+
});
|
|
96
94
|
refs.set(node, result);
|
|
97
95
|
return result;
|
|
98
96
|
}
|
|
@@ -113,13 +111,12 @@ function clone(node, options, refs) {
|
|
|
113
111
|
return node;
|
|
114
112
|
}
|
|
115
113
|
function cloneError(value, options, refs) {
|
|
114
|
+
const { name, message, cause, stack } = value;
|
|
116
115
|
if (value instanceof DOMException) {
|
|
117
|
-
const result2 = new DOMException(
|
|
116
|
+
const result2 = new DOMException(message, name);
|
|
118
117
|
refs.set(value, result2);
|
|
119
118
|
return result2;
|
|
120
119
|
}
|
|
121
|
-
const name = value.name || "Error";
|
|
122
|
-
const message = value.message || "";
|
|
123
120
|
let result;
|
|
124
121
|
switch (name) {
|
|
125
122
|
case "EvalError":
|
|
@@ -145,14 +142,14 @@ function cloneError(value, options, refs) {
|
|
|
145
142
|
result.name = name;
|
|
146
143
|
}
|
|
147
144
|
refs.set(value, result);
|
|
148
|
-
if (
|
|
145
|
+
if (stack) {
|
|
149
146
|
try {
|
|
150
|
-
result.stack =
|
|
147
|
+
result.stack = stack;
|
|
151
148
|
} catch {
|
|
152
149
|
}
|
|
153
150
|
}
|
|
154
|
-
if ("cause" in value &&
|
|
155
|
-
result.cause = clone(
|
|
151
|
+
if ("cause" in value && cause !== void 0) {
|
|
152
|
+
result.cause = clone(cause, options, refs);
|
|
156
153
|
}
|
|
157
154
|
for (const key of Object.keys(value)) {
|
|
158
155
|
result[key] = clone(value[key], options, refs);
|
|
@@ -207,7 +204,7 @@ function isUnsafeKey(key) {
|
|
|
207
204
|
* High-performance deep clone utility with descriptor support.
|
|
208
205
|
* Handles circular ref and complex built-in types.
|
|
209
206
|
*
|
|
210
|
-
* @version 1.2.
|
|
207
|
+
* @version 1.2.10
|
|
211
208
|
* @author Yusuke Kamiyamane
|
|
212
209
|
* @license MIT
|
|
213
210
|
* @copyright Copyright (c) Yusuke Kamiyamane
|