bunshin-clone 2.0.3 → 2.0.4

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.
@@ -147,11 +147,8 @@ function cloneMap(map, settings, refs) {
147
147
  return result;
148
148
  }
149
149
  var OWN_DESCS = Object.getOwnPropertyDescriptors;
150
- function OWN_ENUM_KEYS(object, symbol) {
151
- return typeof symbol !== "boolean" || !symbol ? OWN_ENUM_STRING_KEYS(object) : [
152
- ...OWN_ENUM_STRING_KEYS(object),
153
- ...OWN_ENUM_SYMBOL_KEYS(object)
154
- ];
150
+ function OWN_ENUM_KEYS(object) {
151
+ return [...OWN_ENUM_STRING_KEYS(object), ...OWN_ENUM_SYMBOL_KEYS(object)];
155
152
  }
156
153
  function OWN_ENUM_STRING_KEYS(object) {
157
154
  const keys = Object.keys(object);
@@ -171,11 +168,8 @@ function OWN_ENUM_SYMBOL_KEYS(object) {
171
168
  }
172
169
  return keys;
173
170
  }
174
- function OWN_KEYS(object, symbol) {
175
- return typeof symbol !== "boolean" || !symbol ? OWN_STRING_KEYS(object) : [
176
- ...OWN_STRING_KEYS(object),
177
- ...OWN_SYMBOL_KEYS(object)
178
- ];
171
+ function OWN_KEYS(object) {
172
+ return [...OWN_STRING_KEYS(object), ...OWN_SYMBOL_KEYS(object)];
179
173
  }
180
174
  function OWN_STRING_KEYS(object) {
181
175
  const keys = Object.getOwnPropertyNames(object);
@@ -195,7 +189,7 @@ function isUnsafeKey(key) {
195
189
  function clonePlainObject(object, settings, refs) {
196
190
  const result = Object.create(Object.getPrototypeOf(object));
197
191
  refs.set(object, result);
198
- for (const key of OWN_ENUM_KEYS(object, settings.preserveSymbolKeys)) {
192
+ for (const key of (!settings.preserveSymbolKeys ? OWN_ENUM_STRING_KEYS : OWN_ENUM_KEYS)(object)) {
199
193
  result[key] = clone(object[key], settings, refs);
200
194
  }
201
195
  return result;
@@ -252,7 +246,9 @@ function cloneWithDescriptors(object, settings, refs) {
252
246
  const result = Object.create(Object.getPrototypeOf(object));
253
247
  refs.set(object, result);
254
248
  const descs = OWN_DESCS(object);
255
- for (const key of OWN_KEYS(object, settings.preserveSymbolKeys)) {
249
+ for (const key of (!settings.preserveSymbolKeys ? OWN_STRING_KEYS : OWN_KEYS)(
250
+ object
251
+ )) {
256
252
  const desc = { ...descs[key] };
257
253
  if ("value" in desc) {
258
254
  desc.value = clone(desc.value, settings, refs);
@@ -145,11 +145,8 @@ function cloneMap(map, settings, refs) {
145
145
  return result;
146
146
  }
147
147
  var OWN_DESCS = Object.getOwnPropertyDescriptors;
148
- function OWN_ENUM_KEYS(object, symbol) {
149
- return typeof symbol !== "boolean" || !symbol ? OWN_ENUM_STRING_KEYS(object) : [
150
- ...OWN_ENUM_STRING_KEYS(object),
151
- ...OWN_ENUM_SYMBOL_KEYS(object)
152
- ];
148
+ function OWN_ENUM_KEYS(object) {
149
+ return [...OWN_ENUM_STRING_KEYS(object), ...OWN_ENUM_SYMBOL_KEYS(object)];
153
150
  }
154
151
  function OWN_ENUM_STRING_KEYS(object) {
155
152
  const keys = Object.keys(object);
@@ -169,11 +166,8 @@ function OWN_ENUM_SYMBOL_KEYS(object) {
169
166
  }
170
167
  return keys;
171
168
  }
172
- function OWN_KEYS(object, symbol) {
173
- return typeof symbol !== "boolean" || !symbol ? OWN_STRING_KEYS(object) : [
174
- ...OWN_STRING_KEYS(object),
175
- ...OWN_SYMBOL_KEYS(object)
176
- ];
169
+ function OWN_KEYS(object) {
170
+ return [...OWN_STRING_KEYS(object), ...OWN_SYMBOL_KEYS(object)];
177
171
  }
178
172
  function OWN_STRING_KEYS(object) {
179
173
  const keys = Object.getOwnPropertyNames(object);
@@ -193,7 +187,7 @@ function isUnsafeKey(key) {
193
187
  function clonePlainObject(object, settings, refs) {
194
188
  const result = Object.create(Object.getPrototypeOf(object));
195
189
  refs.set(object, result);
196
- for (const key of OWN_ENUM_KEYS(object, settings.preserveSymbolKeys)) {
190
+ for (const key of (!settings.preserveSymbolKeys ? OWN_ENUM_STRING_KEYS : OWN_ENUM_KEYS)(object)) {
197
191
  result[key] = clone(object[key], settings, refs);
198
192
  }
199
193
  return result;
@@ -250,7 +244,9 @@ function cloneWithDescriptors(object, settings, refs) {
250
244
  const result = Object.create(Object.getPrototypeOf(object));
251
245
  refs.set(object, result);
252
246
  const descs = OWN_DESCS(object);
253
- for (const key of OWN_KEYS(object, settings.preserveSymbolKeys)) {
247
+ for (const key of (!settings.preserveSymbolKeys ? OWN_STRING_KEYS : OWN_KEYS)(
248
+ object
249
+ )) {
254
250
  const desc = { ...descs[key] };
255
251
  if ("value" in desc) {
256
252
  desc.value = clone(desc.value, settings, refs);
package/dist/index.cjs CHANGED
@@ -151,7 +151,7 @@ function cloneMap(map, settings, refs) {
151
151
  function clonePlainObject(object, settings, refs) {
152
152
  const result = Object.create(Object.getPrototypeOf(object));
153
153
  refs.set(object, result);
154
- for (const key of own.OWN_ENUM_KEYS(object, settings.preserveSymbolKeys)) {
154
+ for (const key of (!settings.preserveSymbolKeys ? own.OWN_ENUM_STRING_KEYS : own.OWN_ENUM_KEYS)(object)) {
155
155
  result[key] = clone(object[key], settings, refs);
156
156
  }
157
157
  return result;
@@ -206,7 +206,9 @@ function cloneWithDescriptors(object, settings, refs) {
206
206
  const result = Object.create(Object.getPrototypeOf(object));
207
207
  refs.set(object, result);
208
208
  const descs = own.OWN_DESCS(object);
209
- for (const key of own.OWN_KEYS(object, settings.preserveSymbolKeys)) {
209
+ for (const key of (!settings.preserveSymbolKeys ? own.OWN_STRING_KEYS : own.OWN_KEYS)(
210
+ object
211
+ )) {
210
212
  const desc = { ...descs[key] };
211
213
  if ("value" in desc) {
212
214
  desc.value = clone(desc.value, settings, refs);
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { OWN_DESCS, OWN_KEYS, OWN_ENUM_KEYS } from '@y14e/own';
1
+ import { OWN_DESCS, OWN_STRING_KEYS, OWN_KEYS, OWN_ENUM_STRING_KEYS, OWN_ENUM_KEYS } from '@y14e/own';
2
2
 
3
3
  // src/utils.ts
4
4
  function isObject(value) {
@@ -149,7 +149,7 @@ function cloneMap(map, settings, refs) {
149
149
  function clonePlainObject(object, settings, refs) {
150
150
  const result = Object.create(Object.getPrototypeOf(object));
151
151
  refs.set(object, result);
152
- for (const key of OWN_ENUM_KEYS(object, settings.preserveSymbolKeys)) {
152
+ for (const key of (!settings.preserveSymbolKeys ? OWN_ENUM_STRING_KEYS : OWN_ENUM_KEYS)(object)) {
153
153
  result[key] = clone(object[key], settings, refs);
154
154
  }
155
155
  return result;
@@ -204,7 +204,9 @@ function cloneWithDescriptors(object, settings, refs) {
204
204
  const result = Object.create(Object.getPrototypeOf(object));
205
205
  refs.set(object, result);
206
206
  const descs = OWN_DESCS(object);
207
- for (const key of OWN_KEYS(object, settings.preserveSymbolKeys)) {
207
+ for (const key of (!settings.preserveSymbolKeys ? OWN_STRING_KEYS : OWN_KEYS)(
208
+ object
209
+ )) {
208
210
  const desc = { ...descs[key] };
209
211
  if ("value" in desc) {
210
212
  desc.value = clone(desc.value, settings, refs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunshin-clone",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "High-performance deep clone utility with descriptor support",
5
5
  "keywords": [
6
6
  "array",
@@ -81,6 +81,6 @@
81
81
  "esbuild": true
82
82
  },
83
83
  "dependencies": {
84
- "@y14e/own": "^1.0.2"
84
+ "@y14e/own": "^1.0.3"
85
85
  }
86
86
  }