bunshin-clone 1.2.6 → 1.2.8

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Yusuke Kamiyamane
3
+ Copyright (c) Yusuke Kamiyamane
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -10,14 +10,14 @@ npm i bunshin-clone
10
10
 
11
11
  ```ts
12
12
  // npm
13
- import bunshinClone from 'bunshin-clone';
13
+ import { bunshinClone } from 'bunshin-clone';
14
14
 
15
15
  // CDNs
16
- import bunshinClone from 'https://esm.sh/bunshin-clone@1.2.6';
16
+ import { bunshinClone } from 'https://esm.sh/bunshin-clone@1.2.8';
17
17
  // or
18
- import bunshinClone from 'https://cdn.jsdelivr.net/npm/bunshin-clone@1.2.6/+esm';
18
+ import { bunshinClone } from 'https://cdn.jsdelivr.net/npm/bunshin-clone@1.2.8/+esm';
19
19
  // or
20
- import bunshinClone from 'https://esm.unpkg.com/bunshin-clone@1.2.6';
20
+ import { bunshinClone } from 'https://esm.unpkg.com/bunshin-clone@1.2.8';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -104,7 +104,7 @@ result.self === result; // true
104
104
  const source = {
105
105
  get x() {
106
106
  return 42;
107
- }
107
+ },
108
108
  };
109
109
 
110
110
  const result = bunshinClone(source);
package/dist/index.cjs CHANGED
@@ -80,10 +80,10 @@ function clone(node, options, refs) {
80
80
  refs.set(node, result);
81
81
  return result;
82
82
  }
83
- if (node instanceof Error || typeof DOMException !== "undefined" && node instanceof DOMException) {
83
+ if (node instanceof Error || node instanceof DOMException) {
84
84
  return cloneError(node, options, refs);
85
85
  }
86
- if (typeof Blob !== "undefined" && node instanceof Blob) {
86
+ if (node instanceof Blob) {
87
87
  const result = node.slice(0, node.size, node.type);
88
88
  refs.set(node, result);
89
89
  return result;
@@ -92,17 +92,18 @@ function clone(node, options, refs) {
92
92
  const result = new ImageData(
93
93
  new Uint8ClampedArray(node.data),
94
94
  node.width,
95
- node.height
95
+ node.height,
96
+ { colorSpace: node.colorSpace }
96
97
  );
97
98
  refs.set(node, result);
98
99
  return result;
99
100
  }
100
- if (typeof URL !== "undefined" && node instanceof URL) {
101
+ if (node instanceof URL) {
101
102
  const result = new URL(node.href);
102
103
  refs.set(node, result);
103
104
  return result;
104
105
  }
105
- if (typeof URLSearchParams !== "undefined" && node instanceof URLSearchParams) {
106
+ if (node instanceof URLSearchParams) {
106
107
  const result = new URLSearchParams();
107
108
  refs.set(node, result);
108
109
  for (const [key, value] of node) {
@@ -186,9 +187,8 @@ function forEachOwnKey(object, fn) {
186
187
  for (const key of Object.keys(object)) {
187
188
  fn(key);
188
189
  }
189
- const symbols = Object.getOwnPropertySymbols(object);
190
- for (let i = 0, l = symbols.length; i < l; i++) {
191
- fn(symbols[i]);
190
+ for (const symbol of Object.getOwnPropertySymbols(object)) {
191
+ fn(symbol);
192
192
  }
193
193
  }
194
194
  function isObject(value) {
@@ -209,11 +209,11 @@ function isUnsafeKey(key) {
209
209
  * High-performance deep clone utility with descriptor support.
210
210
  * Handles circular ref and complex built-in types.
211
211
  *
212
- * @version 1.2.6
212
+ * @version 1.2.8
213
213
  * @author Yusuke Kamiyamane
214
214
  * @license MIT
215
215
  * @copyright Copyright (c) Yusuke Kamiyamane
216
216
  * @see {@link https://github.com/y14e/bunshin-clone}
217
217
  */
218
218
 
219
- module.exports = bunshinClone;
219
+ exports.bunshinClone = bunshinClone;
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
6
+ * @version 1.2.8
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -16,4 +16,4 @@ interface BunshinCloneOptions {
16
16
  type Refs = WeakMap<object, unknown>;
17
17
  declare function bunshinClone<T>(source: T, options?: Partial<BunshinCloneOptions>, refs?: Refs): T;
18
18
 
19
- export { type BunshinCloneOptions, bunshinClone as default };
19
+ export { type BunshinCloneOptions, bunshinClone };
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
6
+ * @version 1.2.8
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -16,4 +16,4 @@ interface BunshinCloneOptions {
16
16
  type Refs = WeakMap<object, unknown>;
17
17
  declare function bunshinClone<T>(source: T, options?: Partial<BunshinCloneOptions>, refs?: Refs): T;
18
18
 
19
- export { type BunshinCloneOptions, bunshinClone as default };
19
+ export { type BunshinCloneOptions, bunshinClone };
package/dist/index.js CHANGED
@@ -78,10 +78,10 @@ function clone(node, options, refs) {
78
78
  refs.set(node, result);
79
79
  return result;
80
80
  }
81
- if (node instanceof Error || typeof DOMException !== "undefined" && node instanceof DOMException) {
81
+ if (node instanceof Error || node instanceof DOMException) {
82
82
  return cloneError(node, options, refs);
83
83
  }
84
- if (typeof Blob !== "undefined" && node instanceof Blob) {
84
+ if (node instanceof Blob) {
85
85
  const result = node.slice(0, node.size, node.type);
86
86
  refs.set(node, result);
87
87
  return result;
@@ -90,17 +90,18 @@ function clone(node, options, refs) {
90
90
  const result = new ImageData(
91
91
  new Uint8ClampedArray(node.data),
92
92
  node.width,
93
- node.height
93
+ node.height,
94
+ { colorSpace: node.colorSpace }
94
95
  );
95
96
  refs.set(node, result);
96
97
  return result;
97
98
  }
98
- if (typeof URL !== "undefined" && node instanceof URL) {
99
+ if (node instanceof URL) {
99
100
  const result = new URL(node.href);
100
101
  refs.set(node, result);
101
102
  return result;
102
103
  }
103
- if (typeof URLSearchParams !== "undefined" && node instanceof URLSearchParams) {
104
+ if (node instanceof URLSearchParams) {
104
105
  const result = new URLSearchParams();
105
106
  refs.set(node, result);
106
107
  for (const [key, value] of node) {
@@ -184,9 +185,8 @@ function forEachOwnKey(object, fn) {
184
185
  for (const key of Object.keys(object)) {
185
186
  fn(key);
186
187
  }
187
- const symbols = Object.getOwnPropertySymbols(object);
188
- for (let i = 0, l = symbols.length; i < l; i++) {
189
- fn(symbols[i]);
188
+ for (const symbol of Object.getOwnPropertySymbols(object)) {
189
+ fn(symbol);
190
190
  }
191
191
  }
192
192
  function isObject(value) {
@@ -207,11 +207,11 @@ function isUnsafeKey(key) {
207
207
  * High-performance deep clone utility with descriptor support.
208
208
  * Handles circular ref and complex built-in types.
209
209
  *
210
- * @version 1.2.6
210
+ * @version 1.2.8
211
211
  * @author Yusuke Kamiyamane
212
212
  * @license MIT
213
213
  * @copyright Copyright (c) Yusuke Kamiyamane
214
214
  * @see {@link https://github.com/y14e/bunshin-clone}
215
215
  */
216
216
 
217
- export { bunshinClone as default };
217
+ export { bunshinClone };
package/package.json CHANGED
@@ -1,28 +1,7 @@
1
1
  {
2
2
  "name": "bunshin-clone",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "High-performance deep clone utility with descriptor support",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
14
- }
15
- },
16
- "files": [
17
- "dist",
18
- "LICENSE",
19
- "README.md"
20
- ],
21
- "scripts": {
22
- "build": "tsup",
23
- "prepublishOnly": "npm run build",
24
- "lint": "tsc --noEmit"
25
- },
26
5
  "keywords": [
27
6
  "array",
28
7
  "buffer",
@@ -53,22 +32,46 @@
53
32
  "structured-clone",
54
33
  "typescript"
55
34
  ],
56
- "author": "Yusuke Kamiyamane",
57
- "license": "MIT",
35
+ "homepage": "https://github.com/y14e/bunshin-clone#readme",
36
+ "bugs": {
37
+ "url": "https://github.com/y14e/bunshin-clone/issues"
38
+ },
58
39
  "repository": {
59
40
  "type": "git",
60
41
  "url": "git+https://github.com/y14e/bunshin-clone.git"
61
42
  },
62
- "bugs": {
63
- "url": "https://github.com/y14e/bunshin-clone/issues"
43
+ "license": "MIT",
44
+ "author": "Yusuke Kamiyamane",
45
+ "type": "module",
46
+ "exports": {
47
+ ".": {
48
+ "types": "./dist/index.d.ts",
49
+ "import": "./dist/index.js",
50
+ "require": "./dist/index.cjs"
51
+ }
52
+ },
53
+ "main": "./dist/index.cjs",
54
+ "module": "./dist/index.js",
55
+ "types": "./dist/index.d.ts",
56
+ "files": [
57
+ "dist",
58
+ "LICENSE",
59
+ "README.md"
60
+ ],
61
+ "scripts": {
62
+ "build": "tsup",
63
+ "lint": "tsc --noEmit",
64
+ "prepublishOnly": "npm run build"
64
65
  },
65
- "homepage": "https://github.com/y14e/bunshin-clone#readme",
66
66
  "devDependencies": {
67
67
  "bun-types": "latest",
68
68
  "tsup": "^8.0.0",
69
- "typescript": "^5.6.0"
69
+ "typescript": "^5.9.3"
70
70
  },
71
71
  "engines": {
72
72
  "node": ">=18"
73
+ },
74
+ "allowScripts": {
75
+ "esbuild": true
73
76
  }
74
77
  }