bunshin-clone 1.2.12 → 1.2.13
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 +4 -4
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -4
- 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.13';
|
|
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.13/+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.13';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 📦 APIs
|
package/dist/index.cjs
CHANGED
|
@@ -80,7 +80,7 @@ function clone(node, options, refs) {
|
|
|
80
80
|
refs.set(node, result);
|
|
81
81
|
return result;
|
|
82
82
|
}
|
|
83
|
-
if (node instanceof
|
|
83
|
+
if (node instanceof DOMException || node instanceof Error) {
|
|
84
84
|
return cloneError(node, options, refs);
|
|
85
85
|
}
|
|
86
86
|
if (node instanceof Blob) {
|
|
@@ -154,7 +154,7 @@ function cloneError(value, options, refs) {
|
|
|
154
154
|
result.cause = clone(cause, options, refs);
|
|
155
155
|
}
|
|
156
156
|
for (const key of Object.keys(value)) {
|
|
157
|
-
result
|
|
157
|
+
Reflect.set(result, key, clone(Reflect.get(value, key), options, refs));
|
|
158
158
|
}
|
|
159
159
|
return result;
|
|
160
160
|
}
|
|
@@ -192,7 +192,7 @@ function isObject(value) {
|
|
|
192
192
|
return typeof value === "object" && value !== null;
|
|
193
193
|
}
|
|
194
194
|
function isPlainObject(value) {
|
|
195
|
-
if (value
|
|
195
|
+
if (typeof value !== "object" || value === null) {
|
|
196
196
|
return false;
|
|
197
197
|
}
|
|
198
198
|
const proto = Object.getPrototypeOf(value);
|
|
@@ -206,7 +206,7 @@ function isUnsafeKey(key) {
|
|
|
206
206
|
* High-performance deep clone utility with descriptor support.
|
|
207
207
|
* Handles circular ref and complex built-in types.
|
|
208
208
|
*
|
|
209
|
-
* @version 1.2.
|
|
209
|
+
* @version 1.2.13
|
|
210
210
|
* @author Yusuke Kamiyamane
|
|
211
211
|
* @license MIT
|
|
212
212
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* High-performance deep clone utility with descriptor support.
|
|
4
4
|
* Handles circular ref and complex built-in types.
|
|
5
5
|
*
|
|
6
|
-
* @version 1.2.
|
|
6
|
+
* @version 1.2.13
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -13,10 +13,11 @@ interface BunshinCloneOptions {
|
|
|
13
13
|
preserveDescriptors: boolean;
|
|
14
14
|
strictDescriptors: boolean;
|
|
15
15
|
}
|
|
16
|
+
type Object$1 = Record<PropertyKey, unknown>;
|
|
16
17
|
type Refs = WeakMap<object, unknown>;
|
|
17
18
|
declare function bunshinClone<T>(source: T, options?: Partial<BunshinCloneOptions>, refs?: Refs): T;
|
|
18
|
-
declare function forEachOwnKey(object:
|
|
19
|
-
declare function isObject(value: unknown):
|
|
19
|
+
declare function forEachOwnKey(object: Object$1, callback: (key: string | symbol) => void): void;
|
|
20
|
+
declare function isObject(value: unknown): value is Object$1;
|
|
20
21
|
declare function isPlainObject(value: unknown): boolean;
|
|
21
22
|
declare function isUnsafeKey(key: PropertyKey): boolean;
|
|
22
23
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* High-performance deep clone utility with descriptor support.
|
|
4
4
|
* Handles circular ref and complex built-in types.
|
|
5
5
|
*
|
|
6
|
-
* @version 1.2.
|
|
6
|
+
* @version 1.2.13
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -13,10 +13,11 @@ interface BunshinCloneOptions {
|
|
|
13
13
|
preserveDescriptors: boolean;
|
|
14
14
|
strictDescriptors: boolean;
|
|
15
15
|
}
|
|
16
|
+
type Object$1 = Record<PropertyKey, unknown>;
|
|
16
17
|
type Refs = WeakMap<object, unknown>;
|
|
17
18
|
declare function bunshinClone<T>(source: T, options?: Partial<BunshinCloneOptions>, refs?: Refs): T;
|
|
18
|
-
declare function forEachOwnKey(object:
|
|
19
|
-
declare function isObject(value: unknown):
|
|
19
|
+
declare function forEachOwnKey(object: Object$1, callback: (key: string | symbol) => void): void;
|
|
20
|
+
declare function isObject(value: unknown): value is Object$1;
|
|
20
21
|
declare function isPlainObject(value: unknown): boolean;
|
|
21
22
|
declare function isUnsafeKey(key: PropertyKey): boolean;
|
|
22
23
|
|
package/dist/index.js
CHANGED
|
@@ -78,7 +78,7 @@ function clone(node, options, refs) {
|
|
|
78
78
|
refs.set(node, result);
|
|
79
79
|
return result;
|
|
80
80
|
}
|
|
81
|
-
if (node instanceof
|
|
81
|
+
if (node instanceof DOMException || node instanceof Error) {
|
|
82
82
|
return cloneError(node, options, refs);
|
|
83
83
|
}
|
|
84
84
|
if (node instanceof Blob) {
|
|
@@ -152,7 +152,7 @@ function cloneError(value, options, refs) {
|
|
|
152
152
|
result.cause = clone(cause, options, refs);
|
|
153
153
|
}
|
|
154
154
|
for (const key of Object.keys(value)) {
|
|
155
|
-
result
|
|
155
|
+
Reflect.set(result, key, clone(Reflect.get(value, key), options, refs));
|
|
156
156
|
}
|
|
157
157
|
return result;
|
|
158
158
|
}
|
|
@@ -190,7 +190,7 @@ function isObject(value) {
|
|
|
190
190
|
return typeof value === "object" && value !== null;
|
|
191
191
|
}
|
|
192
192
|
function isPlainObject(value) {
|
|
193
|
-
if (value
|
|
193
|
+
if (typeof value !== "object" || value === null) {
|
|
194
194
|
return false;
|
|
195
195
|
}
|
|
196
196
|
const proto = Object.getPrototypeOf(value);
|
|
@@ -204,7 +204,7 @@ function isUnsafeKey(key) {
|
|
|
204
204
|
* High-performance deep clone utility with descriptor support.
|
|
205
205
|
* Handles circular ref and complex built-in types.
|
|
206
206
|
*
|
|
207
|
-
* @version 1.2.
|
|
207
|
+
* @version 1.2.13
|
|
208
208
|
* @author Yusuke Kamiyamane
|
|
209
209
|
* @license MIT
|
|
210
210
|
* @copyright Copyright (c) Yusuke Kamiyamane
|