@bemoje/object 2.2.3 → 3.0.1
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/lib/index.cjs +22 -92
- package/lib/index.js +22 -92
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -19,9 +19,7 @@ function createArrayMerger(predicate) {
|
|
|
19
19
|
__name(createArrayMerger, "createArrayMerger");
|
|
20
20
|
|
|
21
21
|
// src/arrAssign.ts
|
|
22
|
-
var arrAssign = createArrayMerger((value) =>
|
|
23
|
-
return value != null;
|
|
24
|
-
});
|
|
22
|
+
var arrAssign = createArrayMerger((value) => value != null);
|
|
25
23
|
|
|
26
24
|
// src/className.ts
|
|
27
25
|
function className(target) {
|
|
@@ -221,79 +219,27 @@ function getKeysPreset(options) {
|
|
|
221
219
|
const ignore = new Set(options?.ignore);
|
|
222
220
|
if (options?.ignoreSymbols) {
|
|
223
221
|
if (options?.ignoreEnumerable) {
|
|
224
|
-
return (o) =>
|
|
225
|
-
return Object.getOwnPropertyNames(o).filter((k) => {
|
|
226
|
-
return !isEnumerable(o, k);
|
|
227
|
-
}).filter((k) => {
|
|
228
|
-
return !ignore.has(k);
|
|
229
|
-
});
|
|
230
|
-
};
|
|
222
|
+
return (o) => Object.getOwnPropertyNames(o).filter((k) => !isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
231
223
|
} else if (options?.ignoreNonEnumerable) {
|
|
232
|
-
return (o) =>
|
|
233
|
-
return Object.keys(o).filter((k) => {
|
|
234
|
-
return !ignore.has(k);
|
|
235
|
-
});
|
|
236
|
-
};
|
|
224
|
+
return (o) => Object.keys(o).filter((k) => !ignore.has(k));
|
|
237
225
|
} else {
|
|
238
|
-
return (o) =>
|
|
239
|
-
return Object.getOwnPropertyNames(o).filter((k) => {
|
|
240
|
-
return !ignore.has(k);
|
|
241
|
-
});
|
|
242
|
-
};
|
|
226
|
+
return (o) => Object.getOwnPropertyNames(o).filter((k) => !ignore.has(k));
|
|
243
227
|
}
|
|
244
228
|
} else if (options?.ignoreStrings) {
|
|
245
229
|
if (options?.ignoreEnumerable) {
|
|
246
|
-
return (o) =>
|
|
247
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
248
|
-
return typeof k !== "string";
|
|
249
|
-
}).filter((k) => {
|
|
250
|
-
return !isEnumerable(o, k);
|
|
251
|
-
}).filter((k) => {
|
|
252
|
-
return !ignore.has(k);
|
|
253
|
-
});
|
|
254
|
-
};
|
|
230
|
+
return (o) => Reflect.ownKeys(o).filter((k) => typeof k !== "string").filter((k) => !isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
255
231
|
} else if (options?.ignoreNonEnumerable) {
|
|
256
|
-
return (o) =>
|
|
257
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
258
|
-
return typeof k !== "string";
|
|
259
|
-
}).filter((k) => {
|
|
260
|
-
return isEnumerable(o, k);
|
|
261
|
-
}).filter((k) => {
|
|
262
|
-
return !ignore.has(k);
|
|
263
|
-
});
|
|
264
|
-
};
|
|
232
|
+
return (o) => Reflect.ownKeys(o).filter((k) => typeof k !== "string").filter((k) => isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
265
233
|
} else {
|
|
266
|
-
return (o) =>
|
|
267
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
268
|
-
return typeof k !== "string";
|
|
269
|
-
}).filter((k) => {
|
|
270
|
-
return !ignore.has(k);
|
|
271
|
-
});
|
|
272
|
-
};
|
|
234
|
+
return (o) => Reflect.ownKeys(o).filter((k) => typeof k !== "string").filter((k) => !ignore.has(k));
|
|
273
235
|
}
|
|
274
236
|
} else {
|
|
275
237
|
if (options?.ignoreEnumerable) {
|
|
276
|
-
return (o) =>
|
|
277
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
278
|
-
return !isEnumerable(o, k);
|
|
279
|
-
}).filter((k) => {
|
|
280
|
-
return !ignore.has(k);
|
|
281
|
-
});
|
|
282
|
-
};
|
|
238
|
+
return (o) => Reflect.ownKeys(o).filter((k) => !isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
283
239
|
} else if (options?.ignoreNonEnumerable) {
|
|
284
|
-
return (o) =>
|
|
285
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
286
|
-
return isEnumerable(o, k);
|
|
287
|
-
}).filter((k) => {
|
|
288
|
-
return !ignore.has(k);
|
|
289
|
-
});
|
|
290
|
-
};
|
|
240
|
+
return (o) => Reflect.ownKeys(o).filter((k) => isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
291
241
|
} else {
|
|
292
|
-
return (o) =>
|
|
293
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
294
|
-
return !ignore.has(k);
|
|
295
|
-
});
|
|
296
|
-
};
|
|
242
|
+
return (o) => Reflect.ownKeys(o).filter((k) => !ignore.has(k));
|
|
297
243
|
}
|
|
298
244
|
}
|
|
299
245
|
}
|
|
@@ -351,9 +297,7 @@ __name(hasOwnProperty, "hasOwnProperty");
|
|
|
351
297
|
|
|
352
298
|
// src/hasPrototypeChainProperty.ts
|
|
353
299
|
function hasPrototypeChainProperty(object, key) {
|
|
354
|
-
return getClassChain(object).some((ctor) =>
|
|
355
|
-
return hasOwnProperty(ctor.prototype, key);
|
|
356
|
-
});
|
|
300
|
+
return getClassChain(object).some((ctor) => hasOwnProperty(ctor.prototype, key));
|
|
357
301
|
}
|
|
358
302
|
__name(hasPrototypeChainProperty, "hasPrototypeChainProperty");
|
|
359
303
|
|
|
@@ -466,9 +410,7 @@ function* iterateObject(root) {
|
|
|
466
410
|
value: current,
|
|
467
411
|
root,
|
|
468
412
|
propertyPathArray,
|
|
469
|
-
propertyPath: propertyPathArray.map((s) => {
|
|
470
|
-
return typeof s === "string" ? s : `[${s}]`;
|
|
471
|
-
}).join(".").replaceAll(".[", "["),
|
|
413
|
+
propertyPath: propertyPathArray.map((s) => typeof s === "string" ? s : `[${s}]`).join(".").replaceAll(".[", "["),
|
|
472
414
|
isLeaf: false,
|
|
473
415
|
nodeType: Array.isArray(current) ? "array" : "object"
|
|
474
416
|
};
|
|
@@ -499,9 +441,7 @@ function* iterateObject(root) {
|
|
|
499
441
|
key: propertyPathArray[propertyPathArray.length - 1],
|
|
500
442
|
root,
|
|
501
443
|
propertyPathArray,
|
|
502
|
-
propertyPath: propertyPathArray.map((s) => {
|
|
503
|
-
return typeof s === "string" ? s : `[${s}]`;
|
|
504
|
-
}).join(".").replaceAll(".[", "["),
|
|
444
|
+
propertyPath: propertyPathArray.map((s) => typeof s === "string" ? s : `[${s}]`).join(".").replaceAll(".[", "["),
|
|
505
445
|
isLeaf: true,
|
|
506
446
|
nodeType: "object"
|
|
507
447
|
};
|
|
@@ -532,9 +472,7 @@ function mapObjectKeys(obj, fn) {
|
|
|
532
472
|
__name(mapObjectKeys, "mapObjectKeys");
|
|
533
473
|
|
|
534
474
|
// src/objAssign.ts
|
|
535
|
-
var objAssign = createObjectMerger((value) =>
|
|
536
|
-
return value != null;
|
|
537
|
-
});
|
|
475
|
+
var objAssign = createObjectMerger((value) => value != null);
|
|
538
476
|
|
|
539
477
|
// src/objDeepFreeze.ts
|
|
540
478
|
function objDeepFreeze(o) {
|
|
@@ -550,13 +488,11 @@ __name(objDeepFreeze, "objDeepFreeze");
|
|
|
550
488
|
|
|
551
489
|
// src/objDefineLazyProperty.ts
|
|
552
490
|
function objDefineLazyProperty(object, key, getValue) {
|
|
553
|
-
const set = /* @__PURE__ */ __name((value) => {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
});
|
|
559
|
-
}, "set");
|
|
491
|
+
const set = /* @__PURE__ */ __name((value) => Object.defineProperty(object, key, {
|
|
492
|
+
value,
|
|
493
|
+
enumerable: true,
|
|
494
|
+
writable: true
|
|
495
|
+
}), "set");
|
|
560
496
|
Object.defineProperty(object, key, {
|
|
561
497
|
configurable: true,
|
|
562
498
|
enumerable: true,
|
|
@@ -631,9 +567,7 @@ function objPropertyValueToGetter(object, ...propertyNames) {
|
|
|
631
567
|
Object.defineProperty(object, propertyName, {
|
|
632
568
|
enumerable,
|
|
633
569
|
configurable,
|
|
634
|
-
get: /* @__PURE__ */ __name(() =>
|
|
635
|
-
return value;
|
|
636
|
-
}, "get")
|
|
570
|
+
get: /* @__PURE__ */ __name(() => value, "get")
|
|
637
571
|
});
|
|
638
572
|
}
|
|
639
573
|
return object;
|
|
@@ -658,9 +592,7 @@ function objSortKeys(o, compare) {
|
|
|
658
592
|
if (compare) {
|
|
659
593
|
entries.sort(compare);
|
|
660
594
|
} else {
|
|
661
|
-
entries.sort((a, b) =>
|
|
662
|
-
return a[0].localeCompare(b[0]);
|
|
663
|
-
});
|
|
595
|
+
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
664
596
|
}
|
|
665
597
|
return Object.fromEntries(entries);
|
|
666
598
|
}
|
|
@@ -774,9 +706,7 @@ __name(sortKeysLike, "sortKeysLike");
|
|
|
774
706
|
// src/staticClassKeysOf.ts
|
|
775
707
|
function staticClassKeysOf(cls) {
|
|
776
708
|
const keys = Object.getOwnPropertyNames(cls);
|
|
777
|
-
return keys.filter((key) =>
|
|
778
|
-
return !ignoreKeys.includes(key);
|
|
779
|
-
});
|
|
709
|
+
return keys.filter((key) => !ignoreKeys.includes(key));
|
|
780
710
|
}
|
|
781
711
|
__name(staticClassKeysOf, "staticClassKeysOf");
|
|
782
712
|
var ignoreKeys = [
|
package/lib/index.js
CHANGED
|
@@ -17,9 +17,7 @@ function createArrayMerger(predicate) {
|
|
|
17
17
|
__name(createArrayMerger, "createArrayMerger");
|
|
18
18
|
|
|
19
19
|
// src/arrAssign.ts
|
|
20
|
-
var arrAssign = createArrayMerger((value) =>
|
|
21
|
-
return value != null;
|
|
22
|
-
});
|
|
20
|
+
var arrAssign = createArrayMerger((value) => value != null);
|
|
23
21
|
|
|
24
22
|
// src/className.ts
|
|
25
23
|
function className(target) {
|
|
@@ -219,79 +217,27 @@ function getKeysPreset(options) {
|
|
|
219
217
|
const ignore = new Set(options?.ignore);
|
|
220
218
|
if (options?.ignoreSymbols) {
|
|
221
219
|
if (options?.ignoreEnumerable) {
|
|
222
|
-
return (o) =>
|
|
223
|
-
return Object.getOwnPropertyNames(o).filter((k) => {
|
|
224
|
-
return !isEnumerable(o, k);
|
|
225
|
-
}).filter((k) => {
|
|
226
|
-
return !ignore.has(k);
|
|
227
|
-
});
|
|
228
|
-
};
|
|
220
|
+
return (o) => Object.getOwnPropertyNames(o).filter((k) => !isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
229
221
|
} else if (options?.ignoreNonEnumerable) {
|
|
230
|
-
return (o) =>
|
|
231
|
-
return Object.keys(o).filter((k) => {
|
|
232
|
-
return !ignore.has(k);
|
|
233
|
-
});
|
|
234
|
-
};
|
|
222
|
+
return (o) => Object.keys(o).filter((k) => !ignore.has(k));
|
|
235
223
|
} else {
|
|
236
|
-
return (o) =>
|
|
237
|
-
return Object.getOwnPropertyNames(o).filter((k) => {
|
|
238
|
-
return !ignore.has(k);
|
|
239
|
-
});
|
|
240
|
-
};
|
|
224
|
+
return (o) => Object.getOwnPropertyNames(o).filter((k) => !ignore.has(k));
|
|
241
225
|
}
|
|
242
226
|
} else if (options?.ignoreStrings) {
|
|
243
227
|
if (options?.ignoreEnumerable) {
|
|
244
|
-
return (o) =>
|
|
245
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
246
|
-
return typeof k !== "string";
|
|
247
|
-
}).filter((k) => {
|
|
248
|
-
return !isEnumerable(o, k);
|
|
249
|
-
}).filter((k) => {
|
|
250
|
-
return !ignore.has(k);
|
|
251
|
-
});
|
|
252
|
-
};
|
|
228
|
+
return (o) => Reflect.ownKeys(o).filter((k) => typeof k !== "string").filter((k) => !isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
253
229
|
} else if (options?.ignoreNonEnumerable) {
|
|
254
|
-
return (o) =>
|
|
255
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
256
|
-
return typeof k !== "string";
|
|
257
|
-
}).filter((k) => {
|
|
258
|
-
return isEnumerable(o, k);
|
|
259
|
-
}).filter((k) => {
|
|
260
|
-
return !ignore.has(k);
|
|
261
|
-
});
|
|
262
|
-
};
|
|
230
|
+
return (o) => Reflect.ownKeys(o).filter((k) => typeof k !== "string").filter((k) => isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
263
231
|
} else {
|
|
264
|
-
return (o) =>
|
|
265
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
266
|
-
return typeof k !== "string";
|
|
267
|
-
}).filter((k) => {
|
|
268
|
-
return !ignore.has(k);
|
|
269
|
-
});
|
|
270
|
-
};
|
|
232
|
+
return (o) => Reflect.ownKeys(o).filter((k) => typeof k !== "string").filter((k) => !ignore.has(k));
|
|
271
233
|
}
|
|
272
234
|
} else {
|
|
273
235
|
if (options?.ignoreEnumerable) {
|
|
274
|
-
return (o) =>
|
|
275
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
276
|
-
return !isEnumerable(o, k);
|
|
277
|
-
}).filter((k) => {
|
|
278
|
-
return !ignore.has(k);
|
|
279
|
-
});
|
|
280
|
-
};
|
|
236
|
+
return (o) => Reflect.ownKeys(o).filter((k) => !isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
281
237
|
} else if (options?.ignoreNonEnumerable) {
|
|
282
|
-
return (o) =>
|
|
283
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
284
|
-
return isEnumerable(o, k);
|
|
285
|
-
}).filter((k) => {
|
|
286
|
-
return !ignore.has(k);
|
|
287
|
-
});
|
|
288
|
-
};
|
|
238
|
+
return (o) => Reflect.ownKeys(o).filter((k) => isEnumerable(o, k)).filter((k) => !ignore.has(k));
|
|
289
239
|
} else {
|
|
290
|
-
return (o) =>
|
|
291
|
-
return Reflect.ownKeys(o).filter((k) => {
|
|
292
|
-
return !ignore.has(k);
|
|
293
|
-
});
|
|
294
|
-
};
|
|
240
|
+
return (o) => Reflect.ownKeys(o).filter((k) => !ignore.has(k));
|
|
295
241
|
}
|
|
296
242
|
}
|
|
297
243
|
}
|
|
@@ -349,9 +295,7 @@ __name(hasOwnProperty, "hasOwnProperty");
|
|
|
349
295
|
|
|
350
296
|
// src/hasPrototypeChainProperty.ts
|
|
351
297
|
function hasPrototypeChainProperty(object, key) {
|
|
352
|
-
return getClassChain(object).some((ctor) =>
|
|
353
|
-
return hasOwnProperty(ctor.prototype, key);
|
|
354
|
-
});
|
|
298
|
+
return getClassChain(object).some((ctor) => hasOwnProperty(ctor.prototype, key));
|
|
355
299
|
}
|
|
356
300
|
__name(hasPrototypeChainProperty, "hasPrototypeChainProperty");
|
|
357
301
|
|
|
@@ -464,9 +408,7 @@ function* iterateObject(root) {
|
|
|
464
408
|
value: current,
|
|
465
409
|
root,
|
|
466
410
|
propertyPathArray,
|
|
467
|
-
propertyPath: propertyPathArray.map((s) => {
|
|
468
|
-
return typeof s === "string" ? s : `[${s}]`;
|
|
469
|
-
}).join(".").replaceAll(".[", "["),
|
|
411
|
+
propertyPath: propertyPathArray.map((s) => typeof s === "string" ? s : `[${s}]`).join(".").replaceAll(".[", "["),
|
|
470
412
|
isLeaf: false,
|
|
471
413
|
nodeType: Array.isArray(current) ? "array" : "object"
|
|
472
414
|
};
|
|
@@ -497,9 +439,7 @@ function* iterateObject(root) {
|
|
|
497
439
|
key: propertyPathArray[propertyPathArray.length - 1],
|
|
498
440
|
root,
|
|
499
441
|
propertyPathArray,
|
|
500
|
-
propertyPath: propertyPathArray.map((s) => {
|
|
501
|
-
return typeof s === "string" ? s : `[${s}]`;
|
|
502
|
-
}).join(".").replaceAll(".[", "["),
|
|
442
|
+
propertyPath: propertyPathArray.map((s) => typeof s === "string" ? s : `[${s}]`).join(".").replaceAll(".[", "["),
|
|
503
443
|
isLeaf: true,
|
|
504
444
|
nodeType: "object"
|
|
505
445
|
};
|
|
@@ -530,9 +470,7 @@ function mapObjectKeys(obj, fn) {
|
|
|
530
470
|
__name(mapObjectKeys, "mapObjectKeys");
|
|
531
471
|
|
|
532
472
|
// src/objAssign.ts
|
|
533
|
-
var objAssign = createObjectMerger((value) =>
|
|
534
|
-
return value != null;
|
|
535
|
-
});
|
|
473
|
+
var objAssign = createObjectMerger((value) => value != null);
|
|
536
474
|
|
|
537
475
|
// src/objDeepFreeze.ts
|
|
538
476
|
function objDeepFreeze(o) {
|
|
@@ -548,13 +486,11 @@ __name(objDeepFreeze, "objDeepFreeze");
|
|
|
548
486
|
|
|
549
487
|
// src/objDefineLazyProperty.ts
|
|
550
488
|
function objDefineLazyProperty(object, key, getValue) {
|
|
551
|
-
const set = /* @__PURE__ */ __name((value) => {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
});
|
|
557
|
-
}, "set");
|
|
489
|
+
const set = /* @__PURE__ */ __name((value) => Object.defineProperty(object, key, {
|
|
490
|
+
value,
|
|
491
|
+
enumerable: true,
|
|
492
|
+
writable: true
|
|
493
|
+
}), "set");
|
|
558
494
|
Object.defineProperty(object, key, {
|
|
559
495
|
configurable: true,
|
|
560
496
|
enumerable: true,
|
|
@@ -629,9 +565,7 @@ function objPropertyValueToGetter(object, ...propertyNames) {
|
|
|
629
565
|
Object.defineProperty(object, propertyName, {
|
|
630
566
|
enumerable,
|
|
631
567
|
configurable,
|
|
632
|
-
get: /* @__PURE__ */ __name(() =>
|
|
633
|
-
return value;
|
|
634
|
-
}, "get")
|
|
568
|
+
get: /* @__PURE__ */ __name(() => value, "get")
|
|
635
569
|
});
|
|
636
570
|
}
|
|
637
571
|
return object;
|
|
@@ -656,9 +590,7 @@ function objSortKeys(o, compare) {
|
|
|
656
590
|
if (compare) {
|
|
657
591
|
entries.sort(compare);
|
|
658
592
|
} else {
|
|
659
|
-
entries.sort((a, b) =>
|
|
660
|
-
return a[0].localeCompare(b[0]);
|
|
661
|
-
});
|
|
593
|
+
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
662
594
|
}
|
|
663
595
|
return Object.fromEntries(entries);
|
|
664
596
|
}
|
|
@@ -772,9 +704,7 @@ __name(sortKeysLike, "sortKeysLike");
|
|
|
772
704
|
// src/staticClassKeysOf.ts
|
|
773
705
|
function staticClassKeysOf(cls) {
|
|
774
706
|
const keys = Object.getOwnPropertyNames(cls);
|
|
775
|
-
return keys.filter((key) =>
|
|
776
|
-
return !ignoreKeys.includes(key);
|
|
777
|
-
});
|
|
707
|
+
return keys.filter((key) => !ignoreKeys.includes(key));
|
|
778
708
|
}
|
|
779
709
|
__name(staticClassKeysOf, "staticClassKeysOf");
|
|
780
710
|
var ignoreKeys = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/object",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Comprehensive object manipulation utilities for property definition, traversal, filtering, mapping, prototype chains, and descriptor management.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|