bunshin-clone 1.7.1 → 1.7.2

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/dist/index.cjs CHANGED
@@ -18,7 +18,7 @@ function clone(value, settings, refs) {
18
18
  return cloneWithDescriptors(value, settings, refs);
19
19
  }
20
20
  if (Array.isArray(value)) {
21
- if (isShallowClonableArray(value)) {
21
+ if (isShallowArray(value)) {
22
22
  const result2 = value.slice();
23
23
  refs.set(value, result2);
24
24
  return result2;
@@ -209,14 +209,6 @@ function createErrorInstance(error, settings, refs) {
209
209
  result.name = name;
210
210
  return result;
211
211
  }
212
- function isShallowClonableArray(array) {
213
- for (let i = 0, l = array.length; i < l; i++) {
214
- if (isObject(array[i])) {
215
- return false;
216
- }
217
- }
218
- return true;
219
- }
220
212
  function forEachOwnKey(object, callback) {
221
213
  for (const key of Object.keys(object)) {
222
214
  callback(key);
@@ -235,6 +227,14 @@ function isPlainObject(value) {
235
227
  const proto = Object.getPrototypeOf(value);
236
228
  return proto === Object.prototype || proto === null;
237
229
  }
230
+ function isShallowArray(array) {
231
+ for (let i = 0, l = array.length; i < l; i++) {
232
+ if (isObject(array[i])) {
233
+ return false;
234
+ }
235
+ }
236
+ return true;
237
+ }
238
238
  function isUnsafeKey(key) {
239
239
  return typeof key === "string" && (key === "__proto__" || key === "prototype" || key === "constructor");
240
240
  }
@@ -263,4 +263,5 @@ exports.bunshinClone = bunshinClone;
263
263
  exports.forEachOwnKey = forEachOwnKey;
264
264
  exports.isObject = isObject;
265
265
  exports.isPlainObject = isPlainObject;
266
+ exports.isShallowArray = isShallowArray;
266
267
  exports.isUnsafeKey = isUnsafeKey;
package/dist/index.d.cts CHANGED
@@ -9,6 +9,7 @@ declare function bunshinClone<T>(value: T, options?: Partial<BunshinCloneOptions
9
9
  declare function forEachOwnKey(object: PlainObject, callback: (key: string | symbol) => void): void;
10
10
  declare function isObject(value: unknown): value is object;
11
11
  declare function isPlainObject(value: unknown): value is PlainObject;
12
+ declare function isShallowArray(array: unknown[]): boolean;
12
13
  declare function isUnsafeKey(key: PropertyKey): boolean;
13
14
 
14
- export { type BunshinCloneOptions, bunshinClone, forEachOwnKey, isObject, isPlainObject, isUnsafeKey };
15
+ export { type BunshinCloneOptions, bunshinClone, forEachOwnKey, isObject, isPlainObject, isShallowArray, isUnsafeKey };
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ declare function bunshinClone<T>(value: T, options?: Partial<BunshinCloneOptions
9
9
  declare function forEachOwnKey(object: PlainObject, callback: (key: string | symbol) => void): void;
10
10
  declare function isObject(value: unknown): value is object;
11
11
  declare function isPlainObject(value: unknown): value is PlainObject;
12
+ declare function isShallowArray(array: unknown[]): boolean;
12
13
  declare function isUnsafeKey(key: PropertyKey): boolean;
13
14
 
14
- export { type BunshinCloneOptions, bunshinClone, forEachOwnKey, isObject, isPlainObject, isUnsafeKey };
15
+ export { type BunshinCloneOptions, bunshinClone, forEachOwnKey, isObject, isPlainObject, isShallowArray, isUnsafeKey };
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ function clone(value, settings, refs) {
16
16
  return cloneWithDescriptors(value, settings, refs);
17
17
  }
18
18
  if (Array.isArray(value)) {
19
- if (isShallowClonableArray(value)) {
19
+ if (isShallowArray(value)) {
20
20
  const result2 = value.slice();
21
21
  refs.set(value, result2);
22
22
  return result2;
@@ -207,14 +207,6 @@ function createErrorInstance(error, settings, refs) {
207
207
  result.name = name;
208
208
  return result;
209
209
  }
210
- function isShallowClonableArray(array) {
211
- for (let i = 0, l = array.length; i < l; i++) {
212
- if (isObject(array[i])) {
213
- return false;
214
- }
215
- }
216
- return true;
217
- }
218
210
  function forEachOwnKey(object, callback) {
219
211
  for (const key of Object.keys(object)) {
220
212
  callback(key);
@@ -233,6 +225,14 @@ function isPlainObject(value) {
233
225
  const proto = Object.getPrototypeOf(value);
234
226
  return proto === Object.prototype || proto === null;
235
227
  }
228
+ function isShallowArray(array) {
229
+ for (let i = 0, l = array.length; i < l; i++) {
230
+ if (isObject(array[i])) {
231
+ return false;
232
+ }
233
+ }
234
+ return true;
235
+ }
236
236
  function isUnsafeKey(key) {
237
237
  return typeof key === "string" && (key === "__proto__" || key === "prototype" || key === "constructor");
238
238
  }
@@ -257,4 +257,4 @@ function resolveOptions(options) {
257
257
  return { preserveBufferSharing, preserveDescriptors, strictDescriptors };
258
258
  }
259
259
 
260
- export { bunshinClone, forEachOwnKey, isObject, isPlainObject, isUnsafeKey };
260
+ export { bunshinClone, forEachOwnKey, isObject, isPlainObject, isShallowArray, isUnsafeKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunshin-clone",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "High-performance deep clone utility with descriptor support",
5
5
  "keywords": [
6
6
  "array",