radashi 12.2.0-beta.0dc9c8a → 12.2.0-beta.1ee40e2

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,138 +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
- flip: () => flip,
47
- fork: () => fork,
48
- get: () => get,
49
- group: () => group,
50
- guard: () => guard,
51
- inRange: () => inRange,
52
- intersects: () => intersects,
53
- invert: () => invert,
54
- isArray: () => isArray,
55
- isDate: () => isDate,
56
- isEmpty: () => isEmpty,
57
- isEqual: () => isEqual,
58
- isFloat: () => isFloat,
59
- isFunction: () => isFunction,
60
- isInt: () => isInt,
61
- isIntString: () => isIntString,
62
- isMap: () => isMap,
63
- isNumber: () => isNumber,
64
- isObject: () => isObject,
65
- isPlainObject: () => isPlainObject,
66
- isPrimitive: () => isPrimitive,
67
- isPromise: () => isPromise,
68
- isRegExp: () => isRegExp,
69
- isSet: () => isSet,
70
- isString: () => isString,
71
- isSymbol: () => isSymbol,
72
- isTagged: () => isTagged,
73
- isWeakMap: () => isWeakMap,
74
- isWeakSet: () => isWeakSet,
75
- iterate: () => iterate,
76
- keys: () => keys,
77
- last: () => last,
78
- lerp: () => lerp,
79
- list: () => list,
80
- listify: () => listify,
81
- lowerize: () => lowerize,
82
- map: () => map,
83
- mapEntries: () => mapEntries,
84
- mapKeys: () => mapKeys,
85
- mapValues: () => mapValues,
86
- mapify: () => mapify,
87
- max: () => max,
88
- memo: () => memo,
89
- merge: () => merge,
90
- min: () => min,
91
- objectify: () => objectify,
92
- omit: () => omit,
93
- once: () => once,
94
- parallel: () => parallel,
95
- partial: () => partial,
96
- partob: () => partob,
97
- pascal: () => pascal,
98
- pick: () => pick,
99
- proxied: () => proxied,
100
- random: () => random,
101
- range: () => range,
102
- reduce: () => reduce,
103
- replace: () => replace,
104
- replaceOrAppend: () => replaceOrAppend,
105
- retry: () => retry,
106
- round: () => round,
107
- select: () => select,
108
- selectFirst: () => selectFirst,
109
- series: () => series,
110
- set: () => set,
111
- shake: () => shake,
112
- shift: () => shift,
113
- shuffle: () => shuffle,
114
- sift: () => sift,
115
- sleep: () => sleep,
116
- snake: () => snake,
117
- sort: () => sort,
118
- sum: () => sum,
119
- template: () => template,
120
- throttle: () => throttle,
121
- title: () => title,
122
- toFloat: () => toFloat,
123
- toInt: () => toInt,
124
- toggle: () => toggle,
125
- trim: () => trim,
126
- try: () => tryit,
127
- tryit: () => tryit,
128
- uid: () => uid,
129
- unique: () => unique,
130
- unzip: () => unzip,
131
- upperize: () => upperize,
132
- zip: () => zip,
133
- zipToObject: () => zipToObject
134
- });
135
- module.exports = __toCommonJS(mod_exports);
1
+ 'use strict';
136
2
 
137
3
  // src/array/alphabetical.ts
138
4
  function alphabetical(array, getter, direction = "asc") {
@@ -152,6 +18,16 @@ function boil(array, compareFunc) {
152
18
  return array.reduce(compareFunc);
153
19
  }
154
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
+
155
31
  // src/array/cluster.ts
156
32
  function cluster(array, size = 2) {
157
33
  const clusters = [];
@@ -271,20 +147,11 @@ function list(startOrLength, end, valueOrMapper, step) {
271
147
  function mapify(array, getKey, getValue = (item) => item) {
272
148
  const map2 = /* @__PURE__ */ new Map();
273
149
  for (const item of array) {
274
- map2.set(getKey(item), getValue(item));
150
+ map2.set(getKey(item, map2.size), getValue(item, map2.size));
275
151
  }
276
152
  return map2;
277
153
  }
278
154
 
279
- // src/array/max.ts
280
- function max(array, getter) {
281
- if (!array || (array.length ?? 0) === 0) {
282
- return null;
283
- }
284
- const get2 = getter ?? ((v) => v);
285
- return array.reduce((a, b) => get2(a) > get2(b) ? a : b);
286
- }
287
-
288
155
  // src/array/merge.ts
289
156
  function merge(prev, array, toKey) {
290
157
  if (!array && !prev) {
@@ -306,15 +173,6 @@ function merge(prev, array, toKey) {
306
173
  });
307
174
  }
308
175
 
309
- // src/array/min.ts
310
- function min(array, getter) {
311
- if (!array || (array.length ?? 0) === 0) {
312
- return null;
313
- }
314
- const get2 = getter ?? ((v) => v);
315
- return array.reduce((a, b) => get2(a) < get2(b) ? a : b);
316
- }
317
-
318
176
  // src/array/objectify.ts
319
177
  function objectify(array, getKey, getValue = (item) => item) {
320
178
  return array.reduce(
@@ -326,19 +184,6 @@ function objectify(array, getKey, getValue = (item) => item) {
326
184
  );
327
185
  }
328
186
 
329
- // src/array/range.ts
330
- function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
331
- const mapper = isFunction(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
332
- const start = end ? startOrLength : 0;
333
- const final = end ?? startOrLength;
334
- for (let i = start; i <= final; i += step) {
335
- yield mapper(i);
336
- if (i + step > final) {
337
- break;
338
- }
339
- }
340
- }
341
-
342
187
  // src/array/replace.ts
343
188
  function replace(array, newItem, match) {
344
189
  if (!array) {
@@ -411,11 +256,11 @@ function selectFirst(array, mapper, condition) {
411
256
  // src/array/shift.ts
412
257
  function shift(arr, n) {
413
258
  if (arr.length === 0) {
414
- return arr;
259
+ return [...arr];
415
260
  }
416
261
  const shiftNumber = n % arr.length;
417
262
  if (shiftNumber === 0) {
418
- return arr;
263
+ return [...arr];
419
264
  }
420
265
  return [...arr.slice(-shiftNumber, arr.length), ...arr.slice(0, -shiftNumber)];
421
266
  }
@@ -435,11 +280,6 @@ function sort(array, getter, desc = false) {
435
280
  return array.slice().sort(desc === true ? dsc : asc);
436
281
  }
437
282
 
438
- // src/array/sum.ts
439
- function sum(array, fn) {
440
- return (array || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
441
- }
442
-
443
283
  // src/array/toggle.ts
444
284
  function toggle(array, item, toKey, options) {
445
285
  if (!array) {
@@ -509,18 +349,21 @@ function zipToObject(keys2, values) {
509
349
  }
510
350
 
511
351
  // src/async/AggregateError.ts
512
- var AggregateError = class extends Error {
513
- errors;
514
- constructor(errors = []) {
515
- var _a, _b;
516
- super();
517
- const name = ((_a = errors.find((e) => e.name)) == null ? void 0 : _a.name) ?? "";
518
- this.name = `AggregateError(${name}...)`;
519
- this.message = `AggregateError with ${errors.length} errors`;
520
- this.stack = ((_b = errors.find((e) => e.stack)) == null ? void 0 : _b.stack) ?? this.stack;
521
- 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
+ }
522
365
  }
523
- };
366
+ ))();
524
367
 
525
368
  // src/async/all.ts
526
369
  async function all(promises) {
@@ -532,7 +375,7 @@ async function all(promises) {
532
375
  );
533
376
  const exceptions = results.filter((r) => r.exc);
534
377
  if (exceptions.length > 0) {
535
- throw new AggregateError(exceptions.map((e) => e.exc));
378
+ throw new AggregateErrorOrPolyfill(exceptions.map((e) => e.exc));
536
379
  }
537
380
  if (isArray(promises)) {
538
381
  return results.map((r) => r.result);
@@ -624,7 +467,7 @@ async function parallel(limit, array, func) {
624
467
  (x) => !!x.error
625
468
  );
626
469
  if (errors.length > 0) {
627
- throw new AggregateError(errors.map((error) => error.error));
470
+ throw new AggregateErrorOrPolyfill(errors.map((error) => error.error));
628
471
  }
629
472
  return results.map((r) => r.result);
630
473
  }
@@ -691,12 +534,22 @@ function tryit(func) {
691
534
  };
692
535
  }
693
536
 
537
+ // src/async/withResolvers.ts
538
+ function withResolvers() {
539
+ let resolve;
540
+ let reject;
541
+ const promise = new Promise((res, rej) => {
542
+ resolve = res;
543
+ reject = rej;
544
+ });
545
+ return { resolve, reject, promise };
546
+ }
547
+
694
548
  // src/curry/callable.ts
695
549
  function callable(obj, fn) {
696
550
  return new Proxy(Object.assign(fn.bind(null), obj), {
697
551
  get: (target, key) => target[key],
698
552
  set: (target, key, value) => {
699
- ;
700
553
  target[key] = value;
701
554
  return true;
702
555
  },
@@ -772,20 +625,23 @@ function memo(func, options = {}) {
772
625
  }
773
626
 
774
627
  // src/curry/once.ts
775
- var onceSymbol = Symbol();
776
- var once = (fn) => {
777
- const onceFn = function(...args) {
778
- if (onceFn[onceSymbol] === onceSymbol) {
779
- onceFn[onceSymbol] = fn.apply(this, args);
780
- }
781
- return onceFn[onceSymbol];
628
+ var onceSymbol = /* @__PURE__ */ Symbol();
629
+ var once = /* @__PURE__ */ (() => {
630
+ const once2 = (fn) => {
631
+ const onceFn = function(...args) {
632
+ if (onceFn[onceSymbol] === onceSymbol) {
633
+ onceFn[onceSymbol] = fn.apply(this, args);
634
+ }
635
+ return onceFn[onceSymbol];
636
+ };
637
+ onceFn[onceSymbol] = onceSymbol;
638
+ return onceFn;
782
639
  };
783
- onceFn[onceSymbol] = onceSymbol;
784
- return onceFn;
785
- };
786
- once.reset = (fn) => {
787
- fn[onceSymbol] = onceSymbol;
788
- };
640
+ once2.reset = (fn) => {
641
+ fn[onceSymbol] = onceSymbol;
642
+ };
643
+ return once2;
644
+ })();
789
645
 
790
646
  // src/curry/partial.ts
791
647
  function partial(fn, ...args) {
@@ -808,26 +664,70 @@ function proxied(handler) {
808
664
  }
809
665
 
810
666
  // src/curry/throttle.ts
811
- function throttle({ interval }, func) {
812
- let ready = true;
813
- let timer = void 0;
667
+ function throttle({ interval, trailing }, func) {
668
+ let timer;
669
+ let lastCalled = 0;
670
+ let trailingArgs;
814
671
  const throttled = (...args) => {
815
- if (!ready) {
816
- return;
672
+ if (!isThrottled()) {
673
+ trigger(...args);
674
+ } else if (trailing) {
675
+ trailingArgs = args;
817
676
  }
818
- func(...args);
819
- ready = false;
820
- timer = setTimeout(() => {
821
- ready = true;
822
- timer = void 0;
823
- }, interval);
824
677
  };
825
- throttled.isThrottled = () => {
826
- return timer !== void 0;
678
+ const isThrottled = () => Date.now() - lastCalled < interval;
679
+ throttled.isThrottled = isThrottled;
680
+ const trigger = throttled.trigger = (...args) => {
681
+ func(...args);
682
+ lastCalled = Date.now();
683
+ if (trailing) {
684
+ trailingArgs = void 0;
685
+ clearTimeout(timer);
686
+ timer = setTimeout(
687
+ () => trailingArgs && trigger(...trailingArgs),
688
+ interval
689
+ );
690
+ }
827
691
  };
828
692
  return throttled;
829
693
  }
830
694
 
695
+ // src/function/always.ts
696
+ function always(value) {
697
+ return () => value;
698
+ }
699
+
700
+ // src/function/castComparator.ts
701
+ function castComparator(mapping, compare, reverse) {
702
+ const map2 = isFunction(mapping) ? mapping : (obj) => obj[mapping];
703
+ const comparator = (left, right) => {
704
+ const mappedLeft = map2(left);
705
+ const mappedRight = map2(right);
706
+ if (compare) {
707
+ return compare(mappedLeft, mappedRight);
708
+ }
709
+ return mappedLeft > mappedRight ? 1 : mappedLeft < mappedRight ? -1 : 0;
710
+ };
711
+ return reverse ? flip(comparator) : comparator;
712
+ }
713
+
714
+ // src/function/castMapping.ts
715
+ function castMapping(mapping) {
716
+ return isFunction(mapping) ? mapping : mapping != null ? (input) => input[mapping] : (input) => input;
717
+ }
718
+
719
+ // src/function/noop.ts
720
+ function noop() {
721
+ }
722
+
723
+ // src/number/clamp.ts
724
+ function clamp(n, min2, max2) {
725
+ if (max2 != null && min2 != null && min2 > max2) {
726
+ throw new Error("invalid clamp range");
727
+ }
728
+ return max2 != null && n > max2 ? max2 : min2 != null && n < min2 ? min2 : n;
729
+ }
730
+
831
731
  // src/number/inRange.ts
832
732
  function inRange(number, start, end) {
833
733
  const isTypeSafe = typeof number === "number" && typeof start === "number" && (typeof end === "undefined" || typeof end === "number");
@@ -846,6 +746,37 @@ function lerp(from, to, amount) {
846
746
  return from + (to - from) * amount;
847
747
  }
848
748
 
749
+ // src/number/max.ts
750
+ function max(array, getter) {
751
+ if (!array || (array.length ?? 0) === 0) {
752
+ return null;
753
+ }
754
+ const get2 = getter ?? ((v) => v);
755
+ return array.reduce((a, b) => get2(a) > get2(b) ? a : b);
756
+ }
757
+
758
+ // src/number/min.ts
759
+ function min(array, getter) {
760
+ if (!array || (array.length ?? 0) === 0) {
761
+ return null;
762
+ }
763
+ const get2 = getter ?? ((v) => v);
764
+ return array.reduce((a, b) => get2(a) < get2(b) ? a : b);
765
+ }
766
+
767
+ // src/number/range.ts
768
+ function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
769
+ const mapper = isFunction(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
770
+ const start = end ? startOrLength : 0;
771
+ const final = end ?? startOrLength;
772
+ for (let i = start; i <= final; i += step) {
773
+ yield mapper(i);
774
+ if (i + step > final) {
775
+ break;
776
+ }
777
+ }
778
+ }
779
+
849
780
  // src/number/round.ts
850
781
  function round(value, precision, toInteger = Math.round) {
851
782
  if (precision) {
@@ -857,6 +788,11 @@ function round(value, precision, toInteger = Math.round) {
857
788
  return toInteger(value);
858
789
  }
859
790
 
791
+ // src/number/sum.ts
792
+ function sum(array, fn) {
793
+ return (array || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
794
+ }
795
+
860
796
  // src/number/toFloat.ts
861
797
  function toFloat(value, defaultValue) {
862
798
  const parsedValue = isSymbol(value) ? Number.NaN : Number.parseFloat(value);
@@ -876,10 +812,8 @@ function assign(initial, override) {
876
812
  }
877
813
  const proto = Object.getPrototypeOf(initial);
878
814
  const merged = proto ? { ...initial } : Object.assign(Object.create(proto), initial);
879
- for (const key in override) {
880
- if (Object.prototype.hasOwnProperty.call(override, key)) {
881
- merged[key] = isPlainObject(initial[key]) ? assign(initial[key], override[key]) : override[key];
882
- }
815
+ for (const key of Object.keys(override)) {
816
+ merged[key] = isPlainObject(initial[key]) && isPlainObject(override[key]) ? assign(initial[key], override[key]) : override[key];
883
817
  }
884
818
  return merged;
885
819
  }
@@ -900,6 +834,73 @@ function clone(obj) {
900
834
  return newObj;
901
835
  }
902
836
 
837
+ // src/object/cloneDeep.ts
838
+ var DefaultCloningStrategy = {
839
+ cloneMap(input, track, clone2) {
840
+ const output = track(/* @__PURE__ */ new Map());
841
+ for (const [key, value] of input) {
842
+ output.set(key, clone2(value));
843
+ }
844
+ return output;
845
+ },
846
+ cloneSet(input, track, clone2) {
847
+ const output = track(/* @__PURE__ */ new Set());
848
+ for (const value of input) {
849
+ output.add(clone2(value));
850
+ }
851
+ return output;
852
+ },
853
+ cloneArray(input, track, clone2) {
854
+ const output = track(new Array(input.length));
855
+ input.forEach((value, index) => {
856
+ output[index] = clone2(value);
857
+ });
858
+ return output;
859
+ },
860
+ cloneObject(input, track, clone2) {
861
+ const output = track(Object.create(Object.getPrototypeOf(input)));
862
+ for (const key of Reflect.ownKeys(input)) {
863
+ const descriptor = Object.getOwnPropertyDescriptor(input, key);
864
+ if ("value" in descriptor) {
865
+ descriptor.value = clone2(descriptor.value);
866
+ }
867
+ Object.defineProperty(output, key, descriptor);
868
+ }
869
+ return output;
870
+ },
871
+ cloneOther(input, track) {
872
+ return track(input);
873
+ }
874
+ };
875
+ var FastCloningStrategy = {
876
+ cloneObject: (input, track, clone2) => {
877
+ const output = track({ ...input });
878
+ for (const key of Object.keys(input)) {
879
+ output[key] = clone2(input[key]);
880
+ }
881
+ return output;
882
+ }
883
+ };
884
+ function cloneDeep(root, customStrategy) {
885
+ const strategy = { ...DefaultCloningStrategy, ...customStrategy };
886
+ const tracked = /* @__PURE__ */ new Map();
887
+ const track = (parent, newParent) => {
888
+ tracked.set(parent, newParent);
889
+ return newParent;
890
+ };
891
+ const clone2 = (value) => value && typeof value === "object" ? tracked.get(value) ?? cloneDeep2(value, strategy) : value;
892
+ const cloneDeep2 = (parent, strategy2) => {
893
+ const cloneParent = isObject(parent) ? strategy2.cloneObject : isArray(parent) ? strategy2.cloneArray : isMap(parent) ? strategy2.cloneMap : isSet(parent) ? strategy2.cloneSet : strategy2.cloneOther;
894
+ const newParent = cloneParent(parent, track.bind(null, parent), clone2);
895
+ if (!newParent) {
896
+ return cloneDeep2(parent, DefaultCloningStrategy);
897
+ }
898
+ tracked.set(parent, newParent);
899
+ return newParent;
900
+ };
901
+ return cloneDeep2(root, strategy);
902
+ }
903
+
903
904
  // src/object/construct.ts
904
905
  function construct(obj) {
905
906
  if (!obj) {
@@ -915,11 +916,16 @@ function crush(value) {
915
916
  if (!value) {
916
917
  return {};
917
918
  }
918
- return objectify(
919
- keys(value),
920
- (k) => k,
921
- (k) => get(value, k)
922
- );
919
+ return function crushReducer(crushed, value2, path) {
920
+ if (isObject(value2) || isArray(value2)) {
921
+ for (const [prop, propValue] of Object.entries(value2)) {
922
+ crushReducer(crushed, propValue, path ? `${path}.${prop}` : prop);
923
+ }
924
+ } else {
925
+ crushed[path] = value2;
926
+ }
927
+ return crushed;
928
+ }({}, value, "");
923
929
  }
924
930
 
925
931
  // src/object/filterKey.ts
@@ -1121,6 +1127,103 @@ function shake(obj, filter = (value) => value === void 0) {
1121
1127
  }, {});
1122
1128
  }
1123
1129
 
1130
+ // src/object/traverse.ts
1131
+ function traverse(root, visitor, options, outerContext) {
1132
+ const context = outerContext ?? {
1133
+ value: null,
1134
+ key: null,
1135
+ parent: null,
1136
+ parents: [],
1137
+ path: [],
1138
+ skipped: /* @__PURE__ */ new Set(),
1139
+ skip(obj) {
1140
+ context.skipped.add(obj ?? context.value);
1141
+ }
1142
+ };
1143
+ const { rootNeedsVisit } = options ??= {};
1144
+ const ownKeys = options.ownKeys ?? Object.keys;
1145
+ const nestedOptions = {
1146
+ ...options,
1147
+ rootNeedsVisit: null
1148
+ };
1149
+ let ok = true;
1150
+ const visit = (value, key) => {
1151
+ if (context.parent.constructor === Map) {
1152
+ [key, value] = value;
1153
+ }
1154
+ context.path.push(key);
1155
+ const result = visitor(
1156
+ context.value = value,
1157
+ context.key = key,
1158
+ context.parent,
1159
+ context,
1160
+ nestedOptions
1161
+ );
1162
+ if (result === false) {
1163
+ return ok = false;
1164
+ }
1165
+ if (value !== null && typeof value === "object" && (isArray(value) || isPlainObject(value)) && !context.skipped.has(value) && !context.parents.includes(value)) {
1166
+ traverse2(value, result);
1167
+ }
1168
+ context.path.pop();
1169
+ return ok;
1170
+ };
1171
+ const traverse2 = (parent, parentResult) => {
1172
+ context.parents.push(parent);
1173
+ context.parent = parent;
1174
+ if (rootNeedsVisit && parent === root) {
1175
+ parentResult = visitor(
1176
+ context.value = parent,
1177
+ context.key = null,
1178
+ context.parent,
1179
+ context,
1180
+ nestedOptions
1181
+ );
1182
+ if (parentResult === false) {
1183
+ return ok;
1184
+ }
1185
+ }
1186
+ if (isArray(parent)) {
1187
+ parent.slice().forEach((value, index, values) => {
1188
+ if (visit(value, index) === false) {
1189
+ values.length = 0;
1190
+ }
1191
+ });
1192
+ } else if (parent === root && isIterable(parent)) {
1193
+ let index = 0;
1194
+ for (const value of parent) {
1195
+ if (visit(value, index) === false) {
1196
+ return ok;
1197
+ }
1198
+ index++;
1199
+ }
1200
+ } else {
1201
+ for (const key of ownKeys(parent)) {
1202
+ if (visit(parent[key], key) === false) {
1203
+ return ok;
1204
+ }
1205
+ }
1206
+ }
1207
+ context.parents.pop();
1208
+ context.parent = last(context.parents);
1209
+ if (ok && isFunction(parentResult)) {
1210
+ ok = parentResult() !== false;
1211
+ }
1212
+ return ok;
1213
+ };
1214
+ if (outerContext) {
1215
+ if (outerContext.skipped.has(root)) {
1216
+ return true;
1217
+ }
1218
+ const { value, key } = context;
1219
+ traverse2(root);
1220
+ context.value = value;
1221
+ context.key = key;
1222
+ return ok;
1223
+ }
1224
+ return traverse2(root);
1225
+ }
1226
+
1124
1227
  // src/object/upperize.ts
1125
1228
  function upperize(obj) {
1126
1229
  return mapKeys(obj, (k) => k.toUpperCase());
@@ -1268,6 +1371,54 @@ function pascal(str) {
1268
1371
  return parts.map((str2) => str2.charAt(0).toUpperCase() + str2.slice(1)).join("");
1269
1372
  }
1270
1373
 
1374
+ // src/string/similarity.ts
1375
+ function similarity(str1, str2) {
1376
+ if (str1 === str2) {
1377
+ return 0;
1378
+ }
1379
+ let start = 0;
1380
+ let end1 = str1.length - 1;
1381
+ let end2 = str2.length - 1;
1382
+ while (start <= end1 && start <= end2 && str1[start] === str2[start]) {
1383
+ start++;
1384
+ }
1385
+ while (end1 >= start && end2 >= start && str1[end1] === str2[end2]) {
1386
+ end1--;
1387
+ end2--;
1388
+ }
1389
+ const length1 = end1 - start + 1;
1390
+ const length2 = end2 - start + 1;
1391
+ if (length1 === 0) {
1392
+ return length2;
1393
+ }
1394
+ if (length2 === 0) {
1395
+ return length1;
1396
+ }
1397
+ const numRows = length1 + 1;
1398
+ const numColumns = length2 + 1;
1399
+ const distances = new Array(numRows * numColumns).fill(0);
1400
+ for (let x = 1; x < numColumns; x++) {
1401
+ distances[x] = x;
1402
+ }
1403
+ for (let y = 1; y < numRows; y++) {
1404
+ distances[y * numColumns] = y;
1405
+ }
1406
+ for (let x = 1; x < numColumns; x++) {
1407
+ for (let y = 1; y < numRows; y++) {
1408
+ const i = y * numColumns + x;
1409
+ distances[i] = Math.min(
1410
+ // Cost of a deletion.
1411
+ distances[i - numColumns] + 1,
1412
+ // Cost of an insertion.
1413
+ distances[i - 1] + 1,
1414
+ // Cost of a substitution.
1415
+ distances[i - numColumns - 1] + (str1[start + y - 1] === str2[start + x - 1] ? 0 : 1)
1416
+ );
1417
+ }
1418
+ }
1419
+ return distances[length1 * numColumns + length2];
1420
+ }
1421
+
1271
1422
  // src/string/snake.ts
1272
1423
  function snake(str, options) {
1273
1424
  const parts = (str == null ? void 0 : str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase())) ?? [];
@@ -1314,7 +1465,12 @@ function trim(str, charsToTrim = " ") {
1314
1465
  }
1315
1466
 
1316
1467
  // src/typed/isArray.ts
1317
- var isArray = Array.isArray;
1468
+ var isArray = /* @__PURE__ */ (() => Array.isArray)();
1469
+
1470
+ // src/typed/isBoolean.ts
1471
+ function isBoolean(value) {
1472
+ return typeof value === "boolean";
1473
+ }
1318
1474
 
1319
1475
  // src/typed/isDate.ts
1320
1476
  function isDate(value) {
@@ -1394,7 +1550,7 @@ function isFunction(value) {
1394
1550
  }
1395
1551
 
1396
1552
  // src/typed/isInt.ts
1397
- var isInt = Number.isInteger;
1553
+ var isInt = /* @__PURE__ */ (() => Number.isInteger)();
1398
1554
 
1399
1555
  // src/typed/isIntString.ts
1400
1556
  function isIntString(value) {
@@ -1405,6 +1561,11 @@ function isIntString(value) {
1405
1561
  return Number.isInteger(num) && `${num}` === value;
1406
1562
  }
1407
1563
 
1564
+ // src/typed/isIterable.ts
1565
+ function isIterable(value) {
1566
+ return typeof value === "object" && value !== null && Symbol.iterator in value;
1567
+ }
1568
+
1408
1569
  // src/typed/isMap.ts
1409
1570
  function isMap(value) {
1410
1571
  return isTagged(value, "[object Map]");
@@ -1426,7 +1587,12 @@ function isPlainObject(value) {
1426
1587
  return false;
1427
1588
  }
1428
1589
  const prototype = Object.getPrototypeOf(value);
1429
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
1590
+ return (
1591
+ // Fast path for most common objects.
1592
+ prototype === Object.prototype || // Support objects created without a prototype.
1593
+ prototype === null || // Support plain objects from other realms.
1594
+ Object.getPrototypeOf(prototype) === null
1595
+ );
1430
1596
  }
1431
1597
 
1432
1598
  // src/typed/isPrimitive.ts
@@ -1473,117 +1639,130 @@ function isWeakMap(value) {
1473
1639
  function isWeakSet(value) {
1474
1640
  return isTagged(value, "[object WeakSet]");
1475
1641
  }
1476
- // Annotate the CommonJS export names for ESM import in node:
1477
- 0 && (module.exports = {
1478
- AggregateError,
1479
- all,
1480
- alphabetical,
1481
- assign,
1482
- boil,
1483
- callable,
1484
- camel,
1485
- capitalize,
1486
- chain,
1487
- clone,
1488
- cluster,
1489
- compose,
1490
- construct,
1491
- counting,
1492
- crush,
1493
- dash,
1494
- debounce,
1495
- defer,
1496
- diff,
1497
- draw,
1498
- filterKey,
1499
- first,
1500
- flat,
1501
- flip,
1502
- fork,
1503
- get,
1504
- group,
1505
- guard,
1506
- inRange,
1507
- intersects,
1508
- invert,
1509
- isArray,
1510
- isDate,
1511
- isEmpty,
1512
- isEqual,
1513
- isFloat,
1514
- isFunction,
1515
- isInt,
1516
- isIntString,
1517
- isMap,
1518
- isNumber,
1519
- isObject,
1520
- isPlainObject,
1521
- isPrimitive,
1522
- isPromise,
1523
- isRegExp,
1524
- isSet,
1525
- isString,
1526
- isSymbol,
1527
- isTagged,
1528
- isWeakMap,
1529
- isWeakSet,
1530
- iterate,
1531
- keys,
1532
- last,
1533
- lerp,
1534
- list,
1535
- listify,
1536
- lowerize,
1537
- map,
1538
- mapEntries,
1539
- mapKeys,
1540
- mapValues,
1541
- mapify,
1542
- max,
1543
- memo,
1544
- merge,
1545
- min,
1546
- objectify,
1547
- omit,
1548
- once,
1549
- parallel,
1550
- partial,
1551
- partob,
1552
- pascal,
1553
- pick,
1554
- proxied,
1555
- random,
1556
- range,
1557
- reduce,
1558
- replace,
1559
- replaceOrAppend,
1560
- retry,
1561
- round,
1562
- select,
1563
- selectFirst,
1564
- series,
1565
- set,
1566
- shake,
1567
- shift,
1568
- shuffle,
1569
- sift,
1570
- sleep,
1571
- snake,
1572
- sort,
1573
- sum,
1574
- template,
1575
- throttle,
1576
- title,
1577
- toFloat,
1578
- toInt,
1579
- toggle,
1580
- trim,
1581
- try: null,
1582
- tryit,
1583
- uid,
1584
- unique,
1585
- unzip,
1586
- upperize,
1587
- zip,
1588
- zipToObject
1589
- });
1642
+
1643
+ exports.AggregateError = AggregateErrorOrPolyfill;
1644
+ exports.DefaultCloningStrategy = DefaultCloningStrategy;
1645
+ exports.FastCloningStrategy = FastCloningStrategy;
1646
+ exports.all = all;
1647
+ exports.alphabetical = alphabetical;
1648
+ exports.always = always;
1649
+ exports.assign = assign;
1650
+ exports.boil = boil;
1651
+ exports.callable = callable;
1652
+ exports.camel = camel;
1653
+ exports.capitalize = capitalize;
1654
+ exports.castArray = castArray;
1655
+ exports.castArrayIfExists = castArrayIfExists;
1656
+ exports.castComparator = castComparator;
1657
+ exports.castMapping = castMapping;
1658
+ exports.chain = chain;
1659
+ exports.clamp = clamp;
1660
+ exports.clone = clone;
1661
+ exports.cloneDeep = cloneDeep;
1662
+ exports.cluster = cluster;
1663
+ exports.compose = compose;
1664
+ exports.construct = construct;
1665
+ exports.counting = counting;
1666
+ exports.crush = crush;
1667
+ exports.dash = dash;
1668
+ exports.debounce = debounce;
1669
+ exports.defer = defer;
1670
+ exports.diff = diff;
1671
+ exports.draw = draw;
1672
+ exports.filterKey = filterKey;
1673
+ exports.first = first;
1674
+ exports.flat = flat;
1675
+ exports.flip = flip;
1676
+ exports.fork = fork;
1677
+ exports.get = get;
1678
+ exports.group = group;
1679
+ exports.guard = guard;
1680
+ exports.inRange = inRange;
1681
+ exports.intersects = intersects;
1682
+ exports.invert = invert;
1683
+ exports.isArray = isArray;
1684
+ exports.isBoolean = isBoolean;
1685
+ exports.isDate = isDate;
1686
+ exports.isEmpty = isEmpty;
1687
+ exports.isEqual = isEqual;
1688
+ exports.isFloat = isFloat;
1689
+ exports.isFunction = isFunction;
1690
+ exports.isInt = isInt;
1691
+ exports.isIntString = isIntString;
1692
+ exports.isIterable = isIterable;
1693
+ exports.isMap = isMap;
1694
+ exports.isNumber = isNumber;
1695
+ exports.isObject = isObject;
1696
+ exports.isPlainObject = isPlainObject;
1697
+ exports.isPrimitive = isPrimitive;
1698
+ exports.isPromise = isPromise;
1699
+ exports.isRegExp = isRegExp;
1700
+ exports.isSet = isSet;
1701
+ exports.isString = isString;
1702
+ exports.isSymbol = isSymbol;
1703
+ exports.isTagged = isTagged;
1704
+ exports.isWeakMap = isWeakMap;
1705
+ exports.isWeakSet = isWeakSet;
1706
+ exports.iterate = iterate;
1707
+ exports.keys = keys;
1708
+ exports.last = last;
1709
+ exports.lerp = lerp;
1710
+ exports.list = list;
1711
+ exports.listify = listify;
1712
+ exports.lowerize = lowerize;
1713
+ exports.map = map;
1714
+ exports.mapEntries = mapEntries;
1715
+ exports.mapKeys = mapKeys;
1716
+ exports.mapValues = mapValues;
1717
+ exports.mapify = mapify;
1718
+ exports.max = max;
1719
+ exports.memo = memo;
1720
+ exports.merge = merge;
1721
+ exports.min = min;
1722
+ exports.noop = noop;
1723
+ exports.objectify = objectify;
1724
+ exports.omit = omit;
1725
+ exports.once = once;
1726
+ exports.parallel = parallel;
1727
+ exports.partial = partial;
1728
+ exports.partob = partob;
1729
+ exports.pascal = pascal;
1730
+ exports.pick = pick;
1731
+ exports.proxied = proxied;
1732
+ exports.random = random;
1733
+ exports.range = range;
1734
+ exports.reduce = reduce;
1735
+ exports.replace = replace;
1736
+ exports.replaceOrAppend = replaceOrAppend;
1737
+ exports.retry = retry;
1738
+ exports.round = round;
1739
+ exports.select = select;
1740
+ exports.selectFirst = selectFirst;
1741
+ exports.series = series;
1742
+ exports.set = set;
1743
+ exports.shake = shake;
1744
+ exports.shift = shift;
1745
+ exports.shuffle = shuffle;
1746
+ exports.sift = sift;
1747
+ exports.similarity = similarity;
1748
+ exports.sleep = sleep;
1749
+ exports.snake = snake;
1750
+ exports.sort = sort;
1751
+ exports.sum = sum;
1752
+ exports.template = template;
1753
+ exports.throttle = throttle;
1754
+ exports.title = title;
1755
+ exports.toFloat = toFloat;
1756
+ exports.toInt = toInt;
1757
+ exports.toggle = toggle;
1758
+ exports.traverse = traverse;
1759
+ exports.trim = trim;
1760
+ exports.try = tryit;
1761
+ exports.tryit = tryit;
1762
+ exports.uid = uid;
1763
+ exports.unique = unique;
1764
+ exports.unzip = unzip;
1765
+ exports.upperize = upperize;
1766
+ exports.withResolvers = withResolvers;
1767
+ exports.zip = zip;
1768
+ exports.zipToObject = zipToObject;