radashi 12.3.3 → 13.0.0-beta.ffa4778

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
@@ -56,9 +50,6 @@ function cluster(array, size = 2) {
56
50
 
57
51
  // src/array/counting.ts
58
52
  function counting(array, identity) {
59
- if (!array) {
60
- return {};
61
- }
62
53
  return array.reduce(
63
54
  (acc, item) => {
64
55
  const id = identity(item);
@@ -71,15 +62,6 @@ function counting(array, identity) {
71
62
 
72
63
  // src/array/diff.ts
73
64
  function diff(root, other, identity = (t) => t) {
74
- if (!(root == null ? void 0 : root.length) && !(other == null ? void 0 : other.length)) {
75
- return [];
76
- }
77
- if ((root == null ? void 0 : root.length) === void 0) {
78
- return [...other];
79
- }
80
- if (!(other == null ? void 0 : other.length)) {
81
- return [...root];
82
- }
83
65
  const bKeys = other.reduce(
84
66
  (acc, item) => {
85
67
  acc[identity(item)] = true;
@@ -92,7 +74,7 @@ function diff(root, other, identity = (t) => t) {
92
74
 
93
75
  // src/array/first.ts
94
76
  function first(array, defaultValue) {
95
- return (array == null ? void 0 : array.length) > 0 ? array[0] : defaultValue;
77
+ return array.length > 0 ? array[0] : defaultValue;
96
78
  }
97
79
 
98
80
  // src/array/flat.ts
@@ -106,10 +88,8 @@ function flat(lists) {
106
88
  // src/array/fork.ts
107
89
  function fork(array, condition) {
108
90
  const forked = [[], []];
109
- if (array) {
110
- for (const item of array) {
111
- forked[condition(item) ? 0 : 1].push(item);
112
- }
91
+ for (const item of array) {
92
+ forked[condition(item) ? 0 : 1].push(item);
113
93
  }
114
94
  return forked;
115
95
  }
@@ -131,9 +111,6 @@ function group(array, getGroupId) {
131
111
 
132
112
  // src/array/intersects.ts
133
113
  function intersects(listA, listB, identity) {
134
- if (!listA || !listB) {
135
- return false;
136
- }
137
114
  if (identity) {
138
115
  const known = new Set(listA.map(identity));
139
116
  return listB.some((item) => known.has(identity(item)));
@@ -152,7 +129,7 @@ function iterate(count, func, initValue) {
152
129
 
153
130
  // src/array/last.ts
154
131
  function last(array, defaultValue) {
155
- return (array == null ? void 0 : array.length) > 0 ? array[array.length - 1] : defaultValue;
132
+ return array.length > 0 ? array[array.length - 1] : defaultValue;
156
133
  }
157
134
 
158
135
  // src/array/list.ts
@@ -171,18 +148,6 @@ function mapify(array, getKey, getValue = (item) => item) {
171
148
 
172
149
  // src/array/merge.ts
173
150
  function merge(prev, array, toKey) {
174
- if (!array && !prev) {
175
- return [];
176
- }
177
- if (!array) {
178
- return [...prev];
179
- }
180
- if (!prev) {
181
- return [];
182
- }
183
- if (!toKey) {
184
- return [...prev];
185
- }
186
151
  const keys2 = /* @__PURE__ */ new Map();
187
152
  for (const item of array) {
188
153
  keys2.set(toKey(item), item);
@@ -206,9 +171,6 @@ function objectify(array, getKey, getValue = (item) => item) {
206
171
 
207
172
  // src/array/replace.ts
208
173
  function replace(array, newItem, match) {
209
- if (!array) {
210
- return [];
211
- }
212
174
  if (newItem === void 0) {
213
175
  return [...array];
214
176
  }
@@ -224,15 +186,9 @@ function replace(array, newItem, match) {
224
186
 
225
187
  // src/array/replaceOrAppend.ts
226
188
  function replaceOrAppend(array, newItem, match) {
227
- if (!array && !newItem) {
228
- return [];
229
- }
230
- if (!newItem) {
189
+ if (newItem === void 0) {
231
190
  return [...array];
232
191
  }
233
- if (!array) {
234
- return [newItem];
235
- }
236
192
  const out = array.slice();
237
193
  for (let index = 0; index < array.length; index++) {
238
194
  if (match(array[index], index)) {
@@ -246,9 +202,6 @@ function replaceOrAppend(array, newItem, match) {
246
202
 
247
203
  // src/array/select.ts
248
204
  function select(array, mapper, condition) {
249
- if (!array) {
250
- return [];
251
- }
252
205
  let mapped;
253
206
  return array.reduce((acc, item, index) => {
254
207
  if (condition) {
@@ -262,9 +215,6 @@ function select(array, mapper, condition) {
262
215
 
263
216
  // src/array/selectFirst.ts
264
217
  function selectFirst(array, mapper, condition) {
265
- if (!array) {
266
- return void 0;
267
- }
268
218
  let foundIndex = -1;
269
219
  const found = array.find((item, index) => {
270
220
  foundIndex = index;
@@ -292,9 +242,6 @@ function sift(array) {
292
242
 
293
243
  // src/array/sort.ts
294
244
  function sort(array, getter, desc = false) {
295
- if (!array) {
296
- return [];
297
- }
298
245
  const asc = (a, b) => getter(a) - getter(b);
299
246
  const dsc = (a, b) => getter(b) - getter(a);
300
247
  return array.slice().sort(desc === true ? dsc : asc);
@@ -302,9 +249,6 @@ function sort(array, getter, desc = false) {
302
249
 
303
250
  // src/array/toggle.ts
304
251
  function toggle(array, item, toKey, options) {
305
- if (!array) {
306
- return item !== void 0 ? [item] : [];
307
- }
308
252
  if (item === void 0) {
309
253
  return [...array];
310
254
  }
@@ -340,9 +284,6 @@ function unique(array, toKey) {
340
284
 
341
285
  // src/array/unzip.ts
342
286
  function unzip(arrays) {
343
- if (!arrays || !arrays.length) {
344
- return [];
345
- }
346
287
  const out = new Array(
347
288
  arrays.reduce((max2, arr) => Math.max(max2, arr.length), 0)
348
289
  );
@@ -361,9 +302,6 @@ function zip(...arrays) {
361
302
 
362
303
  // src/array/zipToObject.ts
363
304
  function zipToObject(keys2, values) {
364
- if (!keys2 || !keys2.length) {
365
- return {};
366
- }
367
305
  const getValue = isFunction(values) ? values : isArray(values) ? (_k, i) => values[i] : (_k, _i) => values;
368
306
  return keys2.reduce(
369
307
  (acc, key, idx) => {
@@ -450,9 +388,6 @@ function guard(func, shouldGuard) {
450
388
 
451
389
  // src/async/map.ts
452
390
  async function map(array, asyncMapFunc) {
453
- if (!array) {
454
- return [];
455
- }
456
391
  const result = [];
457
392
  let index = 0;
458
393
  for (const value of array) {
@@ -521,17 +456,20 @@ async function parallel(options, array, func) {
521
456
  }
522
457
 
523
458
  // src/async/reduce.ts
524
- async function reduce(array, asyncReducer, initValue) {
525
- const initProvided = initValue !== void 0;
526
- if (!initProvided && (array == null ? void 0 : array.length) < 1) {
527
- throw new Error("Cannot reduce empty array with no init value");
459
+ async function reduce(array, reducer, initialValue) {
460
+ const indices = array.keys();
461
+ let acc = initialValue;
462
+ if (acc === void 0 && arguments.length < 3) {
463
+ if (!array.length) {
464
+ throw new TypeError("Reduce of empty array with no initial value");
465
+ }
466
+ acc = array[0];
467
+ indices.next();
528
468
  }
529
- const iter = initProvided ? array : array.slice(1);
530
- let value = initProvided ? initValue : array[0];
531
- for (const [i, item] of iter.entries()) {
532
- value = await asyncReducer(value, item, i);
469
+ for (const index of indices) {
470
+ acc = await reducer(acc, array[index], index);
533
471
  }
534
- return value;
472
+ return acc;
535
473
  }
536
474
 
537
475
  // src/async/retry.ts
@@ -638,31 +576,30 @@ function compose(...funcs) {
638
576
  }
639
577
 
640
578
  // src/curry/debounce.ts
641
- function debounce({ delay, leading }, func) {
642
- let timer = void 0;
643
- let active = true;
579
+ function debounce({ delay, leading }, callee) {
580
+ let timeout2;
644
581
  const debounced = (...args) => {
645
- if (active) {
646
- clearTimeout(timer);
647
- timer = setTimeout(() => {
648
- active && func(...args);
649
- timer = void 0;
650
- }, delay);
651
- if (leading) {
652
- func(...args);
653
- leading = false;
654
- }
582
+ clearTimeout(timeout2);
583
+ if (leading) {
584
+ leading = false;
585
+ callee(...args);
655
586
  } else {
656
- func(...args);
587
+ timeout2 = setTimeout(
588
+ debounced.flush = () => {
589
+ debounced.flush = noop;
590
+ clearTimeout(timeout2);
591
+ callee(...args);
592
+ },
593
+ delay
594
+ );
657
595
  }
658
596
  };
659
- debounced.isPending = () => {
660
- return timer !== void 0;
661
- };
597
+ debounced.callee = callee;
598
+ debounced.flush = noop;
662
599
  debounced.cancel = () => {
663
- active = false;
600
+ debounced.flush = noop;
601
+ clearTimeout(timeout2);
664
602
  };
665
- debounced.flush = (...args) => func(...args);
666
603
  return debounced;
667
604
  }
668
605
 
@@ -801,15 +738,7 @@ function clamp(n, min2, max2) {
801
738
  }
802
739
 
803
740
  // src/number/inRange.ts
804
- function inRange(number, start, end) {
805
- const isTypeSafe = typeof number === "number" && typeof start === "number" && (typeof end === "undefined" || typeof end === "number");
806
- if (!isTypeSafe) {
807
- return false;
808
- }
809
- if (typeof end === "undefined") {
810
- end = start;
811
- start = 0;
812
- }
741
+ function inRange(number, start, end = 0) {
813
742
  return number >= Math.min(start, end) && number < Math.max(start, end);
814
743
  }
815
744
 
@@ -820,7 +749,7 @@ function lerp(from, to, amount) {
820
749
 
821
750
  // src/number/max.ts
822
751
  function max(array, getter) {
823
- if (!array || (array.length ?? 0) === 0) {
752
+ if (!array.length) {
824
753
  return null;
825
754
  }
826
755
  const get2 = getter ?? ((v) => v);
@@ -829,7 +758,7 @@ function max(array, getter) {
829
758
 
830
759
  // src/number/min.ts
831
760
  function min(array, getter) {
832
- if (!array || (array.length ?? 0) === 0) {
761
+ if (!array.length) {
833
762
  return null;
834
763
  }
835
764
  const get2 = getter ?? ((v) => v);
@@ -879,9 +808,6 @@ function toInt(value, defaultValue) {
879
808
 
880
809
  // src/object/assign.ts
881
810
  function assign(initial, override) {
882
- if (!initial || !override) {
883
- return initial ?? override ?? {};
884
- }
885
811
  const proto = Object.getPrototypeOf(initial);
886
812
  const merged = proto ? { ...initial } : Object.assign(Object.create(proto), initial);
887
813
  for (const key of Object.keys(override)) {
@@ -892,12 +818,6 @@ function assign(initial, override) {
892
818
 
893
819
  // src/object/clone.ts
894
820
  function clone(obj) {
895
- if (isPrimitive(obj)) {
896
- return obj;
897
- }
898
- if (typeof obj === "function") {
899
- return obj.bind({});
900
- }
901
821
  const proto = Object.getPrototypeOf(obj);
902
822
  const newObj = typeof (proto == null ? void 0 : proto.constructor) === "function" ? new proto.constructor() : Object.create(proto);
903
823
  for (const key of Object.getOwnPropertyNames(obj)) {
@@ -975,9 +895,6 @@ function cloneDeep(root, customStrategy) {
975
895
 
976
896
  // src/object/construct.ts
977
897
  function construct(obj) {
978
- if (!obj) {
979
- return {};
980
- }
981
898
  return Object.keys(obj).reduce((acc, path) => {
982
899
  return set(acc, path, obj[path]);
983
900
  }, {});
@@ -985,9 +902,6 @@ function construct(obj) {
985
902
 
986
903
  // src/object/crush.ts
987
904
  function crush(value) {
988
- if (!value) {
989
- return {};
990
- }
991
905
  return function crushReducer(crushed, value2, path) {
992
906
  if (isObject(value2) || isArray(value2)) {
993
907
  for (const [prop, propValue] of Object.entries(value2)) {
@@ -1030,9 +944,6 @@ function get(value, path, defaultValue) {
1030
944
 
1031
945
  // src/object/invert.ts
1032
946
  function invert(obj) {
1033
- if (!obj) {
1034
- return {};
1035
- }
1036
947
  const keys2 = Object.keys(obj);
1037
948
  return keys2.reduce(
1038
949
  (acc, key) => {
@@ -1045,9 +956,6 @@ function invert(obj) {
1045
956
 
1046
957
  // src/object/keys.ts
1047
958
  function keys(value) {
1048
- if (!value) {
1049
- return [];
1050
- }
1051
959
  const keys2 = [];
1052
960
  const keyPath = [];
1053
961
  const recurse = (value2) => {
@@ -1073,14 +981,7 @@ function keys(value) {
1073
981
 
1074
982
  // src/object/listify.ts
1075
983
  function listify(obj, toItem) {
1076
- if (!obj) {
1077
- return [];
1078
- }
1079
- const entries = Object.entries(obj);
1080
- if (entries.length === 0) {
1081
- return [];
1082
- }
1083
- return entries.reduce((acc, entry) => {
984
+ return Object.entries(obj).reduce((acc, entry) => {
1084
985
  acc.push(toItem(entry[0], entry[1]));
1085
986
  return acc;
1086
987
  }, []);
@@ -1093,9 +994,6 @@ function lowerize(obj) {
1093
994
 
1094
995
  // src/object/mapEntries.ts
1095
996
  function mapEntries(obj, toEntry) {
1096
- if (!obj) {
1097
- return {};
1098
- }
1099
997
  return Object.entries(obj).reduce(
1100
998
  (acc, [key, value]) => {
1101
999
  const [newKey, newValue] = toEntry(key, value);
@@ -1131,10 +1029,7 @@ function mapValues(obj, mapFunc) {
1131
1029
 
1132
1030
  // src/object/omit.ts
1133
1031
  function omit(obj, keys2) {
1134
- if (!obj) {
1135
- return {};
1136
- }
1137
- if (!keys2 || keys2.length === 0) {
1032
+ if (keys2.length === 0) {
1138
1033
  return obj;
1139
1034
  }
1140
1035
  return keys2.reduce(
@@ -1148,9 +1043,6 @@ function omit(obj, keys2) {
1148
1043
 
1149
1044
  // src/object/pick.ts
1150
1045
  function pick(obj, filter) {
1151
- if (!obj) {
1152
- return {};
1153
- }
1154
1046
  let keys2 = filter;
1155
1047
  if (isArray(filter)) {
1156
1048
  filter = null;
@@ -1167,28 +1059,20 @@ function pick(obj, filter) {
1167
1059
 
1168
1060
  // src/object/set.ts
1169
1061
  function set(initial, path, value) {
1170
- if (!initial) {
1171
- return {};
1172
- }
1173
- if (!path || value === void 0) {
1062
+ if (value === void 0) {
1174
1063
  return initial;
1175
1064
  }
1176
1065
  const root = clone(initial);
1177
1066
  const keys2 = path.match(/[^.[\]]+/g);
1178
- if (keys2) {
1179
- keys2.reduce(
1180
- (object, key, i) => i < keys2.length - 1 ? object[key] ??= isIntString(keys2[i + 1]) ? [] : {} : object[key] = value,
1181
- root
1182
- );
1183
- }
1067
+ keys2 == null ? void 0 : keys2.reduce(
1068
+ (object, key, i) => i < keys2.length - 1 ? object[key] ??= isIntString(keys2[i + 1]) ? [] : {} : object[key] = value,
1069
+ root
1070
+ );
1184
1071
  return root;
1185
1072
  }
1186
1073
 
1187
1074
  // src/object/shake.ts
1188
1075
  function shake(obj, filter = (value) => value === void 0) {
1189
- if (!obj) {
1190
- return {};
1191
- }
1192
1076
  return Object.keys(obj).reduce((acc, key) => {
1193
1077
  if (!filter(obj[key])) {
1194
1078
  acc[key] = obj[key];
@@ -1395,14 +1279,7 @@ var series = (items, toKey = (item) => `${item}`) => {
1395
1279
 
1396
1280
  // src/string/camel.ts
1397
1281
  function camel(str) {
1398
- var _a;
1399
- 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())) ?? [];
1400
- if (parts.length === 0) {
1401
- return "";
1402
- }
1403
- if (parts.length === 1) {
1404
- return parts[0];
1405
- }
1282
+ const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
1406
1283
  return parts.reduce((acc, part) => {
1407
1284
  return `${acc}${part.charAt(0).toUpperCase()}${part.slice(1)}`;
1408
1285
  });
@@ -1410,23 +1287,13 @@ function camel(str) {
1410
1287
 
1411
1288
  // src/string/capitalize.ts
1412
1289
  function capitalize(str) {
1413
- if (!str || str.length === 0) {
1414
- return "";
1415
- }
1416
1290
  const lower = str.toLowerCase();
1417
1291
  return lower.substring(0, 1).toUpperCase() + lower.substring(1, lower.length);
1418
1292
  }
1419
1293
 
1420
1294
  // src/string/dash.ts
1421
1295
  function dash(str) {
1422
- var _a;
1423
- 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())) ?? [];
1424
- if (parts.length === 0) {
1425
- return "";
1426
- }
1427
- if (parts.length === 1) {
1428
- return parts[0];
1429
- }
1296
+ const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
1430
1297
  return parts.reduce((acc, part) => {
1431
1298
  return `${acc}-${part.toLowerCase()}`;
1432
1299
  });
@@ -1458,9 +1325,6 @@ function dedent(text, ...values) {
1458
1325
 
1459
1326
  // src/string/pascal.ts
1460
1327
  function pascal(str) {
1461
- if (!str) {
1462
- return "";
1463
- }
1464
1328
  const result = str.replace(
1465
1329
  /(?:[^\w\d]|_|\s)+(\w)([A-Z]+)?/g,
1466
1330
  (_, firstCharacter, capitalizedLetters) => {
@@ -1523,13 +1387,7 @@ function similarity(str1, str2) {
1523
1387
 
1524
1388
  // src/string/snake.ts
1525
1389
  function snake(str, options) {
1526
- const parts = (str == null ? void 0 : str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase())) ?? [];
1527
- if (parts.length === 0) {
1528
- return "";
1529
- }
1530
- if (parts.length === 1) {
1531
- return parts[0];
1532
- }
1390
+ const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
1533
1391
  const result = parts.reduce((acc, part) => {
1534
1392
  return `${acc}_${part.toLowerCase()}`;
1535
1393
  });
@@ -1550,17 +1408,11 @@ function template(str, data, regex = /\{\{(.+?)\}\}/g) {
1550
1408
 
1551
1409
  // src/string/title.ts
1552
1410
  function title(str) {
1553
- if (!str) {
1554
- return "";
1555
- }
1556
1411
  return str.split(/(?=[A-Z])|[\.\-\s_]/).map((s) => s.trim()).filter((s) => !!s).map((s) => capitalize(s.toLowerCase())).join(" ");
1557
1412
  }
1558
1413
 
1559
1414
  // src/string/trim.ts
1560
1415
  function trim(str, charsToTrim = " ") {
1561
- if (!str) {
1562
- return "";
1563
- }
1564
1416
  const toTrim = charsToTrim.replace(/[\W]{1}/g, "\\$&");
1565
1417
  const regex = new RegExp(`^[${toTrim}]+|[${toTrim}]+$`, "g");
1566
1418
  return str.replace(regex, "");
@@ -1653,7 +1505,7 @@ function isError(value) {
1653
1505
 
1654
1506
  // src/typed/isFloat.ts
1655
1507
  function isFloat(value) {
1656
- return isNumber(value) && value % 1 !== 0;
1508
+ return isNumber(value) && !Number.isNaN(value) && value % 1 !== 0;
1657
1509
  }
1658
1510
 
1659
1511
  // src/typed/isFunction.ts
@@ -1690,7 +1542,7 @@ function isNullish(value) {
1690
1542
 
1691
1543
  // src/typed/isNumber.ts
1692
1544
  function isNumber(value) {
1693
- return typeof value === "number" && !Number.isNaN(value);
1545
+ return typeof value === "number";
1694
1546
  }
1695
1547
 
1696
1548
  // src/typed/isObject.ts
@@ -332,6 +332,7 @@ declare function merge<T>(prev: readonly T[], array: readonly T[], toKey: (item:
332
332
  */
333
333
  declare function objectify<T, Key extends string | number | symbol, Value = T>(array: readonly T[], getKey: (item: T) => Key, getValue?: (item: T) => Value): Record<Key, Value>;
334
334
 
335
+ type Defined$1<T> = T & ({} | null);
335
336
  /**
336
337
  * Replace an element in an array with a new item without modifying
337
338
  * the array and return the new value.
@@ -344,8 +345,9 @@ declare function objectify<T, Key extends string | number | symbol, Value = T>(a
344
345
  * ```
345
346
  * @version 12.1.0
346
347
  */
347
- declare function replace<T>(array: readonly T[], newItem: T, match: (item: T, idx: number) => boolean): T[];
348
+ declare function replace<T, U>(array: readonly T[], newItem: U, match: (item: T, idx: number) => boolean): (T | Defined$1<U>)[];
348
349
 
350
+ type Defined<T> = T & ({} | null);
349
351
  /**
350
352
  * Replace the first occurrence of an item in an array where the
351
353
  * `match` function returns true. If no items match, append the new
@@ -362,7 +364,7 @@ declare function replace<T>(array: readonly T[], newItem: T, match: (item: T, id
362
364
  * ```
363
365
  * @version 12.1.0
364
366
  */
365
- declare function replaceOrAppend<T>(array: readonly T[], newItem: T, match: (a: T, idx: number) => boolean): T[];
367
+ declare function replaceOrAppend<T, U>(array: readonly T[], newItem: U, match: (a: T, idx: number) => boolean): (T | Defined<U>)[];
366
368
 
367
369
  /**
368
370
  * Select performs a filter and a mapper inside of a reduce, only
@@ -738,7 +740,8 @@ declare function parallel<T, K>(options: ParallelOptions | number, array: readon
738
740
  * ```
739
741
  * @version 12.1.0
740
742
  */
741
- declare function reduce<T, K>(array: readonly T[], asyncReducer: (acc: K, item: T, index: number) => Promise<K>, initValue?: K): Promise<K>;
743
+ declare function reduce<T, K>(array: readonly T[], reducer: (acc: K, item: T, index: number) => Promise<K>, initialValue: K): Promise<K>;
744
+ declare function reduce<T, K>(array: readonly T[], reducer: (acc: K, item: T, index: number) => Promise<K>): Promise<K>;
742
745
 
743
746
  type AbortSignal = {
744
747
  throwIfAborted(): void;
@@ -944,7 +947,7 @@ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[
944
947
  declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, F7NextArgs extends any[], F7Result, F8NextArgs extends any[], F8Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => F7Result) => (...args: F5NextArgs) => F6Result, f7: (next: (...args: F7NextArgs) => LastResult) => (...args: F6NextArgs) => F7Result, f8: (next: (...args: F8NextArgs) => LastResult) => (...args: F7NextArgs) => F8Result, last: (...args: F8NextArgs) => LastResult): (...args: F1Args) => F1Result;
945
948
  declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, F7NextArgs extends any[], F7Result, F8NextArgs extends any[], F8Result, F9NextArgs extends any[], F9Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => F7Result) => (...args: F5NextArgs) => F6Result, f7: (next: (...args: F7NextArgs) => LastResult) => (...args: F6NextArgs) => F7Result, f8: (next: (...args: F8NextArgs) => LastResult) => (...args: F7NextArgs) => F8Result, f9: (next: (...args: F9NextArgs) => LastResult) => (...args: F8NextArgs) => F9Result, last: (...args: F9NextArgs) => LastResult): (...args: F1Args) => F1Result;
946
949
 
947
- type DebounceFunction<TArgs extends any[]> = {
950
+ interface DebounceFunction<TArgs extends any[] = any> {
948
951
  (...args: TArgs): void;
949
952
  /**
950
953
  * When called, future invocations of the debounced function are
@@ -952,15 +955,16 @@ type DebounceFunction<TArgs extends any[]> = {
952
955
  */
953
956
  cancel(): void;
954
957
  /**
955
- * Returns `true` if the underlying function is scheduled to be
956
- * called once the delay has passed.
958
+ * If the debounced function is pending, it will be invoked
959
+ * immediately and the result will be returned. Otherwise,
960
+ * `undefined` will be returned.
957
961
  */
958
- isPending(): boolean;
962
+ flush(...args: TArgs): void;
959
963
  /**
960
- * Invoke the underlying function immediately.
964
+ * The underlying function
961
965
  */
962
- flush(...args: TArgs): void;
963
- };
966
+ readonly callee: (...args: TArgs) => unknown;
967
+ }
964
968
  interface DebounceOptions {
965
969
  delay: number;
966
970
  /**
@@ -973,11 +977,11 @@ interface DebounceOptions {
973
977
  leading?: boolean;
974
978
  }
975
979
  /**
976
- * Returns a new function that will only call your callback after
977
- * `delay` milliseconds have passed without any invocations.
980
+ * Returns a new function that will only call the source function
981
+ * after `delay` milliseconds have passed without any invocations.
978
982
  *
979
- * The debounced function has a few methods, such as `cancel`,
980
- * `isPending`, and `flush`.
983
+ * See the documentation (or the `DebounceFunction` type) for details
984
+ * on the methods and properties available on the returned function.
981
985
  *
982
986
  * @see https://radashi.js.org/reference/curry/debounce
983
987
  * @example
@@ -992,7 +996,7 @@ interface DebounceOptions {
992
996
  * ```
993
997
  * @version 12.1.0
994
998
  */
995
- declare function debounce<TArgs extends any[]>({ delay, leading }: DebounceOptions, func: (...args: TArgs) => any): DebounceFunction<TArgs>;
999
+ declare function debounce<TArgs extends any[]>({ delay, leading }: DebounceOptions, callee: (...args: TArgs) => unknown): DebounceFunction<TArgs>;
996
1000
 
997
1001
  /**
998
1002
  * Flip the first two arguments of a function.
@@ -1468,7 +1472,7 @@ declare function range<T = number>(startOrLength: number, end?: number, valueOrM
1468
1472
  * @example
1469
1473
  * ```ts
1470
1474
  * round(123.456)
1471
- * // => 123.5
1475
+ * // => 123
1472
1476
  *
1473
1477
  * round(1234.56, -2)
1474
1478
  * // => 1200
@@ -1634,7 +1638,7 @@ TOverride | (IsOptional extends true ? TInitial : never) : Extract<TOverride, ob
1634
1638
  * ```
1635
1639
  * @version 12.1.0
1636
1640
  */
1637
- declare function clone<T>(obj: T): T;
1641
+ declare function clone<T extends object>(obj: T): T;
1638
1642
 
1639
1643
  /**
1640
1644
  * A strategy for cloning objects with `cloneDeep`.
@@ -2356,7 +2360,7 @@ declare function template(str: string, data: Record<string, any>, regex?: RegExp
2356
2360
  * ```
2357
2361
  * @version 12.1.0
2358
2362
  */
2359
- declare function title(str: string | null | undefined): string;
2363
+ declare function title(str: string): string;
2360
2364
 
2361
2365
  /**
2362
2366
  * Trims all prefix and suffix characters from the given string. Like
@@ -2373,7 +2377,7 @@ declare function title(str: string | null | undefined): string;
2373
2377
  * ```
2374
2378
  * @version 12.1.0
2375
2379
  */
2376
- declare function trim(str: string | null | undefined, charsToTrim?: string): string;
2380
+ declare function trim(str: string, charsToTrim?: string): string;
2377
2381
 
2378
2382
  /**
2379
2383
  * Literally just `Array.isArray` but with better type inference.
@@ -2619,7 +2623,7 @@ declare function isNullish(value: unknown): value is null | undefined;
2619
2623
  * ```ts
2620
2624
  * isNumber(0) // => true
2621
2625
  * isNumber('0') // => false
2622
- * isNumber(NaN) // => false
2626
+ * isNumber(NaN) // => true
2623
2627
  * ```
2624
2628
  * @version 12.1.0
2625
2629
  */