bunshin-clone 1.0.11 → 1.0.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Bunshin Clone
2
2
 
3
- High-performance deep clone utility with descriptor support. Supports circular references and complex built-in types.
3
+ High-performance deep clone utility with descriptor support. Handles circular ref and complex built-in types.
4
4
 
5
5
  * Fast (no unnecessary overhead)
6
6
  * Deep clone (no structural sharing)
@@ -20,39 +20,30 @@ npm i bunshin-clone
20
20
  // npm
21
21
  import bunshinClone from 'bunshin-clone';
22
22
 
23
- // CDN
23
+ // CDNs
24
+ import bunshinClone from 'https://esm.sh/bunshin-clone'
25
+ // or
24
26
  import bunshinClone from 'https://cdn.jsdelivr.net/npm/bunshin-clone/+esm';
27
+ // or
28
+ import bunshinClone from 'https://unpkg.com/bunshin-clone/dist/index.js';
25
29
  ```
26
30
 
27
31
  ## Usage
28
32
 
29
33
  ```ts
30
- import bunshinClone from 'bunshin-clone';
31
-
32
- const source = { foo: 1, nested: { x: 1 } };
33
-
34
- const result = bunshinClone(source);
35
-
36
- console.log(result);
37
- // { foo: 1, nested: { x: 1 } }
38
-
39
- console.log(result === source); // false
40
- console.log(result.nested === source.nested); // false
41
- ```
42
-
43
- ## API
44
-
45
- ```ts
46
- bunshinClone(target)
47
- bunshinClone(target, options)
34
+ bunshinClone(source, options);
35
+ // => T
36
+ //
37
+ // source: T
38
+ // options (optional): BunshinCloneOptions
48
39
  ```
49
40
 
50
- ## Options
41
+ ### 🪄 Options
51
42
 
52
43
  ```ts
53
- BunshinCloneOptions {
54
- preserveDescriptors: false;
55
- strictDescriptors: false;
44
+ interface BunshinCloneOptions {
45
+ preserveDescriptors?: boolean; // (default: false)
46
+ strictDescriptors?: boolean; // (default: false)
56
47
  }
57
48
  ```
58
49
 
@@ -96,6 +87,20 @@ bunshinClone(obj, { strictDescriptors: true });
96
87
 
97
88
  ---
98
89
 
90
+ ## Example
91
+
92
+ ```ts
93
+ const source = { foo: 1, nested: { x: 1 } };
94
+
95
+ const result = bunshinClone(source);
96
+
97
+ console.log(result);
98
+ // { foo: 1, nested: { x: 1 } }
99
+
100
+ console.log(result === source); // false
101
+ console.log(result.nested === source.nested); // false
102
+ ```
103
+
99
104
  ## Supported Types
100
105
 
101
106
  bunshin-clone correctly handles:
package/dist/index.cjs CHANGED
@@ -185,13 +185,13 @@ function cloneWithDescriptors(node, options, ref) {
185
185
  });
186
186
  return result;
187
187
  }
188
- function forEachOwnKey(object, callback) {
188
+ function forEachOwnKey(object, fn) {
189
189
  for (const key of Object.keys(object)) {
190
- callback(key);
190
+ fn(key);
191
191
  }
192
192
  const symbols = Object.getOwnPropertySymbols(object);
193
193
  for (let i = 0, l = symbols.length; i < l; i++) {
194
- callback(symbols[i]);
194
+ fn(symbols[i]);
195
195
  }
196
196
  }
197
197
  function isObject(value) {
@@ -210,9 +210,9 @@ function isUnsafeKey(key) {
210
210
  /**
211
211
  * Bunshin Clone
212
212
  * High-performance deep clone utility with descriptor support.
213
- * Supports circular ref and complex built-in types.
213
+ * Handles circular ref and complex built-in types.
214
214
  *
215
- * @version 1.0.11
215
+ * @version 1.0.12
216
216
  * @author Yusuke Kamiyamane
217
217
  * @license MIT
218
218
  * @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
- * Supports circular ref and complex built-in types.
4
+ * Handles circular ref and complex built-in types.
5
5
  *
6
- * @version 1.0.11
6
+ * @version 1.0.12
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
- * Supports circular ref and complex built-in types.
4
+ * Handles circular ref and complex built-in types.
5
5
  *
6
- * @version 1.0.11
6
+ * @version 1.0.12
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) 2026 Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -183,13 +183,13 @@ function cloneWithDescriptors(node, options, ref) {
183
183
  });
184
184
  return result;
185
185
  }
186
- function forEachOwnKey(object, callback) {
186
+ function forEachOwnKey(object, fn) {
187
187
  for (const key of Object.keys(object)) {
188
- callback(key);
188
+ fn(key);
189
189
  }
190
190
  const symbols = Object.getOwnPropertySymbols(object);
191
191
  for (let i = 0, l = symbols.length; i < l; i++) {
192
- callback(symbols[i]);
192
+ fn(symbols[i]);
193
193
  }
194
194
  }
195
195
  function isObject(value) {
@@ -208,9 +208,9 @@ function isUnsafeKey(key) {
208
208
  /**
209
209
  * Bunshin Clone
210
210
  * High-performance deep clone utility with descriptor support.
211
- * Supports circular ref and complex built-in types.
211
+ * Handles circular ref and complex built-in types.
212
212
  *
213
- * @version 1.0.11
213
+ * @version 1.0.12
214
214
  * @author Yusuke Kamiyamane
215
215
  * @license MIT
216
216
  * @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.11",
3
+ "version": "1.0.12",
4
4
  "description": "High-performance deep clone utility with descriptor support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",