bunshin-clone 1.2.9 → 1.2.11

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
@@ -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.9';
16
+ import { bunshinClone } from 'https://esm.sh/bunshin-clone@1.2.11';
17
17
  // or
18
- import { bunshinClone } from 'https://cdn.jsdelivr.net/npm/bunshin-clone@1.2.9/+esm';
18
+ import { bunshinClone } from 'https://cdn.jsdelivr.net/npm/bunshin-clone@1.2.11/+esm';
19
19
  // or
20
- import { bunshinClone } from 'https://esm.unpkg.com/bunshin-clone@1.2.9';
20
+ import { bunshinClone } from 'https://esm.unpkg.com/bunshin-clone@1.2.11';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
package/dist/index.cjs CHANGED
@@ -28,27 +28,27 @@ function clone(node, options, refs) {
28
28
  if (isPlainObject(node)) {
29
29
  const result = Object.create(Object.getPrototypeOf(node));
30
30
  refs.set(node, result);
31
- for (const k in node) {
32
- if (!HAS_OWN.call(node, k) || isUnsafeKey(k)) {
31
+ for (const key in node) {
32
+ if (!HAS_OWN.call(node, key) || isUnsafeKey(key)) {
33
33
  continue;
34
34
  }
35
- result[k] = clone(node[k], options, refs);
35
+ result[key] = clone(node[key], options, refs);
36
36
  }
37
37
  return result;
38
38
  }
39
39
  if (node instanceof Map) {
40
40
  const result = /* @__PURE__ */ new Map();
41
41
  refs.set(node, result);
42
- for (const [k, v] of node) {
43
- result.set(clone(k, options, refs), clone(v, options, refs));
42
+ for (const [key, value] of node) {
43
+ result.set(clone(key, options, refs), clone(value, options, refs));
44
44
  }
45
45
  return result;
46
46
  }
47
47
  if (node instanceof Set) {
48
48
  const result = /* @__PURE__ */ new Set();
49
49
  refs.set(node, result);
50
- for (const i of node) {
51
- result.add(clone(i, options, refs));
50
+ for (const item of node) {
51
+ result.add(clone(item, options, refs));
52
52
  }
53
53
  return result;
54
54
  }
@@ -104,8 +104,8 @@ function clone(node, options, refs) {
104
104
  if (node instanceof URLSearchParams) {
105
105
  const result = new URLSearchParams();
106
106
  refs.set(node, result);
107
- for (const [k, v] of node) {
108
- result.append(k, v);
107
+ for (const [key, value] of node) {
108
+ result.append(key, value);
109
109
  }
110
110
  return result;
111
111
  }
@@ -153,8 +153,8 @@ function cloneError(value, options, refs) {
153
153
  if ("cause" in value && cause !== void 0) {
154
154
  result.cause = clone(cause, options, refs);
155
155
  }
156
- for (const k of Object.keys(value)) {
157
- result[k] = clone(value[k], options, refs);
156
+ for (const key of Object.keys(value)) {
157
+ result[key] = clone(value[key], options, refs);
158
158
  }
159
159
  return result;
160
160
  }
@@ -162,16 +162,16 @@ function cloneWithDescriptors(node, options, refs) {
162
162
  const result = Object.create(Object.getPrototypeOf(node));
163
163
  refs.set(node, result);
164
164
  const descs = Object.getOwnPropertyDescriptors(node);
165
- forEachOwnKey(descs, (k) => {
166
- if (isUnsafeKey(k)) {
165
+ forEachOwnKey(descs, (key) => {
166
+ if (isUnsafeKey(key)) {
167
167
  return;
168
168
  }
169
- const desc = { ...descs[k] };
169
+ const desc = { ...descs[key] };
170
170
  if ("value" in desc) {
171
171
  desc.value = clone(desc.value, options, refs);
172
172
  }
173
173
  try {
174
- Object.defineProperty(result, k, desc);
174
+ Object.defineProperty(result, key, desc);
175
175
  } catch (error) {
176
176
  if (options.strictDescriptors) {
177
177
  throw error;
@@ -181,11 +181,11 @@ function cloneWithDescriptors(node, options, refs) {
181
181
  return result;
182
182
  }
183
183
  function forEachOwnKey(object, fn) {
184
- for (const k of Object.keys(object)) {
185
- fn(k);
184
+ for (const key of Object.keys(object)) {
185
+ fn(key);
186
186
  }
187
- for (const s of Object.getOwnPropertySymbols(object)) {
188
- fn(s);
187
+ for (const symbol of Object.getOwnPropertySymbols(object)) {
188
+ fn(symbol);
189
189
  }
190
190
  }
191
191
  function isObject(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.9
209
+ * @version 1.2.11
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.9
6
+ * @version 1.2.11
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
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.9
6
+ * @version 1.2.11
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -26,27 +26,27 @@ function clone(node, options, refs) {
26
26
  if (isPlainObject(node)) {
27
27
  const result = Object.create(Object.getPrototypeOf(node));
28
28
  refs.set(node, result);
29
- for (const k in node) {
30
- if (!HAS_OWN.call(node, k) || isUnsafeKey(k)) {
29
+ for (const key in node) {
30
+ if (!HAS_OWN.call(node, key) || isUnsafeKey(key)) {
31
31
  continue;
32
32
  }
33
- result[k] = clone(node[k], options, refs);
33
+ result[key] = clone(node[key], options, refs);
34
34
  }
35
35
  return result;
36
36
  }
37
37
  if (node instanceof Map) {
38
38
  const result = /* @__PURE__ */ new Map();
39
39
  refs.set(node, result);
40
- for (const [k, v] of node) {
41
- result.set(clone(k, options, refs), clone(v, options, refs));
40
+ for (const [key, value] of node) {
41
+ result.set(clone(key, options, refs), clone(value, options, refs));
42
42
  }
43
43
  return result;
44
44
  }
45
45
  if (node instanceof Set) {
46
46
  const result = /* @__PURE__ */ new Set();
47
47
  refs.set(node, result);
48
- for (const i of node) {
49
- result.add(clone(i, options, refs));
48
+ for (const item of node) {
49
+ result.add(clone(item, options, refs));
50
50
  }
51
51
  return result;
52
52
  }
@@ -102,8 +102,8 @@ function clone(node, options, refs) {
102
102
  if (node instanceof URLSearchParams) {
103
103
  const result = new URLSearchParams();
104
104
  refs.set(node, result);
105
- for (const [k, v] of node) {
106
- result.append(k, v);
105
+ for (const [key, value] of node) {
106
+ result.append(key, value);
107
107
  }
108
108
  return result;
109
109
  }
@@ -151,8 +151,8 @@ function cloneError(value, options, refs) {
151
151
  if ("cause" in value && cause !== void 0) {
152
152
  result.cause = clone(cause, options, refs);
153
153
  }
154
- for (const k of Object.keys(value)) {
155
- result[k] = clone(value[k], options, refs);
154
+ for (const key of Object.keys(value)) {
155
+ result[key] = clone(value[key], options, refs);
156
156
  }
157
157
  return result;
158
158
  }
@@ -160,16 +160,16 @@ function cloneWithDescriptors(node, options, refs) {
160
160
  const result = Object.create(Object.getPrototypeOf(node));
161
161
  refs.set(node, result);
162
162
  const descs = Object.getOwnPropertyDescriptors(node);
163
- forEachOwnKey(descs, (k) => {
164
- if (isUnsafeKey(k)) {
163
+ forEachOwnKey(descs, (key) => {
164
+ if (isUnsafeKey(key)) {
165
165
  return;
166
166
  }
167
- const desc = { ...descs[k] };
167
+ const desc = { ...descs[key] };
168
168
  if ("value" in desc) {
169
169
  desc.value = clone(desc.value, options, refs);
170
170
  }
171
171
  try {
172
- Object.defineProperty(result, k, desc);
172
+ Object.defineProperty(result, key, desc);
173
173
  } catch (error) {
174
174
  if (options.strictDescriptors) {
175
175
  throw error;
@@ -179,11 +179,11 @@ function cloneWithDescriptors(node, options, refs) {
179
179
  return result;
180
180
  }
181
181
  function forEachOwnKey(object, fn) {
182
- for (const k of Object.keys(object)) {
183
- fn(k);
182
+ for (const key of Object.keys(object)) {
183
+ fn(key);
184
184
  }
185
- for (const s of Object.getOwnPropertySymbols(object)) {
186
- fn(s);
185
+ for (const symbol of Object.getOwnPropertySymbols(object)) {
186
+ fn(symbol);
187
187
  }
188
188
  }
189
189
  function isObject(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.9
207
+ * @version 1.2.11
208
208
  * @author Yusuke Kamiyamane
209
209
  * @license MIT
210
210
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunshin-clone",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "High-performance deep clone utility with descriptor support",
5
5
  "keywords": [
6
6
  "array",