radashi 12.9.8 → 13.0.0-beta.87bc348

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/radashi.cjs CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  // src/array/alphabetical.ts
4
4
  function alphabetical(array, getter, direction = "asc") {
5
- if (!array) {
6
- return [];
7
- }
8
5
  const asc = (a, b) => `${getter(a)}`.localeCompare(getter(b));
9
6
  const dsc = (a, b) => `${getter(b)}`.localeCompare(getter(a));
10
7
  return array.slice().sort(direction === "desc" ? dsc : asc);
@@ -12,10 +9,7 @@ function alphabetical(array, getter, direction = "asc") {
12
9
 
13
10
  // src/array/boil.ts
14
11
  function boil(array, compareFunc) {
15
- if (!array || (array.length ?? 0) === 0) {
16
- return null;
17
- }
18
- return array.reduce(compareFunc);
12
+ return array.length ? array.reduce(compareFunc) : null;
19
13
  }
20
14
 
21
15
  // src/array/cartesianProduct.ts
@@ -46,7 +40,7 @@ function castArrayIfExists(value) {
46
40
  }
47
41
 
48
42
  // src/array/cluster.ts
49
- function cluster(array, size = 2) {
43
+ function cluster(array, size) {
50
44
  const clusters = [];
51
45
  if (size > 0) {
52
46
  for (let i = 0; i < array.length; i += size) {
@@ -72,28 +66,18 @@ function concat(...values) {
72
66
 
73
67
  // src/array/counting.ts
74
68
  function counting(array, identity2) {
75
- const counts = /* @__PURE__ */ Object.create(null);
76
- if (!array) {
77
- return counts;
78
- }
79
- for (const item of array) {
80
- const id = identity2(item);
81
- counts[id] = (counts[id] ?? 0) + 1;
82
- }
83
- return counts;
69
+ return array.reduce(
70
+ (acc, item) => {
71
+ const id = identity2(item);
72
+ acc[id] = (acc[id] ?? 0) + 1;
73
+ return acc;
74
+ },
75
+ /* @__PURE__ */ Object.create(null)
76
+ );
84
77
  }
85
78
 
86
79
  // src/array/diff.ts
87
80
  function diff(root, other, identity2 = (t) => t) {
88
- if (!(root == null ? void 0 : root.length) && !(other == null ? void 0 : other.length)) {
89
- return [];
90
- }
91
- if ((root == null ? void 0 : root.length) === void 0) {
92
- return [...other];
93
- }
94
- if (!(other == null ? void 0 : other.length)) {
95
- return [...root];
96
- }
97
81
  const bKeys = /* @__PURE__ */ new Set();
98
82
  for (const item of other) {
99
83
  bKeys.add(identity2(item));
@@ -103,7 +87,7 @@ function diff(root, other, identity2 = (t) => t) {
103
87
 
104
88
  // src/array/first.ts
105
89
  function first(array, defaultValue) {
106
- return (array == null ? void 0 : array.length) > 0 ? array[0] : defaultValue;
90
+ return array.length > 0 ? array[0] : defaultValue;
107
91
  }
108
92
 
109
93
  // src/array/flat.ts
@@ -117,10 +101,8 @@ function flat(lists) {
117
101
  // src/array/fork.ts
118
102
  function fork(array, condition) {
119
103
  const forked = [[], []];
120
- if (array) {
121
- for (const item of array) {
122
- forked[condition(item) ? 0 : 1].push(item);
123
- }
104
+ for (const item of array) {
105
+ forked[condition(item) ? 0 : 1].push(item);
124
106
  }
125
107
  return forked;
126
108
  }
@@ -140,9 +122,6 @@ function group(array, getGroupId) {
140
122
 
141
123
  // src/array/intersects.ts
142
124
  function intersects(listA, listB, identity2) {
143
- if (!listA || !listB) {
144
- return false;
145
- }
146
125
  if (identity2) {
147
126
  const known = new Set(listA.map(identity2));
148
127
  return listB.some((item) => known.has(identity2(item)));
@@ -176,7 +155,7 @@ function iterate(count, func, initValue) {
176
155
 
177
156
  // src/array/last.ts
178
157
  function last(array, defaultValue) {
179
- return (array == null ? void 0 : array.length) > 0 ? array[array.length - 1] : defaultValue;
158
+ return array.length > 0 ? array[array.length - 1] : defaultValue;
180
159
  }
181
160
 
182
161
  // src/array/list.ts
@@ -195,18 +174,6 @@ function mapify(array, getKey, getValue = (item) => item) {
195
174
 
196
175
  // src/array/merge.ts
197
176
  function merge(prev, array, toKey) {
198
- if (!array && !prev) {
199
- return [];
200
- }
201
- if (!array) {
202
- return [...prev];
203
- }
204
- if (!prev) {
205
- return [];
206
- }
207
- if (!toKey) {
208
- return [...prev];
209
- }
210
177
  const keys2 = /* @__PURE__ */ new Map();
211
178
  for (const item of array) {
212
179
  keys2.set(toKey(item), item);
@@ -244,9 +211,6 @@ function remove(array, predicate) {
244
211
 
245
212
  // src/array/replace.ts
246
213
  function replace(array, newItem, match) {
247
- if (!array) {
248
- return [];
249
- }
250
214
  if (newItem === void 0) {
251
215
  return [...array];
252
216
  }
@@ -262,15 +226,9 @@ function replace(array, newItem, match) {
262
226
 
263
227
  // src/array/replaceOrAppend.ts
264
228
  function replaceOrAppend(array, newItem, match) {
265
- if (!array && newItem == null) {
266
- return [];
267
- }
268
- if (newItem == null) {
229
+ if (newItem === void 0) {
269
230
  return [...array];
270
231
  }
271
- if (!array) {
272
- return [newItem];
273
- }
274
232
  const out = array.slice();
275
233
  for (let index = 0; index < array.length; index++) {
276
234
  if (match(array[index], index)) {
@@ -284,9 +242,6 @@ function replaceOrAppend(array, newItem, match) {
284
242
 
285
243
  // src/array/select.ts
286
244
  function select(array, mapper, condition) {
287
- if (!array) {
288
- return [];
289
- }
290
245
  let mapped;
291
246
  return array.reduce((acc, item, index) => {
292
247
  if (condition) {
@@ -300,9 +255,6 @@ function select(array, mapper, condition) {
300
255
 
301
256
  // src/array/selectFirst.ts
302
257
  function selectFirst(array, mapper, condition) {
303
- if (!array) {
304
- return void 0;
305
- }
306
258
  let foundItem;
307
259
  const foundIndex = array.findIndex((item, index) => {
308
260
  foundItem = item;
@@ -325,23 +277,18 @@ function shift(arr, n) {
325
277
 
326
278
  // src/array/sift.ts
327
279
  function sift(array) {
328
- return (array == null ? void 0 : array.filter((x) => !!x)) ?? [];
280
+ return array?.filter((x) => !!x) ?? [];
329
281
  }
330
282
 
331
283
  // src/array/sort.ts
332
- function sort(array, getter = identity, desc = false) {
333
- if (!array) {
334
- return [];
335
- }
336
- const direction = desc ? -1 : 1;
337
- return array.slice().sort((a, b) => (getter(a) - getter(b)) * direction);
284
+ function sort(array, getter = identity, direction = "asc") {
285
+ const asc = (a, b) => getter(a) - getter(b);
286
+ const dsc = (a, b) => getter(b) - getter(a);
287
+ return array.slice().sort(direction === "desc" ? dsc : asc);
338
288
  }
339
289
 
340
290
  // src/array/toggle.ts
341
291
  function toggle(array, item, toKey, options) {
342
- if (!array) {
343
- return item !== void 0 ? [item] : [];
344
- }
345
292
  if (item === void 0) {
346
293
  return [...array];
347
294
  }
@@ -356,7 +303,7 @@ function toggle(array, item, toKey, options) {
356
303
  if (existingIndex !== -1) {
357
304
  return array.filter((x, idx) => !matcher(x, idx));
358
305
  }
359
- return (options == null ? void 0 : options.strategy) === "prepend" ? [item, ...array] : [...array, item];
306
+ return options?.strategy === "prepend" ? [item, ...array] : [...array, item];
360
307
  }
361
308
 
362
309
  // src/array/unique.ts
@@ -377,9 +324,6 @@ function unique(array, toKey) {
377
324
 
378
325
  // src/array/unzip.ts
379
326
  function unzip(arrays) {
380
- if (!arrays || !arrays.length) {
381
- return [];
382
- }
383
327
  const out = new Array(
384
328
  arrays.reduce((max2, arr) => Math.max(max2, arr.length), 0)
385
329
  );
@@ -398,9 +342,6 @@ function zip(...arrays) {
398
342
 
399
343
  // src/array/zipToObject.ts
400
344
  function zipToObject(keys2, values) {
401
- if (!keys2 || !keys2.length) {
402
- return {};
403
- }
404
345
  const getValue = isFunction(values) ? values : isArray(values) ? (_k, i) => values[i] : (_k, _i) => values;
405
346
  return keys2.reduce(
406
347
  (acc, key, idx) => {
@@ -441,7 +382,7 @@ async function defer(func) {
441
382
  const callbacks = [];
442
383
  const register = (fn, options) => callbacks.push({
443
384
  fn,
444
- rethrow: (options == null ? void 0 : options.rethrow) ?? false
385
+ rethrow: options?.rethrow ?? false
445
386
  });
446
387
  const [err, response] = await tryit(func)(register);
447
388
  for (const { fn, rethrow } of callbacks) {
@@ -473,9 +414,6 @@ function guard(func, shouldGuard) {
473
414
 
474
415
  // src/async/map.ts
475
416
  async function map(array, asyncMapFunc) {
476
- if (!array) {
477
- return [];
478
- }
479
417
  const result = [];
480
418
  let index = 0;
481
419
  for (const value of array) {
@@ -501,11 +439,11 @@ async function parallel(options, array, func) {
501
439
  };
502
440
  } else {
503
441
  signal = options.signal;
504
- signal == null ? void 0 : signal.throwIfAborted();
442
+ signal?.throwIfAborted();
505
443
  }
506
444
  const processor = async (resolve) => {
507
445
  const results2 = [];
508
- while (!(signal == null ? void 0 : signal.aborted)) {
446
+ while (!signal?.aborted) {
509
447
  const next = work.pop();
510
448
  if (!next) {
511
449
  break;
@@ -558,9 +496,6 @@ function queueByKey(asyncFn, keyFn) {
558
496
 
559
497
  // src/async/reduce.ts
560
498
  async function reduce(array, reducer, initialValue) {
561
- if (!array) {
562
- array = [];
563
- }
564
499
  let index = 0;
565
500
  let acc = initialValue;
566
501
  if (acc === void 0 && arguments.length < 3) {
@@ -577,16 +512,16 @@ async function reduce(array, reducer, initialValue) {
577
512
 
578
513
  // src/async/retry.ts
579
514
  async function retry(options, func) {
580
- const times = (options == null ? void 0 : options.times) ?? 3;
581
- const delay = options == null ? void 0 : options.delay;
582
- const backoff = (options == null ? void 0 : options.backoff) ?? null;
583
- const signal = options == null ? void 0 : options.signal;
515
+ const times = options?.times ?? 3;
516
+ const delay = options?.delay;
517
+ const backoff = options?.backoff ?? null;
518
+ const signal = options?.signal;
584
519
  let i = 0;
585
520
  while (true) {
586
521
  const [err, result] = await tryit(func)((err2) => {
587
522
  throw { _exited: err2 };
588
523
  });
589
- signal == null ? void 0 : signal.throwIfAborted();
524
+ signal?.throwIfAborted();
590
525
  if (!err) {
591
526
  return result;
592
527
  }
@@ -659,6 +594,32 @@ function withResolvers() {
659
594
  return { resolve, reject, promise };
660
595
  }
661
596
 
597
+ // src/async/promiseMemo.ts
598
+ function promiseMemo(func, options = {}) {
599
+ const { key: keyFunc, ttl, cache = {} } = options;
600
+ return function callWithMemo(...args) {
601
+ const key = keyFunc ? keyFunc(...args) : JSON.stringify({ args });
602
+ const existing = cache[key];
603
+ if (existing !== void 0) {
604
+ if (!existing.exp) {
605
+ return existing.value;
606
+ }
607
+ if (existing.exp > (/* @__PURE__ */ new Date()).getTime()) {
608
+ return existing.value;
609
+ }
610
+ }
611
+ const promise = func(...args);
612
+ cache[key] = {
613
+ exp: ttl ? (/* @__PURE__ */ new Date()).getTime() + ttl : null,
614
+ value: promise
615
+ };
616
+ promise.catch(() => {
617
+ delete cache[key];
618
+ });
619
+ return promise;
620
+ };
621
+ }
622
+
662
623
  // src/curry/callable.ts
663
624
  function callable(obj, fn) {
664
625
  return new Proxy(Object.assign(fn.bind(null), obj), {
@@ -684,31 +645,31 @@ function compose(...funcs) {
684
645
  }
685
646
 
686
647
  // src/curry/debounce.ts
687
- function debounce({ delay, leading }, func) {
688
- let timer = void 0;
689
- let active = true;
690
- const debounced = (...args) => {
691
- if (active) {
692
- clearTimeout(timer);
693
- timer = setTimeout(() => {
694
- active && func(...args);
695
- timer = void 0;
696
- }, delay);
697
- if (leading) {
698
- func(...args);
699
- leading = false;
700
- }
648
+ function debounce({ delay, leading }, callee) {
649
+ let timeout2;
650
+ const debounced = ((...args) => {
651
+ if (leading) {
652
+ leading = false;
653
+ callee(...args);
701
654
  } else {
702
- func(...args);
655
+ clearTimeout(timeout2);
656
+ timeout2 = setTimeout(
657
+ debounced.flush = () => {
658
+ debounced.cancel();
659
+ callee(...args);
660
+ },
661
+ delay
662
+ );
703
663
  }
704
- };
705
- debounced.isPending = () => {
706
- return timer !== void 0;
707
- };
664
+ });
665
+ debounced.callee = callee;
666
+ debounced.isDebounced = () => timeout2 !== void 0;
667
+ debounced.flush = noop;
708
668
  debounced.cancel = () => {
709
- active = false;
669
+ debounced.flush = noop;
670
+ clearTimeout(timeout2);
671
+ timeout2 = void 0;
710
672
  };
711
- debounced.flush = (...args) => func(...args);
712
673
  return debounced;
713
674
  }
714
675
 
@@ -718,7 +679,8 @@ function flip(fn) {
718
679
  }
719
680
 
720
681
  // src/curry/memo.ts
721
- function memoize(cache, func, keyFunc, ttl) {
682
+ function memo(func, options = {}) {
683
+ const { key: keyFunc, ttl, cache = /* @__PURE__ */ Object.create(null) } = options;
722
684
  return function callWithMemo(...args) {
723
685
  const key = keyFunc ? keyFunc(...args) : JSON.stringify({ args });
724
686
  const existing = cache[key];
@@ -738,14 +700,6 @@ function memoize(cache, func, keyFunc, ttl) {
738
700
  return result;
739
701
  };
740
702
  }
741
- function memo(func, options = {}) {
742
- return memoize(
743
- /* @__PURE__ */ Object.create(null),
744
- func,
745
- options.key ?? null,
746
- options.ttl ?? null
747
- );
748
- }
749
703
 
750
704
  // src/curry/memoLastCall.ts
751
705
  function memoLastCall(fn) {
@@ -802,6 +756,39 @@ function promiseChain(...funcs) {
802
756
  };
803
757
  }
804
758
 
759
+ // src/curry/promiseDebounce.ts
760
+ function promiseDebounce({ delay, leading }, callee) {
761
+ let timeout2;
762
+ const debounced = ((...args) => {
763
+ const promise = new Promise((resolve) => {
764
+ if (leading) {
765
+ leading = false;
766
+ resolve(callee(...args));
767
+ } else {
768
+ clearTimeout(timeout2);
769
+ timeout2 = setTimeout(
770
+ debounced.flush = () => {
771
+ debounced.cancel();
772
+ resolve((async () => callee(...args))());
773
+ return promise;
774
+ },
775
+ delay
776
+ );
777
+ }
778
+ });
779
+ return promise;
780
+ });
781
+ debounced.callee = callee;
782
+ debounced.isDebounced = () => timeout2 !== void 0;
783
+ debounced.flush = noop;
784
+ debounced.cancel = () => {
785
+ debounced.flush = noop;
786
+ clearTimeout(timeout2);
787
+ timeout2 = void 0;
788
+ };
789
+ return debounced;
790
+ }
791
+
805
792
  // src/curry/proxied.ts
806
793
  function proxied(handler) {
807
794
  return new Proxy(
@@ -883,15 +870,7 @@ function clamp(n, min2, max2) {
883
870
  }
884
871
 
885
872
  // src/number/inRange.ts
886
- function inRange(number, start, end) {
887
- const isTypeSafe = typeof number === "number" && typeof start === "number" && (typeof end === "undefined" || typeof end === "number");
888
- if (!isTypeSafe) {
889
- return false;
890
- }
891
- if (typeof end === "undefined") {
892
- end = start;
893
- start = 0;
894
- }
873
+ function inRange(number, start, end = 0) {
895
874
  return number >= Math.min(start, end) && number < Math.max(start, end);
896
875
  }
897
876
 
@@ -902,7 +881,7 @@ function lerp(from, to, amount) {
902
881
 
903
882
  // src/number/max.ts
904
883
  function max(array, getter) {
905
- if (!array || (array.length ?? 0) === 0) {
884
+ if (!array.length) {
906
885
  return null;
907
886
  }
908
887
  const get2 = getter ?? ((v) => v);
@@ -911,7 +890,7 @@ function max(array, getter) {
911
890
 
912
891
  // src/number/min.ts
913
892
  function min(array, getter) {
914
- if (!array || (array.length ?? 0) === 0) {
893
+ if (!array.length) {
915
894
  return null;
916
895
  }
917
896
  const get2 = getter ?? ((v) => v);
@@ -968,9 +947,6 @@ function toInt(value, defaultValue) {
968
947
 
969
948
  // src/object/assign.ts
970
949
  function assign(initial, override) {
971
- if (!initial || !override) {
972
- return initial ?? override ?? {};
973
- }
974
950
  const proto = Object.getPrototypeOf(initial);
975
951
  const merged = proto ? { ...initial } : Object.assign(Object.create(proto), initial);
976
952
  for (const key of Object.keys(override)) {
@@ -984,14 +960,8 @@ function assign(initial, override) {
984
960
 
985
961
  // src/object/clone.ts
986
962
  function clone(obj) {
987
- if (isPrimitive(obj)) {
988
- return obj;
989
- }
990
- if (typeof obj === "function") {
991
- return obj.bind({});
992
- }
993
963
  const proto = Object.getPrototypeOf(obj);
994
- const newObj = typeof (proto == null ? void 0 : proto.constructor) === "function" ? new proto.constructor() : Object.create(proto);
964
+ const newObj = typeof proto?.constructor === "function" ? new proto.constructor() : Object.create(proto);
995
965
  for (const key of Object.getOwnPropertyNames(obj)) {
996
966
  newObj[key] = obj[key];
997
967
  }
@@ -1067,9 +1037,6 @@ function cloneDeep(root, customStrategy) {
1067
1037
 
1068
1038
  // src/object/construct.ts
1069
1039
  function construct(obj) {
1070
- if (!obj) {
1071
- return {};
1072
- }
1073
1040
  return Object.keys(obj).reduce((acc, path) => {
1074
1041
  return set(acc, path, obj[path]);
1075
1042
  }, {});
@@ -1077,11 +1044,11 @@ function construct(obj) {
1077
1044
 
1078
1045
  // src/object/crush.ts
1079
1046
  function crush(value) {
1080
- if (!value) {
1047
+ if (Object.keys(value).length === 0) {
1081
1048
  return {};
1082
1049
  }
1083
1050
  return (function crushReducer(crushed, value2, path) {
1084
- if (isObject(value2) || isArray(value2)) {
1051
+ if ((isObject(value2) || isArray(value2)) && Object.keys(value2).length > 0) {
1085
1052
  for (const [prop, propValue] of Object.entries(value2)) {
1086
1053
  crushReducer(crushed, propValue, path ? `${path}.${prop}` : prop);
1087
1054
  }
@@ -1141,9 +1108,6 @@ function getOrInsertComputed(map2, key, compute) {
1141
1108
 
1142
1109
  // src/object/invert.ts
1143
1110
  function invert(obj) {
1144
- if (!obj) {
1145
- return {};
1146
- }
1147
1111
  const keys2 = Object.keys(obj);
1148
1112
  return keys2.reduce(
1149
1113
  (acc, key) => {
@@ -1161,9 +1125,6 @@ function isDangerousKey(key, object) {
1161
1125
 
1162
1126
  // src/object/keys.ts
1163
1127
  function keys(value) {
1164
- if (!value) {
1165
- return [];
1166
- }
1167
1128
  const keys2 = [];
1168
1129
  const keyPath = [];
1169
1130
  const recurse = (value2) => {
@@ -1189,14 +1150,7 @@ function keys(value) {
1189
1150
 
1190
1151
  // src/object/listify.ts
1191
1152
  function listify(obj, toItem) {
1192
- if (!obj) {
1193
- return [];
1194
- }
1195
- const entries = Object.entries(obj);
1196
- if (entries.length === 0) {
1197
- return [];
1198
- }
1199
- return entries.reduce((acc, entry) => {
1153
+ return Object.entries(obj).reduce((acc, entry) => {
1200
1154
  acc.push(toItem(entry[0], entry[1]));
1201
1155
  return acc;
1202
1156
  }, []);
@@ -1209,9 +1163,6 @@ function lowerize(obj) {
1209
1163
 
1210
1164
  // src/object/mapEntries.ts
1211
1165
  function mapEntries(obj, toEntry) {
1212
- if (!obj) {
1213
- return {};
1214
- }
1215
1166
  return Object.entries(obj).reduce(
1216
1167
  (acc, [key, value]) => {
1217
1168
  const [newKey, newValue] = toEntry(key, value);
@@ -1258,10 +1209,7 @@ function mergeOptions(a, b) {
1258
1209
 
1259
1210
  // src/object/omit.ts
1260
1211
  function omit(obj, keys2) {
1261
- if (!obj) {
1262
- return {};
1263
- }
1264
- if (!keys2 || keys2.length === 0) {
1212
+ if (keys2.length === 0) {
1265
1213
  return obj;
1266
1214
  }
1267
1215
  return keys2.reduce(
@@ -1275,9 +1223,6 @@ function omit(obj, keys2) {
1275
1223
 
1276
1224
  // src/object/pick.ts
1277
1225
  function pick(obj, filter) {
1278
- if (!obj) {
1279
- return {};
1280
- }
1281
1226
  let keys2 = filter;
1282
1227
  if (isArray(filter)) {
1283
1228
  filter = null;
@@ -1294,10 +1239,7 @@ function pick(obj, filter) {
1294
1239
 
1295
1240
  // src/object/set.ts
1296
1241
  function set(initial, path, value) {
1297
- if (!initial) {
1298
- return {};
1299
- }
1300
- if (!path || value === void 0) {
1242
+ if (path.length === 0) {
1301
1243
  return initial;
1302
1244
  }
1303
1245
  return (function recurse(object, keys2, index) {
@@ -1319,9 +1261,6 @@ function set(initial, path, value) {
1319
1261
 
1320
1262
  // src/object/shake.ts
1321
1263
  function shake(obj, filter = (value) => value === void 0) {
1322
- if (!obj) {
1323
- return {};
1324
- }
1325
1264
  return Object.keys(obj).reduce((acc, key) => {
1326
1265
  if (!filter(obj[key])) {
1327
1266
  acc[key] = obj[key];
@@ -1433,20 +1372,44 @@ function upperize(obj) {
1433
1372
  }
1434
1373
 
1435
1374
  // src/oop/AggregateError.ts
1436
- var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => globalThis.AggregateError ?? class AggregateError extends Error {
1437
- constructor(errors = []) {
1438
- var _a, _b;
1439
- super();
1440
- const name = ((_a = errors.find((e) => e.name)) == null ? void 0 : _a.name) ?? "";
1441
- this.name = `AggregateError(${name}...)`;
1442
- this.message = `AggregateError with ${errors.length} errors`;
1443
- this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
1444
- this.errors = errors;
1445
- }
1375
+ var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => {
1376
+ if (globalThis.AggregateError) {
1377
+ return globalThis.AggregateError;
1378
+ }
1379
+ function AggregateError(errors, message, options = void 0) {
1380
+ const error = Reflect.construct(
1381
+ Error,
1382
+ [message],
1383
+ new.target ?? AggregateError
1384
+ );
1385
+ if (options !== null && (typeof options === "object" || typeof options === "function") && "cause" in options) {
1386
+ Object.defineProperty(error, "cause", {
1387
+ value: options.cause,
1388
+ writable: true,
1389
+ configurable: true
1390
+ });
1391
+ }
1392
+ Object.defineProperty(error, "errors", {
1393
+ value: [...errors],
1394
+ writable: true,
1395
+ configurable: true
1396
+ });
1397
+ return error;
1398
+ }
1399
+ Object.setPrototypeOf(AggregateError, Error);
1400
+ Object.setPrototypeOf(AggregateError.prototype, Error.prototype);
1401
+ Object.defineProperty(AggregateError, "prototype", { writable: false });
1402
+ Object.defineProperties(AggregateError.prototype, {
1403
+ name: { value: "AggregateError", writable: true, configurable: true },
1404
+ message: { value: "", writable: true, configurable: true }
1405
+ });
1406
+ return AggregateError;
1446
1407
  })();
1447
1408
 
1448
1409
  // src/oop/QuantityParser.ts
1449
1410
  var QuantityParser = class {
1411
+ units;
1412
+ short;
1450
1413
  constructor({ units, short }) {
1451
1414
  this.units = units;
1452
1415
  this.short = short;
@@ -1457,13 +1420,12 @@ var QuantityParser = class {
1457
1420
  * @throws {Error} If the quantity string is invalid or contains an unknown unit
1458
1421
  */
1459
1422
  parse(quantity) {
1460
- var _a;
1461
1423
  const match = quantity.match(/^(-?\d+(?:\.\d+)?) ?(\w+)?s?$/);
1462
1424
  if (!match) {
1463
1425
  throw new Error(`Invalid quantity, cannot parse: ${quantity}`);
1464
1426
  }
1465
1427
  let unit = match[2];
1466
- unit = ((_a = this.short) == null ? void 0 : _a[unit]) || unit;
1428
+ unit = this.short?.[unit] || unit;
1467
1429
  const count = Number.parseFloat(match[1]);
1468
1430
  if (Math.abs(count) > 1 && unit.endsWith("s")) {
1469
1431
  unit = unit.substring(0, unit.length - 1);
@@ -1499,11 +1461,11 @@ var DurationParser = class _DurationParser extends QuantityParser {
1499
1461
  super({
1500
1462
  units: {
1501
1463
  ..._DurationParser.units,
1502
- ...options == null ? void 0 : options.units
1464
+ ...options?.units
1503
1465
  },
1504
1466
  short: {
1505
1467
  ..._DurationParser.shortUnits,
1506
- ...options == null ? void 0 : options.short
1468
+ ...options?.short
1507
1469
  }
1508
1470
  });
1509
1471
  }
@@ -1522,6 +1484,9 @@ var SemaphorePermit = class {
1522
1484
  this.request = request;
1523
1485
  this.weight = weight;
1524
1486
  }
1487
+ semaphore;
1488
+ request;
1489
+ weight;
1525
1490
  /**
1526
1491
  * Releases this permit back to the semaphore, allowing another
1527
1492
  * operation to acquire it.
@@ -1538,12 +1503,17 @@ var Semaphore = class {
1538
1503
  */
1539
1504
  constructor(maxCapacity) {
1540
1505
  this.maxCapacity = maxCapacity;
1541
- this.queue = [];
1542
1506
  if (maxCapacity <= 0) {
1543
1507
  throw new Error("maxCapacity must be > 0");
1544
1508
  }
1545
1509
  this.capacity = maxCapacity;
1546
1510
  }
1511
+ maxCapacity;
1512
+ queue = [];
1513
+ /**
1514
+ * Current number of permits available to be acquired
1515
+ */
1516
+ capacity;
1547
1517
  /**
1548
1518
  * Number of pending acquisition requests.
1549
1519
  */
@@ -1617,9 +1587,9 @@ var Semaphore = class {
1617
1587
 
1618
1588
  // src/oop/TimeoutError.ts
1619
1589
  var TimeoutError = class extends Error {
1590
+ name = "TimeoutError";
1620
1591
  constructor(message) {
1621
1592
  super(message ?? "Operation timed out");
1622
- this.name = "TimeoutError";
1623
1593
  }
1624
1594
  };
1625
1595
 
@@ -1729,14 +1699,7 @@ var series = (items, toKey = (item) => `${item}`) => {
1729
1699
 
1730
1700
  // src/string/camel.ts
1731
1701
  function camel(str) {
1732
- var _a;
1733
- const parts = ((_a = str == null ? void 0 : str.replace(/([A-Z])+/g, capitalize)) == null ? void 0 : _a.split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase())) ?? [];
1734
- if (parts.length === 0) {
1735
- return "";
1736
- }
1737
- if (parts.length === 1) {
1738
- return parts[0];
1739
- }
1702
+ const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
1740
1703
  return parts.reduce((acc, part) => {
1741
1704
  return `${acc}${part.charAt(0).toUpperCase()}${part.slice(1)}`;
1742
1705
  });
@@ -1744,23 +1707,13 @@ function camel(str) {
1744
1707
 
1745
1708
  // src/string/capitalize.ts
1746
1709
  function capitalize(str) {
1747
- if (!str || str.length === 0) {
1748
- return "";
1749
- }
1750
1710
  const lower = str.toLowerCase();
1751
1711
  return lower.substring(0, 1).toUpperCase() + lower.substring(1, lower.length);
1752
1712
  }
1753
1713
 
1754
1714
  // src/string/dash.ts
1755
1715
  function dash(str) {
1756
- var _a;
1757
- const parts = ((_a = str == null ? void 0 : str.replace(/([A-Z])+/g, capitalize)) == null ? void 0 : _a.split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase())) ?? [];
1758
- if (parts.length === 0) {
1759
- return "";
1760
- }
1761
- if (parts.length === 1) {
1762
- return parts[0];
1763
- }
1716
+ const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
1764
1717
  return parts.reduce((acc, part) => {
1765
1718
  return `${acc}-${part.toLowerCase()}`;
1766
1719
  });
@@ -1816,14 +1769,12 @@ function deburr(input) {
1816
1769
  // src/string/dedent.ts
1817
1770
  // @__NO_SIDE_EFFECTS__
1818
1771
  function dedent(text, ...values) {
1819
- var _a;
1820
1772
  if (isArray(text)) {
1821
1773
  if (values.length > 0) {
1822
1774
  return /* @__PURE__ */ dedent(
1823
1775
  text.reduce((acc, input, i) => {
1824
- var _a2;
1825
1776
  let value = String(values[i] ?? "");
1826
- const indent2 = value.includes("\n") && ((_a2 = input.match(/[ \t]*(?=[^\n]*$)/)) == null ? void 0 : _a2[0]);
1777
+ const indent2 = value.includes("\n") && input.match(/[ \t]*(?=[^\n]*$)/)?.[0];
1827
1778
  if (indent2) {
1828
1779
  value = value.replace(/\n(?=[^\n]*?\S)/g, "\n" + indent2);
1829
1780
  }
@@ -1833,7 +1784,7 @@ function dedent(text, ...values) {
1833
1784
  }
1834
1785
  text = text[0];
1835
1786
  }
1836
- const indent = values[0] ?? ((_a = text.match(/^[ \t]*(?=\S)/m)) == null ? void 0 : _a[0]);
1787
+ const indent = values[0] ?? text.match(/^[ \t]*(?=\S)/m)?.[0];
1837
1788
  const output = indent ? text.replace(new RegExp(`^${indent}`, "gm"), "") : text;
1838
1789
  return output.replace(/^[ \t]*\n|\n[ \t]*$/g, "");
1839
1790
  }
@@ -1853,9 +1804,6 @@ function escapeHTML(input) {
1853
1804
 
1854
1805
  // src/string/pascal.ts
1855
1806
  function pascal(str) {
1856
- if (!str) {
1857
- return "";
1858
- }
1859
1807
  const result = str.replace(
1860
1808
  /(?:[^\w\d]|_|\s)+(\w)([A-Z]+)?/g,
1861
1809
  (_, firstCharacter, capitalizedLetters) => {
@@ -1918,17 +1866,11 @@ function similarity(str1, str2) {
1918
1866
 
1919
1867
  // src/string/snake.ts
1920
1868
  function snake(str, options) {
1921
- const parts = (str == null ? void 0 : str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase())) ?? [];
1922
- if (parts.length === 0) {
1923
- return "";
1924
- }
1925
- if (parts.length === 1) {
1926
- return parts[0];
1927
- }
1869
+ const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
1928
1870
  const result = parts.reduce((acc, part) => {
1929
1871
  return `${acc}_${part.toLowerCase()}`;
1930
1872
  });
1931
- return (options == null ? void 0 : options.splitOnNumber) === false ? result : result.replace(/([A-Za-z]{1}[0-9]{1})/g, (val) => `${val[0]}_${val[1]}`);
1873
+ return options?.splitOnNumber === false ? result : result.replace(/([A-Za-z]{1}[0-9]{1})/g, (val) => `${val[0]}_${val[1]}`);
1932
1874
  }
1933
1875
 
1934
1876
  // src/string/template.ts
@@ -1945,17 +1887,11 @@ function template(str, data, regex = /\{\{(.+?)\}\}/g) {
1945
1887
 
1946
1888
  // src/string/title.ts
1947
1889
  function title(str) {
1948
- if (!str) {
1949
- return "";
1950
- }
1951
1890
  return str.split(/(?=[A-Z])|[\.\-\s_]/).map((s) => s.trim()).filter((s) => !!s).map((s) => capitalize(s.toLowerCase())).join(" ");
1952
1891
  }
1953
1892
 
1954
1893
  // src/string/trim.ts
1955
- function trim(str, charsToTrim = " ") {
1956
- if (!str) {
1957
- return "";
1958
- }
1894
+ function trim(str, charsToTrim) {
1959
1895
  const toTrim = charsToTrim.replace(/[\W]{1}/g, "\\$&");
1960
1896
  const regex = new RegExp(`^[${toTrim}]+|[${toTrim}]+$`, "g");
1961
1897
  return str.replace(regex, "");
@@ -2065,7 +2001,7 @@ function isError(value) {
2065
2001
 
2066
2002
  // src/typed/isFloat.ts
2067
2003
  function isFloat(value) {
2068
- return isNumber(value) && value % 1 !== 0;
2004
+ return isNumber(value) && !Number.isNaN(value) && value % 1 !== 0;
2069
2005
  }
2070
2006
 
2071
2007
  // src/typed/isFunction.ts
@@ -2115,7 +2051,7 @@ function isNullish(value) {
2115
2051
 
2116
2052
  // src/typed/isNumber.ts
2117
2053
  function isNumber(value) {
2118
- return typeof value === "number" && !Number.isNaN(value);
2054
+ return typeof value === "number";
2119
2055
  }
2120
2056
 
2121
2057
  // src/typed/isObject.ts
@@ -2338,6 +2274,8 @@ exports.pascal = pascal;
2338
2274
  exports.pick = pick;
2339
2275
  exports.pluck = pluck;
2340
2276
  exports.promiseChain = promiseChain;
2277
+ exports.promiseDebounce = promiseDebounce;
2278
+ exports.promiseMemo = promiseMemo;
2341
2279
  exports.proportionalJitter = proportionalJitter;
2342
2280
  exports.proxied = proxied;
2343
2281
  exports.queueByKey = queueByKey;