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.d.ts CHANGED
@@ -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
  */
package/dist/radashi.js CHANGED
@@ -1,8 +1,5 @@
1
1
  // src/array/alphabetical.ts
2
2
  function alphabetical(array, getter, direction = "asc") {
3
- if (!array) {
4
- return [];
5
- }
6
3
  const asc = (a, b) => `${getter(a)}`.localeCompare(getter(b));
7
4
  const dsc = (a, b) => `${getter(b)}`.localeCompare(getter(a));
8
5
  return array.slice().sort(direction === "desc" ? dsc : asc);
@@ -10,10 +7,7 @@ function alphabetical(array, getter, direction = "asc") {
10
7
 
11
8
  // src/array/boil.ts
12
9
  function boil(array, compareFunc) {
13
- if (!array || (array.length ?? 0) === 0) {
14
- return null;
15
- }
16
- return array.reduce(compareFunc);
10
+ return array.length ? array.reduce(compareFunc) : null;
17
11
  }
18
12
 
19
13
  // src/array/cartesianProduct.ts
@@ -54,9 +48,6 @@ function cluster(array, size = 2) {
54
48
 
55
49
  // src/array/counting.ts
56
50
  function counting(array, identity) {
57
- if (!array) {
58
- return {};
59
- }
60
51
  return array.reduce(
61
52
  (acc, item) => {
62
53
  const id = identity(item);
@@ -69,15 +60,6 @@ function counting(array, identity) {
69
60
 
70
61
  // src/array/diff.ts
71
62
  function diff(root, other, identity = (t) => t) {
72
- if (!(root == null ? void 0 : root.length) && !(other == null ? void 0 : other.length)) {
73
- return [];
74
- }
75
- if ((root == null ? void 0 : root.length) === void 0) {
76
- return [...other];
77
- }
78
- if (!(other == null ? void 0 : other.length)) {
79
- return [...root];
80
- }
81
63
  const bKeys = other.reduce(
82
64
  (acc, item) => {
83
65
  acc[identity(item)] = true;
@@ -90,7 +72,7 @@ function diff(root, other, identity = (t) => t) {
90
72
 
91
73
  // src/array/first.ts
92
74
  function first(array, defaultValue) {
93
- return (array == null ? void 0 : array.length) > 0 ? array[0] : defaultValue;
75
+ return array.length > 0 ? array[0] : defaultValue;
94
76
  }
95
77
 
96
78
  // src/array/flat.ts
@@ -104,10 +86,8 @@ function flat(lists) {
104
86
  // src/array/fork.ts
105
87
  function fork(array, condition) {
106
88
  const forked = [[], []];
107
- if (array) {
108
- for (const item of array) {
109
- forked[condition(item) ? 0 : 1].push(item);
110
- }
89
+ for (const item of array) {
90
+ forked[condition(item) ? 0 : 1].push(item);
111
91
  }
112
92
  return forked;
113
93
  }
@@ -129,9 +109,6 @@ function group(array, getGroupId) {
129
109
 
130
110
  // src/array/intersects.ts
131
111
  function intersects(listA, listB, identity) {
132
- if (!listA || !listB) {
133
- return false;
134
- }
135
112
  if (identity) {
136
113
  const known = new Set(listA.map(identity));
137
114
  return listB.some((item) => known.has(identity(item)));
@@ -150,7 +127,7 @@ function iterate(count, func, initValue) {
150
127
 
151
128
  // src/array/last.ts
152
129
  function last(array, defaultValue) {
153
- return (array == null ? void 0 : array.length) > 0 ? array[array.length - 1] : defaultValue;
130
+ return array.length > 0 ? array[array.length - 1] : defaultValue;
154
131
  }
155
132
 
156
133
  // src/array/list.ts
@@ -169,18 +146,6 @@ function mapify(array, getKey, getValue = (item) => item) {
169
146
 
170
147
  // src/array/merge.ts
171
148
  function merge(prev, array, toKey) {
172
- if (!array && !prev) {
173
- return [];
174
- }
175
- if (!array) {
176
- return [...prev];
177
- }
178
- if (!prev) {
179
- return [];
180
- }
181
- if (!toKey) {
182
- return [...prev];
183
- }
184
149
  const keys2 = /* @__PURE__ */ new Map();
185
150
  for (const item of array) {
186
151
  keys2.set(toKey(item), item);
@@ -204,9 +169,6 @@ function objectify(array, getKey, getValue = (item) => item) {
204
169
 
205
170
  // src/array/replace.ts
206
171
  function replace(array, newItem, match) {
207
- if (!array) {
208
- return [];
209
- }
210
172
  if (newItem === void 0) {
211
173
  return [...array];
212
174
  }
@@ -222,15 +184,9 @@ function replace(array, newItem, match) {
222
184
 
223
185
  // src/array/replaceOrAppend.ts
224
186
  function replaceOrAppend(array, newItem, match) {
225
- if (!array && !newItem) {
226
- return [];
227
- }
228
- if (!newItem) {
187
+ if (newItem === void 0) {
229
188
  return [...array];
230
189
  }
231
- if (!array) {
232
- return [newItem];
233
- }
234
190
  const out = array.slice();
235
191
  for (let index = 0; index < array.length; index++) {
236
192
  if (match(array[index], index)) {
@@ -244,9 +200,6 @@ function replaceOrAppend(array, newItem, match) {
244
200
 
245
201
  // src/array/select.ts
246
202
  function select(array, mapper, condition) {
247
- if (!array) {
248
- return [];
249
- }
250
203
  let mapped;
251
204
  return array.reduce((acc, item, index) => {
252
205
  if (condition) {
@@ -260,9 +213,6 @@ function select(array, mapper, condition) {
260
213
 
261
214
  // src/array/selectFirst.ts
262
215
  function selectFirst(array, mapper, condition) {
263
- if (!array) {
264
- return void 0;
265
- }
266
216
  let foundIndex = -1;
267
217
  const found = array.find((item, index) => {
268
218
  foundIndex = index;
@@ -290,9 +240,6 @@ function sift(array) {
290
240
 
291
241
  // src/array/sort.ts
292
242
  function sort(array, getter, desc = false) {
293
- if (!array) {
294
- return [];
295
- }
296
243
  const asc = (a, b) => getter(a) - getter(b);
297
244
  const dsc = (a, b) => getter(b) - getter(a);
298
245
  return array.slice().sort(desc === true ? dsc : asc);
@@ -300,9 +247,6 @@ function sort(array, getter, desc = false) {
300
247
 
301
248
  // src/array/toggle.ts
302
249
  function toggle(array, item, toKey, options) {
303
- if (!array) {
304
- return item !== void 0 ? [item] : [];
305
- }
306
250
  if (item === void 0) {
307
251
  return [...array];
308
252
  }
@@ -338,9 +282,6 @@ function unique(array, toKey) {
338
282
 
339
283
  // src/array/unzip.ts
340
284
  function unzip(arrays) {
341
- if (!arrays || !arrays.length) {
342
- return [];
343
- }
344
285
  const out = new Array(
345
286
  arrays.reduce((max2, arr) => Math.max(max2, arr.length), 0)
346
287
  );
@@ -359,9 +300,6 @@ function zip(...arrays) {
359
300
 
360
301
  // src/array/zipToObject.ts
361
302
  function zipToObject(keys2, values) {
362
- if (!keys2 || !keys2.length) {
363
- return {};
364
- }
365
303
  const getValue = isFunction(values) ? values : isArray(values) ? (_k, i) => values[i] : (_k, _i) => values;
366
304
  return keys2.reduce(
367
305
  (acc, key, idx) => {
@@ -448,9 +386,6 @@ function guard(func, shouldGuard) {
448
386
 
449
387
  // src/async/map.ts
450
388
  async function map(array, asyncMapFunc) {
451
- if (!array) {
452
- return [];
453
- }
454
389
  const result = [];
455
390
  let index = 0;
456
391
  for (const value of array) {
@@ -519,17 +454,20 @@ async function parallel(options, array, func) {
519
454
  }
520
455
 
521
456
  // src/async/reduce.ts
522
- async function reduce(array, asyncReducer, initValue) {
523
- const initProvided = initValue !== void 0;
524
- if (!initProvided && (array == null ? void 0 : array.length) < 1) {
525
- throw new Error("Cannot reduce empty array with no init value");
457
+ async function reduce(array, reducer, initialValue) {
458
+ const indices = array.keys();
459
+ let acc = initialValue;
460
+ if (acc === void 0 && arguments.length < 3) {
461
+ if (!array.length) {
462
+ throw new TypeError("Reduce of empty array with no initial value");
463
+ }
464
+ acc = array[0];
465
+ indices.next();
526
466
  }
527
- const iter = initProvided ? array : array.slice(1);
528
- let value = initProvided ? initValue : array[0];
529
- for (const [i, item] of iter.entries()) {
530
- value = await asyncReducer(value, item, i);
467
+ for (const index of indices) {
468
+ acc = await reducer(acc, array[index], index);
531
469
  }
532
- return value;
470
+ return acc;
533
471
  }
534
472
 
535
473
  // src/async/retry.ts
@@ -636,31 +574,30 @@ function compose(...funcs) {
636
574
  }
637
575
 
638
576
  // src/curry/debounce.ts
639
- function debounce({ delay, leading }, func) {
640
- let timer = void 0;
641
- let active = true;
577
+ function debounce({ delay, leading }, callee) {
578
+ let timeout2;
642
579
  const debounced = (...args) => {
643
- if (active) {
644
- clearTimeout(timer);
645
- timer = setTimeout(() => {
646
- active && func(...args);
647
- timer = void 0;
648
- }, delay);
649
- if (leading) {
650
- func(...args);
651
- leading = false;
652
- }
580
+ clearTimeout(timeout2);
581
+ if (leading) {
582
+ leading = false;
583
+ callee(...args);
653
584
  } else {
654
- func(...args);
585
+ timeout2 = setTimeout(
586
+ debounced.flush = () => {
587
+ debounced.flush = noop;
588
+ clearTimeout(timeout2);
589
+ callee(...args);
590
+ },
591
+ delay
592
+ );
655
593
  }
656
594
  };
657
- debounced.isPending = () => {
658
- return timer !== void 0;
659
- };
595
+ debounced.callee = callee;
596
+ debounced.flush = noop;
660
597
  debounced.cancel = () => {
661
- active = false;
598
+ debounced.flush = noop;
599
+ clearTimeout(timeout2);
662
600
  };
663
- debounced.flush = (...args) => func(...args);
664
601
  return debounced;
665
602
  }
666
603
 
@@ -799,15 +736,7 @@ function clamp(n, min2, max2) {
799
736
  }
800
737
 
801
738
  // src/number/inRange.ts
802
- function inRange(number, start, end) {
803
- const isTypeSafe = typeof number === "number" && typeof start === "number" && (typeof end === "undefined" || typeof end === "number");
804
- if (!isTypeSafe) {
805
- return false;
806
- }
807
- if (typeof end === "undefined") {
808
- end = start;
809
- start = 0;
810
- }
739
+ function inRange(number, start, end = 0) {
811
740
  return number >= Math.min(start, end) && number < Math.max(start, end);
812
741
  }
813
742
 
@@ -818,7 +747,7 @@ function lerp(from, to, amount) {
818
747
 
819
748
  // src/number/max.ts
820
749
  function max(array, getter) {
821
- if (!array || (array.length ?? 0) === 0) {
750
+ if (!array.length) {
822
751
  return null;
823
752
  }
824
753
  const get2 = getter ?? ((v) => v);
@@ -827,7 +756,7 @@ function max(array, getter) {
827
756
 
828
757
  // src/number/min.ts
829
758
  function min(array, getter) {
830
- if (!array || (array.length ?? 0) === 0) {
759
+ if (!array.length) {
831
760
  return null;
832
761
  }
833
762
  const get2 = getter ?? ((v) => v);
@@ -877,9 +806,6 @@ function toInt(value, defaultValue) {
877
806
 
878
807
  // src/object/assign.ts
879
808
  function assign(initial, override) {
880
- if (!initial || !override) {
881
- return initial ?? override ?? {};
882
- }
883
809
  const proto = Object.getPrototypeOf(initial);
884
810
  const merged = proto ? { ...initial } : Object.assign(Object.create(proto), initial);
885
811
  for (const key of Object.keys(override)) {
@@ -890,12 +816,6 @@ function assign(initial, override) {
890
816
 
891
817
  // src/object/clone.ts
892
818
  function clone(obj) {
893
- if (isPrimitive(obj)) {
894
- return obj;
895
- }
896
- if (typeof obj === "function") {
897
- return obj.bind({});
898
- }
899
819
  const proto = Object.getPrototypeOf(obj);
900
820
  const newObj = typeof (proto == null ? void 0 : proto.constructor) === "function" ? new proto.constructor() : Object.create(proto);
901
821
  for (const key of Object.getOwnPropertyNames(obj)) {
@@ -973,9 +893,6 @@ function cloneDeep(root, customStrategy) {
973
893
 
974
894
  // src/object/construct.ts
975
895
  function construct(obj) {
976
- if (!obj) {
977
- return {};
978
- }
979
896
  return Object.keys(obj).reduce((acc, path) => {
980
897
  return set(acc, path, obj[path]);
981
898
  }, {});
@@ -983,9 +900,6 @@ function construct(obj) {
983
900
 
984
901
  // src/object/crush.ts
985
902
  function crush(value) {
986
- if (!value) {
987
- return {};
988
- }
989
903
  return function crushReducer(crushed, value2, path) {
990
904
  if (isObject(value2) || isArray(value2)) {
991
905
  for (const [prop, propValue] of Object.entries(value2)) {
@@ -1028,9 +942,6 @@ function get(value, path, defaultValue) {
1028
942
 
1029
943
  // src/object/invert.ts
1030
944
  function invert(obj) {
1031
- if (!obj) {
1032
- return {};
1033
- }
1034
945
  const keys2 = Object.keys(obj);
1035
946
  return keys2.reduce(
1036
947
  (acc, key) => {
@@ -1043,9 +954,6 @@ function invert(obj) {
1043
954
 
1044
955
  // src/object/keys.ts
1045
956
  function keys(value) {
1046
- if (!value) {
1047
- return [];
1048
- }
1049
957
  const keys2 = [];
1050
958
  const keyPath = [];
1051
959
  const recurse = (value2) => {
@@ -1071,14 +979,7 @@ function keys(value) {
1071
979
 
1072
980
  // src/object/listify.ts
1073
981
  function listify(obj, toItem) {
1074
- if (!obj) {
1075
- return [];
1076
- }
1077
- const entries = Object.entries(obj);
1078
- if (entries.length === 0) {
1079
- return [];
1080
- }
1081
- return entries.reduce((acc, entry) => {
982
+ return Object.entries(obj).reduce((acc, entry) => {
1082
983
  acc.push(toItem(entry[0], entry[1]));
1083
984
  return acc;
1084
985
  }, []);
@@ -1091,9 +992,6 @@ function lowerize(obj) {
1091
992
 
1092
993
  // src/object/mapEntries.ts
1093
994
  function mapEntries(obj, toEntry) {
1094
- if (!obj) {
1095
- return {};
1096
- }
1097
995
  return Object.entries(obj).reduce(
1098
996
  (acc, [key, value]) => {
1099
997
  const [newKey, newValue] = toEntry(key, value);
@@ -1129,10 +1027,7 @@ function mapValues(obj, mapFunc) {
1129
1027
 
1130
1028
  // src/object/omit.ts
1131
1029
  function omit(obj, keys2) {
1132
- if (!obj) {
1133
- return {};
1134
- }
1135
- if (!keys2 || keys2.length === 0) {
1030
+ if (keys2.length === 0) {
1136
1031
  return obj;
1137
1032
  }
1138
1033
  return keys2.reduce(
@@ -1146,9 +1041,6 @@ function omit(obj, keys2) {
1146
1041
 
1147
1042
  // src/object/pick.ts
1148
1043
  function pick(obj, filter) {
1149
- if (!obj) {
1150
- return {};
1151
- }
1152
1044
  let keys2 = filter;
1153
1045
  if (isArray(filter)) {
1154
1046
  filter = null;
@@ -1165,28 +1057,20 @@ function pick(obj, filter) {
1165
1057
 
1166
1058
  // src/object/set.ts
1167
1059
  function set(initial, path, value) {
1168
- if (!initial) {
1169
- return {};
1170
- }
1171
- if (!path || value === void 0) {
1060
+ if (value === void 0) {
1172
1061
  return initial;
1173
1062
  }
1174
1063
  const root = clone(initial);
1175
1064
  const keys2 = path.match(/[^.[\]]+/g);
1176
- if (keys2) {
1177
- keys2.reduce(
1178
- (object, key, i) => i < keys2.length - 1 ? object[key] ??= isIntString(keys2[i + 1]) ? [] : {} : object[key] = value,
1179
- root
1180
- );
1181
- }
1065
+ keys2 == null ? void 0 : keys2.reduce(
1066
+ (object, key, i) => i < keys2.length - 1 ? object[key] ??= isIntString(keys2[i + 1]) ? [] : {} : object[key] = value,
1067
+ root
1068
+ );
1182
1069
  return root;
1183
1070
  }
1184
1071
 
1185
1072
  // src/object/shake.ts
1186
1073
  function shake(obj, filter = (value) => value === void 0) {
1187
- if (!obj) {
1188
- return {};
1189
- }
1190
1074
  return Object.keys(obj).reduce((acc, key) => {
1191
1075
  if (!filter(obj[key])) {
1192
1076
  acc[key] = obj[key];
@@ -1393,14 +1277,7 @@ var series = (items, toKey = (item) => `${item}`) => {
1393
1277
 
1394
1278
  // src/string/camel.ts
1395
1279
  function camel(str) {
1396
- var _a;
1397
- 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())) ?? [];
1398
- if (parts.length === 0) {
1399
- return "";
1400
- }
1401
- if (parts.length === 1) {
1402
- return parts[0];
1403
- }
1280
+ const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
1404
1281
  return parts.reduce((acc, part) => {
1405
1282
  return `${acc}${part.charAt(0).toUpperCase()}${part.slice(1)}`;
1406
1283
  });
@@ -1408,23 +1285,13 @@ function camel(str) {
1408
1285
 
1409
1286
  // src/string/capitalize.ts
1410
1287
  function capitalize(str) {
1411
- if (!str || str.length === 0) {
1412
- return "";
1413
- }
1414
1288
  const lower = str.toLowerCase();
1415
1289
  return lower.substring(0, 1).toUpperCase() + lower.substring(1, lower.length);
1416
1290
  }
1417
1291
 
1418
1292
  // src/string/dash.ts
1419
1293
  function dash(str) {
1420
- var _a;
1421
- 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())) ?? [];
1422
- if (parts.length === 0) {
1423
- return "";
1424
- }
1425
- if (parts.length === 1) {
1426
- return parts[0];
1427
- }
1294
+ const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
1428
1295
  return parts.reduce((acc, part) => {
1429
1296
  return `${acc}-${part.toLowerCase()}`;
1430
1297
  });
@@ -1456,9 +1323,6 @@ function dedent(text, ...values) {
1456
1323
 
1457
1324
  // src/string/pascal.ts
1458
1325
  function pascal(str) {
1459
- if (!str) {
1460
- return "";
1461
- }
1462
1326
  const result = str.replace(
1463
1327
  /(?:[^\w\d]|_|\s)+(\w)([A-Z]+)?/g,
1464
1328
  (_, firstCharacter, capitalizedLetters) => {
@@ -1521,13 +1385,7 @@ function similarity(str1, str2) {
1521
1385
 
1522
1386
  // src/string/snake.ts
1523
1387
  function snake(str, options) {
1524
- const parts = (str == null ? void 0 : str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase())) ?? [];
1525
- if (parts.length === 0) {
1526
- return "";
1527
- }
1528
- if (parts.length === 1) {
1529
- return parts[0];
1530
- }
1388
+ const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
1531
1389
  const result = parts.reduce((acc, part) => {
1532
1390
  return `${acc}_${part.toLowerCase()}`;
1533
1391
  });
@@ -1548,17 +1406,11 @@ function template(str, data, regex = /\{\{(.+?)\}\}/g) {
1548
1406
 
1549
1407
  // src/string/title.ts
1550
1408
  function title(str) {
1551
- if (!str) {
1552
- return "";
1553
- }
1554
1409
  return str.split(/(?=[A-Z])|[\.\-\s_]/).map((s) => s.trim()).filter((s) => !!s).map((s) => capitalize(s.toLowerCase())).join(" ");
1555
1410
  }
1556
1411
 
1557
1412
  // src/string/trim.ts
1558
1413
  function trim(str, charsToTrim = " ") {
1559
- if (!str) {
1560
- return "";
1561
- }
1562
1414
  const toTrim = charsToTrim.replace(/[\W]{1}/g, "\\$&");
1563
1415
  const regex = new RegExp(`^[${toTrim}]+|[${toTrim}]+$`, "g");
1564
1416
  return str.replace(regex, "");
@@ -1651,7 +1503,7 @@ function isError(value) {
1651
1503
 
1652
1504
  // src/typed/isFloat.ts
1653
1505
  function isFloat(value) {
1654
- return isNumber(value) && value % 1 !== 0;
1506
+ return isNumber(value) && !Number.isNaN(value) && value % 1 !== 0;
1655
1507
  }
1656
1508
 
1657
1509
  // src/typed/isFunction.ts
@@ -1688,7 +1540,7 @@ function isNullish(value) {
1688
1540
 
1689
1541
  // src/typed/isNumber.ts
1690
1542
  function isNumber(value) {
1691
- return typeof value === "number" && !Number.isNaN(value);
1543
+ return typeof value === "number";
1692
1544
  }
1693
1545
 
1694
1546
  // src/typed/isObject.ts