radashi 12.2.0-beta.6bdfb09 → 12.2.0-beta.7fb6e89

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
@@ -1,129 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all2) => {
7
- for (var name in all2)
8
- __defProp(target, name, { get: all2[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/mod.ts
21
- var mod_exports = {};
22
- __export(mod_exports, {
23
- AggregateError: () => AggregateError,
24
- all: () => all,
25
- alphabetical: () => alphabetical,
26
- assign: () => assign,
27
- boil: () => boil,
28
- callable: () => callable,
29
- camel: () => camel,
30
- capitalize: () => capitalize,
31
- chain: () => chain,
32
- clone: () => clone,
33
- cluster: () => cluster,
34
- compose: () => compose,
35
- construct: () => construct,
36
- counting: () => counting,
37
- crush: () => crush,
38
- dash: () => dash,
39
- debounce: () => debounce,
40
- defer: () => defer,
41
- diff: () => diff,
42
- draw: () => draw,
43
- filterKey: () => filterKey,
44
- first: () => first,
45
- flat: () => flat,
46
- fork: () => fork,
47
- get: () => get,
48
- group: () => group,
49
- guard: () => guard,
50
- inRange: () => inRange,
51
- intersects: () => intersects,
52
- invert: () => invert,
53
- isArray: () => isArray,
54
- isDate: () => isDate,
55
- isEmpty: () => isEmpty,
56
- isEqual: () => isEqual,
57
- isFloat: () => isFloat,
58
- isFunction: () => isFunction,
59
- isInt: () => isInt,
60
- isIntString: () => isIntString,
61
- isNumber: () => isNumber,
62
- isObject: () => isObject,
63
- isPlainObject: () => isPlainObject,
64
- isPrimitive: () => isPrimitive,
65
- isPromise: () => isPromise,
66
- isString: () => isString,
67
- isSymbol: () => isSymbol,
68
- iterate: () => iterate,
69
- keys: () => keys,
70
- last: () => last,
71
- list: () => list,
72
- listify: () => listify,
73
- lowerize: () => lowerize,
74
- map: () => map,
75
- mapEntries: () => mapEntries,
76
- mapKeys: () => mapKeys,
77
- mapValues: () => mapValues,
78
- mapify: () => mapify,
79
- max: () => max,
80
- memo: () => memo,
81
- merge: () => merge,
82
- min: () => min,
83
- objectify: () => objectify,
84
- omit: () => omit,
85
- parallel: () => parallel,
86
- partial: () => partial,
87
- partob: () => partob,
88
- pascal: () => pascal,
89
- pick: () => pick,
90
- proxied: () => proxied,
91
- random: () => random,
92
- range: () => range,
93
- reduce: () => reduce,
94
- replace: () => replace,
95
- replaceOrAppend: () => replaceOrAppend,
96
- retry: () => retry,
97
- round: () => round,
98
- select: () => select,
99
- selectFirst: () => selectFirst,
100
- series: () => series,
101
- set: () => set,
102
- shake: () => shake,
103
- shift: () => shift,
104
- shuffle: () => shuffle,
105
- sift: () => sift,
106
- sleep: () => sleep,
107
- snake: () => snake,
108
- sort: () => sort,
109
- sum: () => sum,
110
- template: () => template,
111
- throttle: () => throttle,
112
- title: () => title,
113
- toFloat: () => toFloat,
114
- toInt: () => toInt,
115
- toggle: () => toggle,
116
- trim: () => trim,
117
- try: () => tryit,
118
- tryit: () => tryit,
119
- uid: () => uid,
120
- unique: () => unique,
121
- unzip: () => unzip,
122
- upperize: () => upperize,
123
- zip: () => zip,
124
- zipToObject: () => zipToObject
125
- });
126
- module.exports = __toCommonJS(mod_exports);
1
+ 'use strict';
127
2
 
128
3
  // src/array/alphabetical.ts
129
4
  function alphabetical(array, getter, direction = "asc") {
@@ -143,6 +18,16 @@ function boil(array, compareFunc) {
143
18
  return array.reduce(compareFunc);
144
19
  }
145
20
 
21
+ // src/array/castArray.ts
22
+ function castArray(value) {
23
+ return Array.isArray(value) ? value.slice() : [value];
24
+ }
25
+
26
+ // src/array/castArrayIfExists.ts
27
+ function castArrayIfExists(value) {
28
+ return Array.isArray(value) ? value.slice() : value != null ? [value] : value;
29
+ }
30
+
146
31
  // src/array/cluster.ts
147
32
  function cluster(array, size = 2) {
148
33
  const clusters = [];
@@ -262,20 +147,11 @@ function list(startOrLength, end, valueOrMapper, step) {
262
147
  function mapify(array, getKey, getValue = (item) => item) {
263
148
  const map2 = /* @__PURE__ */ new Map();
264
149
  for (const item of array) {
265
- map2.set(getKey(item), getValue(item));
150
+ map2.set(getKey(item, map2.size), getValue(item, map2.size));
266
151
  }
267
152
  return map2;
268
153
  }
269
154
 
270
- // src/array/max.ts
271
- function max(array, getter) {
272
- if (!array || (array.length ?? 0) === 0) {
273
- return null;
274
- }
275
- const get2 = getter ?? ((v) => v);
276
- return array.reduce((a, b) => get2(a) > get2(b) ? a : b);
277
- }
278
-
279
155
  // src/array/merge.ts
280
156
  function merge(prev, array, toKey) {
281
157
  if (!array && !prev) {
@@ -297,15 +173,6 @@ function merge(prev, array, toKey) {
297
173
  });
298
174
  }
299
175
 
300
- // src/array/min.ts
301
- function min(array, getter) {
302
- if (!array || (array.length ?? 0) === 0) {
303
- return null;
304
- }
305
- const get2 = getter ?? ((v) => v);
306
- return array.reduce((a, b) => get2(a) < get2(b) ? a : b);
307
- }
308
-
309
176
  // src/array/objectify.ts
310
177
  function objectify(array, getKey, getValue = (item) => item) {
311
178
  return array.reduce(
@@ -317,19 +184,6 @@ function objectify(array, getKey, getValue = (item) => item) {
317
184
  );
318
185
  }
319
186
 
320
- // src/array/range.ts
321
- function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
322
- const mapper = isFunction(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
323
- const start = end ? startOrLength : 0;
324
- const final = end ?? startOrLength;
325
- for (let i = start; i <= final; i += step) {
326
- yield mapper(i);
327
- if (i + step > final) {
328
- break;
329
- }
330
- }
331
- }
332
-
333
187
  // src/array/replace.ts
334
188
  function replace(array, newItem, match) {
335
189
  if (!array) {
@@ -402,11 +256,11 @@ function selectFirst(array, mapper, condition) {
402
256
  // src/array/shift.ts
403
257
  function shift(arr, n) {
404
258
  if (arr.length === 0) {
405
- return arr;
259
+ return [...arr];
406
260
  }
407
261
  const shiftNumber = n % arr.length;
408
262
  if (shiftNumber === 0) {
409
- return arr;
263
+ return [...arr];
410
264
  }
411
265
  return [...arr.slice(-shiftNumber, arr.length), ...arr.slice(0, -shiftNumber)];
412
266
  }
@@ -426,32 +280,20 @@ function sort(array, getter, desc = false) {
426
280
  return array.slice().sort(desc === true ? dsc : asc);
427
281
  }
428
282
 
429
- // src/array/sum.ts
430
- function sum(array, fn) {
431
- return (array || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
432
- }
433
-
434
283
  // src/array/toggle.ts
435
284
  function toggle(array, item, toKey, options) {
436
- if (!array && !item) {
437
- return [];
438
- }
439
285
  if (!array) {
440
- return [item];
286
+ return item !== void 0 ? [item] : [];
441
287
  }
442
- if (!item) {
288
+ if (item === void 0) {
443
289
  return [...array];
444
290
  }
445
291
  const matcher = toKey ? (x, idx) => toKey(x, idx) === toKey(item, idx) : (x) => x === item;
446
292
  const existing = array.find(matcher);
447
- if (existing) {
293
+ if (existing !== void 0) {
448
294
  return array.filter((x, idx) => !matcher(x, idx));
449
295
  }
450
- const strategy = (options == null ? void 0 : options.strategy) ?? "append";
451
- if (strategy === "append") {
452
- return [...array, item];
453
- }
454
- return [item, ...array];
296
+ return (options == null ? void 0 : options.strategy) === "prepend" ? [item, ...array] : [...array, item];
455
297
  }
456
298
 
457
299
  // src/array/unique.ts
@@ -507,18 +349,21 @@ function zipToObject(keys2, values) {
507
349
  }
508
350
 
509
351
  // src/async/AggregateError.ts
510
- var AggregateError = class extends Error {
511
- errors;
512
- constructor(errors = []) {
513
- var _a, _b;
514
- super();
515
- const name = ((_a = errors.find((e) => e.name)) == null ? void 0 : _a.name) ?? "";
516
- this.name = `AggregateError(${name}...)`;
517
- this.message = `AggregateError with ${errors.length} errors`;
518
- this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
519
- this.errors = errors;
352
+ var AggregateErrorOrPolyfill = /* @__PURE__ */ (() => (
353
+ // eslint-disable-next-line compat/compat
354
+ globalThis.AggregateError ?? class AggregateError extends Error {
355
+ errors;
356
+ constructor(errors = []) {
357
+ var _a, _b;
358
+ super();
359
+ const name = ((_a = errors.find((e) => e.name)) == null ? void 0 : _a.name) ?? "";
360
+ this.name = `AggregateError(${name}...)`;
361
+ this.message = `AggregateError with ${errors.length} errors`;
362
+ this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
363
+ this.errors = errors;
364
+ }
520
365
  }
521
- };
366
+ ))();
522
367
 
523
368
  // src/async/all.ts
524
369
  async function all(promises) {
@@ -530,7 +375,7 @@ async function all(promises) {
530
375
  );
531
376
  const exceptions = results.filter((r) => r.exc);
532
377
  if (exceptions.length > 0) {
533
- throw new AggregateError(exceptions.map((e) => e.exc));
378
+ throw new AggregateErrorOrPolyfill(exceptions.map((e) => e.exc));
534
379
  }
535
380
  if (isArray(promises)) {
536
381
  return results.map((r) => r.result);
@@ -622,7 +467,7 @@ async function parallel(limit, array, func) {
622
467
  (x) => !!x.error
623
468
  );
624
469
  if (errors.length > 0) {
625
- throw new AggregateError(errors.map((error) => error.error));
470
+ throw new AggregateErrorOrPolyfill(errors.map((error) => error.error));
626
471
  }
627
472
  return results.map((r) => r.result);
628
473
  }
@@ -657,7 +502,7 @@ async function retry(options, func) {
657
502
  if (err._exited) {
658
503
  throw err._exited;
659
504
  }
660
- if (++i === times) {
505
+ if (++i >= times) {
661
506
  throw err;
662
507
  }
663
508
  if (delay) {
@@ -694,7 +539,6 @@ function callable(obj, fn) {
694
539
  return new Proxy(Object.assign(fn.bind(null), obj), {
695
540
  get: (target, key) => target[key],
696
541
  set: (target, key, value) => {
697
- ;
698
542
  target[key] = value;
699
543
  return true;
700
544
  },
@@ -739,6 +583,11 @@ function debounce({ delay }, func) {
739
583
  return debounced;
740
584
  }
741
585
 
586
+ // src/curry/flip.ts
587
+ function flip(fn) {
588
+ return (arg2, arg1, ...args) => fn(arg1, arg2, ...args);
589
+ }
590
+
742
591
  // src/curry/memo.ts
743
592
  function memoize(cache, func, keyFunc, ttl) {
744
593
  return function callWithMemo(...args) {
@@ -764,6 +613,25 @@ function memo(func, options = {}) {
764
613
  return memoize({}, func, options.key ?? null, options.ttl ?? null);
765
614
  }
766
615
 
616
+ // src/curry/once.ts
617
+ var onceSymbol = /* @__PURE__ */ Symbol();
618
+ var once = /* @__PURE__ */ (() => {
619
+ const once2 = (fn) => {
620
+ const onceFn = function(...args) {
621
+ if (onceFn[onceSymbol] === onceSymbol) {
622
+ onceFn[onceSymbol] = fn.apply(this, args);
623
+ }
624
+ return onceFn[onceSymbol];
625
+ };
626
+ onceFn[onceSymbol] = onceSymbol;
627
+ return onceFn;
628
+ };
629
+ once2.reset = (fn) => {
630
+ fn[onceSymbol] = onceSymbol;
631
+ };
632
+ return once2;
633
+ })();
634
+
767
635
  // src/curry/partial.ts
768
636
  function partial(fn, ...args) {
769
637
  return (...rest) => fn(...[...args, ...rest]);
@@ -785,26 +653,70 @@ function proxied(handler) {
785
653
  }
786
654
 
787
655
  // src/curry/throttle.ts
788
- function throttle({ interval }, func) {
789
- let ready = true;
790
- let timer = void 0;
656
+ function throttle({ interval, trailing }, func) {
657
+ let timer;
658
+ let lastCalled = 0;
659
+ let trailingArgs;
791
660
  const throttled = (...args) => {
792
- if (!ready) {
793
- return;
661
+ if (!isThrottled()) {
662
+ trigger(...args);
663
+ } else if (trailing) {
664
+ trailingArgs = args;
794
665
  }
795
- func(...args);
796
- ready = false;
797
- timer = setTimeout(() => {
798
- ready = true;
799
- timer = void 0;
800
- }, interval);
801
666
  };
802
- throttled.isThrottled = () => {
803
- return timer !== void 0;
667
+ const isThrottled = () => Date.now() - lastCalled < interval;
668
+ throttled.isThrottled = isThrottled;
669
+ const trigger = throttled.trigger = (...args) => {
670
+ func(...args);
671
+ lastCalled = Date.now();
672
+ if (trailing) {
673
+ trailingArgs = void 0;
674
+ clearTimeout(timer);
675
+ timer = setTimeout(
676
+ () => trailingArgs && trigger(...trailingArgs),
677
+ interval
678
+ );
679
+ }
804
680
  };
805
681
  return throttled;
806
682
  }
807
683
 
684
+ // src/function/always.ts
685
+ function always(value) {
686
+ return () => value;
687
+ }
688
+
689
+ // src/function/castComparator.ts
690
+ function castComparator(mapping, compare, reverse) {
691
+ const map2 = isFunction(mapping) ? mapping : (obj) => obj[mapping];
692
+ const comparator = (left, right) => {
693
+ const mappedLeft = map2(left);
694
+ const mappedRight = map2(right);
695
+ if (compare) {
696
+ return compare(mappedLeft, mappedRight);
697
+ }
698
+ return mappedLeft > mappedRight ? 1 : mappedLeft < mappedRight ? -1 : 0;
699
+ };
700
+ return reverse ? flip(comparator) : comparator;
701
+ }
702
+
703
+ // src/function/castMapping.ts
704
+ function castMapping(mapping) {
705
+ return isFunction(mapping) ? mapping : mapping != null ? (input) => input[mapping] : (input) => input;
706
+ }
707
+
708
+ // src/function/noop.ts
709
+ function noop() {
710
+ }
711
+
712
+ // src/number/clamp.ts
713
+ function clamp(n, min2, max2) {
714
+ if (max2 != null && min2 != null && min2 > max2) {
715
+ throw new Error("invalid clamp range");
716
+ }
717
+ return max2 != null && n > max2 ? max2 : min2 != null && n < min2 ? min2 : n;
718
+ }
719
+
808
720
  // src/number/inRange.ts
809
721
  function inRange(number, start, end) {
810
722
  const isTypeSafe = typeof number === "number" && typeof start === "number" && (typeof end === "undefined" || typeof end === "number");
@@ -818,6 +730,42 @@ function inRange(number, start, end) {
818
730
  return number >= Math.min(start, end) && number < Math.max(start, end);
819
731
  }
820
732
 
733
+ // src/number/lerp.ts
734
+ function lerp(from, to, amount) {
735
+ return from + (to - from) * amount;
736
+ }
737
+
738
+ // src/number/max.ts
739
+ function max(array, getter) {
740
+ if (!array || (array.length ?? 0) === 0) {
741
+ return null;
742
+ }
743
+ const get2 = getter ?? ((v) => v);
744
+ return array.reduce((a, b) => get2(a) > get2(b) ? a : b);
745
+ }
746
+
747
+ // src/number/min.ts
748
+ function min(array, getter) {
749
+ if (!array || (array.length ?? 0) === 0) {
750
+ return null;
751
+ }
752
+ const get2 = getter ?? ((v) => v);
753
+ return array.reduce((a, b) => get2(a) < get2(b) ? a : b);
754
+ }
755
+
756
+ // src/number/range.ts
757
+ function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
758
+ const mapper = isFunction(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
759
+ const start = end ? startOrLength : 0;
760
+ const final = end ?? startOrLength;
761
+ for (let i = start; i <= final; i += step) {
762
+ yield mapper(i);
763
+ if (i + step > final) {
764
+ break;
765
+ }
766
+ }
767
+ }
768
+
821
769
  // src/number/round.ts
822
770
  function round(value, precision, toInteger = Math.round) {
823
771
  if (precision) {
@@ -829,6 +777,11 @@ function round(value, precision, toInteger = Math.round) {
829
777
  return toInteger(value);
830
778
  }
831
779
 
780
+ // src/number/sum.ts
781
+ function sum(array, fn) {
782
+ return (array || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
783
+ }
784
+
832
785
  // src/number/toFloat.ts
833
786
  function toFloat(value, defaultValue) {
834
787
  const parsedValue = isSymbol(value) ? Number.NaN : Number.parseFloat(value);
@@ -848,10 +801,8 @@ function assign(initial, override) {
848
801
  }
849
802
  const proto = Object.getPrototypeOf(initial);
850
803
  const merged = proto ? { ...initial } : Object.assign(Object.create(proto), initial);
851
- for (const key in override) {
852
- if (Object.prototype.hasOwnProperty.call(override, key)) {
853
- merged[key] = isPlainObject(initial[key]) ? assign(initial[key], override[key]) : override[key];
854
- }
804
+ for (const key of Object.keys(override)) {
805
+ merged[key] = isPlainObject(initial[key]) && isPlainObject(override[key]) ? assign(initial[key], override[key]) : override[key];
855
806
  }
856
807
  return merged;
857
808
  }
@@ -872,6 +823,73 @@ function clone(obj) {
872
823
  return newObj;
873
824
  }
874
825
 
826
+ // src/object/cloneDeep.ts
827
+ var DefaultCloningStrategy = {
828
+ cloneMap(input, track, clone2) {
829
+ const output = track(/* @__PURE__ */ new Map());
830
+ for (const [key, value] of input) {
831
+ output.set(key, clone2(value));
832
+ }
833
+ return output;
834
+ },
835
+ cloneSet(input, track, clone2) {
836
+ const output = track(/* @__PURE__ */ new Set());
837
+ for (const value of input) {
838
+ output.add(clone2(value));
839
+ }
840
+ return output;
841
+ },
842
+ cloneArray(input, track, clone2) {
843
+ const output = track(new Array(input.length));
844
+ input.forEach((value, index) => {
845
+ output[index] = clone2(value);
846
+ });
847
+ return output;
848
+ },
849
+ cloneObject(input, track, clone2) {
850
+ const output = track(Object.create(Object.getPrototypeOf(input)));
851
+ for (const key of Reflect.ownKeys(input)) {
852
+ const descriptor = Object.getOwnPropertyDescriptor(input, key);
853
+ if ("value" in descriptor) {
854
+ descriptor.value = clone2(descriptor.value);
855
+ }
856
+ Object.defineProperty(output, key, descriptor);
857
+ }
858
+ return output;
859
+ },
860
+ cloneOther(input, track) {
861
+ return track(input);
862
+ }
863
+ };
864
+ var FastCloningStrategy = {
865
+ cloneObject: (input, track, clone2) => {
866
+ const output = track({ ...input });
867
+ for (const key of Object.keys(input)) {
868
+ output[key] = clone2(input[key]);
869
+ }
870
+ return output;
871
+ }
872
+ };
873
+ function cloneDeep(root, customStrategy) {
874
+ const strategy = { ...DefaultCloningStrategy, ...customStrategy };
875
+ const tracked = /* @__PURE__ */ new Map();
876
+ const track = (parent, newParent) => {
877
+ tracked.set(parent, newParent);
878
+ return newParent;
879
+ };
880
+ const clone2 = (value) => value && typeof value === "object" ? tracked.get(value) ?? cloneDeep2(value, strategy) : value;
881
+ const cloneDeep2 = (parent, strategy2) => {
882
+ const cloneParent = isObject(parent) ? strategy2.cloneObject : isArray(parent) ? strategy2.cloneArray : isMap(parent) ? strategy2.cloneMap : isSet(parent) ? strategy2.cloneSet : strategy2.cloneOther;
883
+ const newParent = cloneParent(parent, track.bind(null, parent), clone2);
884
+ if (!newParent) {
885
+ return cloneDeep2(parent, DefaultCloningStrategy);
886
+ }
887
+ tracked.set(parent, newParent);
888
+ return newParent;
889
+ };
890
+ return cloneDeep2(root, strategy);
891
+ }
892
+
875
893
  // src/object/construct.ts
876
894
  function construct(obj) {
877
895
  if (!obj) {
@@ -887,11 +905,16 @@ function crush(value) {
887
905
  if (!value) {
888
906
  return {};
889
907
  }
890
- return objectify(
891
- keys(value),
892
- (k) => k,
893
- (k) => get(value, k)
894
- );
908
+ return function crushReducer(crushed, value2, path) {
909
+ if (isObject(value2) || isArray(value2)) {
910
+ for (const [prop, propValue] of Object.entries(value2)) {
911
+ crushReducer(crushed, propValue, path ? `${path}.${prop}` : prop);
912
+ }
913
+ } else {
914
+ crushed[path] = value2;
915
+ }
916
+ return crushed;
917
+ }({}, value, "");
895
918
  }
896
919
 
897
920
  // src/object/filterKey.ts
@@ -1042,19 +1065,22 @@ function omit(obj, keys2) {
1042
1065
  }
1043
1066
 
1044
1067
  // src/object/pick.ts
1045
- function pick(obj, keys2) {
1068
+ function pick(obj, filter) {
1046
1069
  if (!obj) {
1047
1070
  return {};
1048
1071
  }
1049
- return keys2.reduce(
1050
- (acc, key) => {
1051
- if (Object.hasOwnProperty.call(obj, key)) {
1052
- acc[key] = obj[key];
1053
- }
1054
- return acc;
1055
- },
1056
- {}
1057
- );
1072
+ let keys2 = filter;
1073
+ if (isArray(filter)) {
1074
+ filter = null;
1075
+ } else {
1076
+ keys2 = Reflect.ownKeys(obj);
1077
+ }
1078
+ return keys2.reduce((acc, key) => {
1079
+ if (filterKey(obj, key, filter)) {
1080
+ acc[key] = obj[key];
1081
+ }
1082
+ return acc;
1083
+ }, {});
1058
1084
  }
1059
1085
 
1060
1086
  // src/object/set.ts
@@ -1090,6 +1116,103 @@ function shake(obj, filter = (value) => value === void 0) {
1090
1116
  }, {});
1091
1117
  }
1092
1118
 
1119
+ // src/object/traverse.ts
1120
+ function traverse(root, visitor, options, outerContext) {
1121
+ const context = outerContext ?? {
1122
+ value: null,
1123
+ key: null,
1124
+ parent: null,
1125
+ parents: [],
1126
+ path: [],
1127
+ skipped: /* @__PURE__ */ new Set(),
1128
+ skip(obj) {
1129
+ context.skipped.add(obj ?? context.value);
1130
+ }
1131
+ };
1132
+ const { rootNeedsVisit } = options ??= {};
1133
+ const ownKeys = options.ownKeys ?? Object.keys;
1134
+ const nestedOptions = {
1135
+ ...options,
1136
+ rootNeedsVisit: null
1137
+ };
1138
+ let ok = true;
1139
+ const visit = (value, key) => {
1140
+ if (context.parent.constructor === Map) {
1141
+ [key, value] = value;
1142
+ }
1143
+ context.path.push(key);
1144
+ const result = visitor(
1145
+ context.value = value,
1146
+ context.key = key,
1147
+ context.parent,
1148
+ context,
1149
+ nestedOptions
1150
+ );
1151
+ if (result === false) {
1152
+ return ok = false;
1153
+ }
1154
+ if (value !== null && typeof value === "object" && (isArray(value) || isPlainObject(value)) && !context.skipped.has(value) && !context.parents.includes(value)) {
1155
+ traverse2(value, result);
1156
+ }
1157
+ context.path.pop();
1158
+ return ok;
1159
+ };
1160
+ const traverse2 = (parent, parentResult) => {
1161
+ context.parents.push(parent);
1162
+ context.parent = parent;
1163
+ if (rootNeedsVisit && parent === root) {
1164
+ parentResult = visitor(
1165
+ context.value = parent,
1166
+ context.key = null,
1167
+ context.parent,
1168
+ context,
1169
+ nestedOptions
1170
+ );
1171
+ if (parentResult === false) {
1172
+ return ok;
1173
+ }
1174
+ }
1175
+ if (isArray(parent)) {
1176
+ parent.slice().forEach((value, index, values) => {
1177
+ if (visit(value, index) === false) {
1178
+ values.length = 0;
1179
+ }
1180
+ });
1181
+ } else if (parent === root && isIterable(parent)) {
1182
+ let index = 0;
1183
+ for (const value of parent) {
1184
+ if (visit(value, index) === false) {
1185
+ return ok;
1186
+ }
1187
+ index++;
1188
+ }
1189
+ } else {
1190
+ for (const key of ownKeys(parent)) {
1191
+ if (visit(parent[key], key) === false) {
1192
+ return ok;
1193
+ }
1194
+ }
1195
+ }
1196
+ context.parents.pop();
1197
+ context.parent = last(context.parents);
1198
+ if (ok && isFunction(parentResult)) {
1199
+ ok = parentResult() !== false;
1200
+ }
1201
+ return ok;
1202
+ };
1203
+ if (outerContext) {
1204
+ if (outerContext.skipped.has(root)) {
1205
+ return true;
1206
+ }
1207
+ const { value, key } = context;
1208
+ traverse2(root);
1209
+ context.value = value;
1210
+ context.key = key;
1211
+ return ok;
1212
+ }
1213
+ return traverse2(root);
1214
+ }
1215
+
1093
1216
  // src/object/upperize.ts
1094
1217
  function upperize(obj) {
1095
1218
  return mapKeys(obj, (k) => k.toUpperCase());
@@ -1111,8 +1234,15 @@ function random(min2, max2) {
1111
1234
  }
1112
1235
 
1113
1236
  // src/random/shuffle.ts
1114
- function shuffle(array) {
1115
- return array.map((a) => ({ rand: Math.random(), value: a })).sort((a, b) => a.rand - b.rand).map((a) => a.value);
1237
+ function shuffle(array, random2 = random) {
1238
+ const newArray = array.slice();
1239
+ for (let idx = 0, randomIdx, item; idx < array.length; idx++) {
1240
+ randomIdx = random2(0, array.length - 1);
1241
+ item = newArray[randomIdx];
1242
+ newArray[randomIdx] = newArray[idx];
1243
+ newArray[idx] = item;
1244
+ }
1245
+ return newArray;
1116
1246
  }
1117
1247
 
1118
1248
  // src/random/uid.ts
@@ -1230,6 +1360,54 @@ function pascal(str) {
1230
1360
  return parts.map((str2) => str2.charAt(0).toUpperCase() + str2.slice(1)).join("");
1231
1361
  }
1232
1362
 
1363
+ // src/string/similarity.ts
1364
+ function similarity(str1, str2) {
1365
+ if (str1 === str2) {
1366
+ return 0;
1367
+ }
1368
+ let start = 0;
1369
+ let end1 = str1.length - 1;
1370
+ let end2 = str2.length - 1;
1371
+ while (start <= end1 && start <= end2 && str1[start] === str2[start]) {
1372
+ start++;
1373
+ }
1374
+ while (end1 >= start && end2 >= start && str1[end1] === str2[end2]) {
1375
+ end1--;
1376
+ end2--;
1377
+ }
1378
+ const length1 = end1 - start + 1;
1379
+ const length2 = end2 - start + 1;
1380
+ if (length1 === 0) {
1381
+ return length2;
1382
+ }
1383
+ if (length2 === 0) {
1384
+ return length1;
1385
+ }
1386
+ const numRows = length1 + 1;
1387
+ const numColumns = length2 + 1;
1388
+ const distances = new Array(numRows * numColumns).fill(0);
1389
+ for (let x = 1; x < numColumns; x++) {
1390
+ distances[x] = x;
1391
+ }
1392
+ for (let y = 1; y < numRows; y++) {
1393
+ distances[y * numColumns] = y;
1394
+ }
1395
+ for (let x = 1; x < numColumns; x++) {
1396
+ for (let y = 1; y < numRows; y++) {
1397
+ const i = y * numColumns + x;
1398
+ distances[i] = Math.min(
1399
+ // Cost of a deletion.
1400
+ distances[i - numColumns] + 1,
1401
+ // Cost of an insertion.
1402
+ distances[i - 1] + 1,
1403
+ // Cost of a substitution.
1404
+ distances[i - numColumns - 1] + (str1[start + y - 1] === str2[start + x - 1] ? 0 : 1)
1405
+ );
1406
+ }
1407
+ }
1408
+ return distances[length1 * numColumns + length2];
1409
+ }
1410
+
1233
1411
  // src/string/snake.ts
1234
1412
  function snake(str, options) {
1235
1413
  const parts = (str == null ? void 0 : str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase())) ?? [];
@@ -1276,11 +1454,16 @@ function trim(str, charsToTrim = " ") {
1276
1454
  }
1277
1455
 
1278
1456
  // src/typed/isArray.ts
1279
- var isArray = Array.isArray;
1457
+ var isArray = /* @__PURE__ */ (() => Array.isArray)();
1458
+
1459
+ // src/typed/isBoolean.ts
1460
+ function isBoolean(value) {
1461
+ return typeof value === "boolean";
1462
+ }
1280
1463
 
1281
1464
  // src/typed/isDate.ts
1282
1465
  function isDate(value) {
1283
- return Object.prototype.toString.call(value) === "[object Date]";
1466
+ return isTagged(value, "[object Date]");
1284
1467
  }
1285
1468
 
1286
1469
  // src/typed/isEmpty.ts
@@ -1356,9 +1539,7 @@ function isFunction(value) {
1356
1539
  }
1357
1540
 
1358
1541
  // src/typed/isInt.ts
1359
- function isInt(value) {
1360
- return isNumber(value) && value % 1 === 0;
1361
- }
1542
+ var isInt = /* @__PURE__ */ (() => Number.isInteger)();
1362
1543
 
1363
1544
  // src/typed/isIntString.ts
1364
1545
  function isIntString(value) {
@@ -1369,18 +1550,24 @@ function isIntString(value) {
1369
1550
  return Number.isInteger(num) && `${num}` === value;
1370
1551
  }
1371
1552
 
1553
+ // src/typed/isIterable.ts
1554
+ function isIterable(value) {
1555
+ return typeof value === "object" && value !== null && Symbol.iterator in value;
1556
+ }
1557
+
1558
+ // src/typed/isMap.ts
1559
+ function isMap(value) {
1560
+ return isTagged(value, "[object Map]");
1561
+ }
1562
+
1372
1563
  // src/typed/isNumber.ts
1373
1564
  function isNumber(value) {
1374
- try {
1375
- return Number(value) === value;
1376
- } catch {
1377
- return false;
1378
- }
1565
+ return typeof value === "number" && !Number.isNaN(value);
1379
1566
  }
1380
1567
 
1381
1568
  // src/typed/isObject.ts
1382
1569
  function isObject(value) {
1383
- return !!value && value.constructor === Object;
1570
+ return isTagged(value, "[object Object]");
1384
1571
  }
1385
1572
 
1386
1573
  // src/typed/isPlainObject.ts
@@ -1389,7 +1576,12 @@ function isPlainObject(value) {
1389
1576
  return false;
1390
1577
  }
1391
1578
  const prototype = Object.getPrototypeOf(value);
1392
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
1579
+ return (
1580
+ // Fast path for most common objects.
1581
+ prototype === Object.prototype || // Support objects created without a prototype.
1582
+ prototype === null || // Support plain objects from other realms.
1583
+ Object.getPrototypeOf(prototype) === null
1584
+ );
1393
1585
  }
1394
1586
 
1395
1587
  // src/typed/isPrimitive.ts
@@ -1402,117 +1594,163 @@ function isPromise(value) {
1402
1594
  return !!value && isFunction(value.then);
1403
1595
  }
1404
1596
 
1597
+ // src/typed/isRegExp.ts
1598
+ function isRegExp(value) {
1599
+ return isTagged(value, "[object RegExp]");
1600
+ }
1601
+
1602
+ // src/typed/isSet.ts
1603
+ function isSet(value) {
1604
+ return isTagged(value, "[object Set]");
1605
+ }
1606
+
1405
1607
  // src/typed/isString.ts
1406
1608
  function isString(value) {
1407
- return typeof value === "string" || value instanceof String;
1609
+ return typeof value === "string";
1408
1610
  }
1409
1611
 
1410
1612
  // src/typed/isSymbol.ts
1411
1613
  function isSymbol(value) {
1412
1614
  return typeof value === "symbol";
1413
1615
  }
1414
- // Annotate the CommonJS export names for ESM import in node:
1415
- 0 && (module.exports = {
1416
- AggregateError,
1417
- all,
1418
- alphabetical,
1419
- assign,
1420
- boil,
1421
- callable,
1422
- camel,
1423
- capitalize,
1424
- chain,
1425
- clone,
1426
- cluster,
1427
- compose,
1428
- construct,
1429
- counting,
1430
- crush,
1431
- dash,
1432
- debounce,
1433
- defer,
1434
- diff,
1435
- draw,
1436
- filterKey,
1437
- first,
1438
- flat,
1439
- fork,
1440
- get,
1441
- group,
1442
- guard,
1443
- inRange,
1444
- intersects,
1445
- invert,
1446
- isArray,
1447
- isDate,
1448
- isEmpty,
1449
- isEqual,
1450
- isFloat,
1451
- isFunction,
1452
- isInt,
1453
- isIntString,
1454
- isNumber,
1455
- isObject,
1456
- isPlainObject,
1457
- isPrimitive,
1458
- isPromise,
1459
- isString,
1460
- isSymbol,
1461
- iterate,
1462
- keys,
1463
- last,
1464
- list,
1465
- listify,
1466
- lowerize,
1467
- map,
1468
- mapEntries,
1469
- mapKeys,
1470
- mapValues,
1471
- mapify,
1472
- max,
1473
- memo,
1474
- merge,
1475
- min,
1476
- objectify,
1477
- omit,
1478
- parallel,
1479
- partial,
1480
- partob,
1481
- pascal,
1482
- pick,
1483
- proxied,
1484
- random,
1485
- range,
1486
- reduce,
1487
- replace,
1488
- replaceOrAppend,
1489
- retry,
1490
- round,
1491
- select,
1492
- selectFirst,
1493
- series,
1494
- set,
1495
- shake,
1496
- shift,
1497
- shuffle,
1498
- sift,
1499
- sleep,
1500
- snake,
1501
- sort,
1502
- sum,
1503
- template,
1504
- throttle,
1505
- title,
1506
- toFloat,
1507
- toInt,
1508
- toggle,
1509
- trim,
1510
- try: null,
1511
- tryit,
1512
- uid,
1513
- unique,
1514
- unzip,
1515
- upperize,
1516
- zip,
1517
- zipToObject
1518
- });
1616
+
1617
+ // src/typed/isTagged.ts
1618
+ function isTagged(value, tag) {
1619
+ return Object.prototype.toString.call(value) === tag;
1620
+ }
1621
+
1622
+ // src/typed/isWeakMap.ts
1623
+ function isWeakMap(value) {
1624
+ return isTagged(value, "[object WeakMap]");
1625
+ }
1626
+
1627
+ // src/typed/isWeakSet.ts
1628
+ function isWeakSet(value) {
1629
+ return isTagged(value, "[object WeakSet]");
1630
+ }
1631
+
1632
+ exports.AggregateError = AggregateErrorOrPolyfill;
1633
+ exports.DefaultCloningStrategy = DefaultCloningStrategy;
1634
+ exports.FastCloningStrategy = FastCloningStrategy;
1635
+ exports.all = all;
1636
+ exports.alphabetical = alphabetical;
1637
+ exports.always = always;
1638
+ exports.assign = assign;
1639
+ exports.boil = boil;
1640
+ exports.callable = callable;
1641
+ exports.camel = camel;
1642
+ exports.capitalize = capitalize;
1643
+ exports.castArray = castArray;
1644
+ exports.castArrayIfExists = castArrayIfExists;
1645
+ exports.castComparator = castComparator;
1646
+ exports.castMapping = castMapping;
1647
+ exports.chain = chain;
1648
+ exports.clamp = clamp;
1649
+ exports.clone = clone;
1650
+ exports.cloneDeep = cloneDeep;
1651
+ exports.cluster = cluster;
1652
+ exports.compose = compose;
1653
+ exports.construct = construct;
1654
+ exports.counting = counting;
1655
+ exports.crush = crush;
1656
+ exports.dash = dash;
1657
+ exports.debounce = debounce;
1658
+ exports.defer = defer;
1659
+ exports.diff = diff;
1660
+ exports.draw = draw;
1661
+ exports.filterKey = filterKey;
1662
+ exports.first = first;
1663
+ exports.flat = flat;
1664
+ exports.flip = flip;
1665
+ exports.fork = fork;
1666
+ exports.get = get;
1667
+ exports.group = group;
1668
+ exports.guard = guard;
1669
+ exports.inRange = inRange;
1670
+ exports.intersects = intersects;
1671
+ exports.invert = invert;
1672
+ exports.isArray = isArray;
1673
+ exports.isBoolean = isBoolean;
1674
+ exports.isDate = isDate;
1675
+ exports.isEmpty = isEmpty;
1676
+ exports.isEqual = isEqual;
1677
+ exports.isFloat = isFloat;
1678
+ exports.isFunction = isFunction;
1679
+ exports.isInt = isInt;
1680
+ exports.isIntString = isIntString;
1681
+ exports.isIterable = isIterable;
1682
+ exports.isMap = isMap;
1683
+ exports.isNumber = isNumber;
1684
+ exports.isObject = isObject;
1685
+ exports.isPlainObject = isPlainObject;
1686
+ exports.isPrimitive = isPrimitive;
1687
+ exports.isPromise = isPromise;
1688
+ exports.isRegExp = isRegExp;
1689
+ exports.isSet = isSet;
1690
+ exports.isString = isString;
1691
+ exports.isSymbol = isSymbol;
1692
+ exports.isTagged = isTagged;
1693
+ exports.isWeakMap = isWeakMap;
1694
+ exports.isWeakSet = isWeakSet;
1695
+ exports.iterate = iterate;
1696
+ exports.keys = keys;
1697
+ exports.last = last;
1698
+ exports.lerp = lerp;
1699
+ exports.list = list;
1700
+ exports.listify = listify;
1701
+ exports.lowerize = lowerize;
1702
+ exports.map = map;
1703
+ exports.mapEntries = mapEntries;
1704
+ exports.mapKeys = mapKeys;
1705
+ exports.mapValues = mapValues;
1706
+ exports.mapify = mapify;
1707
+ exports.max = max;
1708
+ exports.memo = memo;
1709
+ exports.merge = merge;
1710
+ exports.min = min;
1711
+ exports.noop = noop;
1712
+ exports.objectify = objectify;
1713
+ exports.omit = omit;
1714
+ exports.once = once;
1715
+ exports.parallel = parallel;
1716
+ exports.partial = partial;
1717
+ exports.partob = partob;
1718
+ exports.pascal = pascal;
1719
+ exports.pick = pick;
1720
+ exports.proxied = proxied;
1721
+ exports.random = random;
1722
+ exports.range = range;
1723
+ exports.reduce = reduce;
1724
+ exports.replace = replace;
1725
+ exports.replaceOrAppend = replaceOrAppend;
1726
+ exports.retry = retry;
1727
+ exports.round = round;
1728
+ exports.select = select;
1729
+ exports.selectFirst = selectFirst;
1730
+ exports.series = series;
1731
+ exports.set = set;
1732
+ exports.shake = shake;
1733
+ exports.shift = shift;
1734
+ exports.shuffle = shuffle;
1735
+ exports.sift = sift;
1736
+ exports.similarity = similarity;
1737
+ exports.sleep = sleep;
1738
+ exports.snake = snake;
1739
+ exports.sort = sort;
1740
+ exports.sum = sum;
1741
+ exports.template = template;
1742
+ exports.throttle = throttle;
1743
+ exports.title = title;
1744
+ exports.toFloat = toFloat;
1745
+ exports.toInt = toInt;
1746
+ exports.toggle = toggle;
1747
+ exports.traverse = traverse;
1748
+ exports.trim = trim;
1749
+ exports.try = tryit;
1750
+ exports.tryit = tryit;
1751
+ exports.uid = uid;
1752
+ exports.unique = unique;
1753
+ exports.unzip = unzip;
1754
+ exports.upperize = upperize;
1755
+ exports.zip = zip;
1756
+ exports.zipToObject = zipToObject;