radashi 12.2.0-beta.c59abfd → 12.2.0-beta.cf2d48e
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 +382 -75
- package/dist/radashi.d.cts +1521 -229
- package/dist/radashi.d.ts +1521 -229
- package/dist/radashi.js +361 -75
- package/package.json +42 -29
package/dist/radashi.cjs
CHANGED
|
@@ -21,15 +21,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var mod_exports = {};
|
|
22
22
|
__export(mod_exports, {
|
|
23
23
|
AggregateError: () => AggregateError,
|
|
24
|
+
DefaultCloningStrategy: () => DefaultCloningStrategy,
|
|
25
|
+
FastCloningStrategy: () => FastCloningStrategy,
|
|
24
26
|
all: () => all,
|
|
25
27
|
alphabetical: () => alphabetical,
|
|
28
|
+
always: () => always,
|
|
26
29
|
assign: () => assign,
|
|
27
30
|
boil: () => boil,
|
|
28
31
|
callable: () => callable,
|
|
29
32
|
camel: () => camel,
|
|
30
33
|
capitalize: () => capitalize,
|
|
34
|
+
castArray: () => castArray,
|
|
35
|
+
castArrayIfExists: () => castArrayIfExists,
|
|
36
|
+
castComparator: () => castComparator,
|
|
37
|
+
castMapping: () => castMapping,
|
|
31
38
|
chain: () => chain,
|
|
39
|
+
clamp: () => clamp,
|
|
32
40
|
clone: () => clone,
|
|
41
|
+
cloneDeep: () => cloneDeep,
|
|
33
42
|
cluster: () => cluster,
|
|
34
43
|
compose: () => compose,
|
|
35
44
|
construct: () => construct,
|
|
@@ -52,6 +61,7 @@ __export(mod_exports, {
|
|
|
52
61
|
intersects: () => intersects,
|
|
53
62
|
invert: () => invert,
|
|
54
63
|
isArray: () => isArray,
|
|
64
|
+
isBoolean: () => isBoolean,
|
|
55
65
|
isDate: () => isDate,
|
|
56
66
|
isEmpty: () => isEmpty,
|
|
57
67
|
isEqual: () => isEqual,
|
|
@@ -59,16 +69,24 @@ __export(mod_exports, {
|
|
|
59
69
|
isFunction: () => isFunction,
|
|
60
70
|
isInt: () => isInt,
|
|
61
71
|
isIntString: () => isIntString,
|
|
72
|
+
isIterable: () => isIterable,
|
|
73
|
+
isMap: () => isMap,
|
|
62
74
|
isNumber: () => isNumber,
|
|
63
75
|
isObject: () => isObject,
|
|
64
76
|
isPlainObject: () => isPlainObject,
|
|
65
77
|
isPrimitive: () => isPrimitive,
|
|
66
78
|
isPromise: () => isPromise,
|
|
79
|
+
isRegExp: () => isRegExp,
|
|
80
|
+
isSet: () => isSet,
|
|
67
81
|
isString: () => isString,
|
|
68
82
|
isSymbol: () => isSymbol,
|
|
83
|
+
isTagged: () => isTagged,
|
|
84
|
+
isWeakMap: () => isWeakMap,
|
|
85
|
+
isWeakSet: () => isWeakSet,
|
|
69
86
|
iterate: () => iterate,
|
|
70
87
|
keys: () => keys,
|
|
71
88
|
last: () => last,
|
|
89
|
+
lerp: () => lerp,
|
|
72
90
|
list: () => list,
|
|
73
91
|
listify: () => listify,
|
|
74
92
|
lowerize: () => lowerize,
|
|
@@ -81,8 +99,10 @@ __export(mod_exports, {
|
|
|
81
99
|
memo: () => memo,
|
|
82
100
|
merge: () => merge,
|
|
83
101
|
min: () => min,
|
|
102
|
+
noop: () => noop,
|
|
84
103
|
objectify: () => objectify,
|
|
85
104
|
omit: () => omit,
|
|
105
|
+
once: () => once,
|
|
86
106
|
parallel: () => parallel,
|
|
87
107
|
partial: () => partial,
|
|
88
108
|
partob: () => partob,
|
|
@@ -114,6 +134,7 @@ __export(mod_exports, {
|
|
|
114
134
|
toFloat: () => toFloat,
|
|
115
135
|
toInt: () => toInt,
|
|
116
136
|
toggle: () => toggle,
|
|
137
|
+
traverse: () => traverse,
|
|
117
138
|
trim: () => trim,
|
|
118
139
|
try: () => tryit,
|
|
119
140
|
tryit: () => tryit,
|
|
@@ -144,6 +165,16 @@ function boil(array, compareFunc) {
|
|
|
144
165
|
return array.reduce(compareFunc);
|
|
145
166
|
}
|
|
146
167
|
|
|
168
|
+
// src/array/castArray.ts
|
|
169
|
+
function castArray(value) {
|
|
170
|
+
return Array.isArray(value) ? value.slice() : [value];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// src/array/castArrayIfExists.ts
|
|
174
|
+
function castArrayIfExists(value) {
|
|
175
|
+
return Array.isArray(value) ? value.slice() : value != null ? [value] : value;
|
|
176
|
+
}
|
|
177
|
+
|
|
147
178
|
// src/array/cluster.ts
|
|
148
179
|
function cluster(array, size = 2) {
|
|
149
180
|
const clusters = [];
|
|
@@ -263,20 +294,11 @@ function list(startOrLength, end, valueOrMapper, step) {
|
|
|
263
294
|
function mapify(array, getKey, getValue = (item) => item) {
|
|
264
295
|
const map2 = /* @__PURE__ */ new Map();
|
|
265
296
|
for (const item of array) {
|
|
266
|
-
map2.set(getKey(item), getValue(item));
|
|
297
|
+
map2.set(getKey(item, map2.size), getValue(item, map2.size));
|
|
267
298
|
}
|
|
268
299
|
return map2;
|
|
269
300
|
}
|
|
270
301
|
|
|
271
|
-
// src/array/max.ts
|
|
272
|
-
function max(array, getter) {
|
|
273
|
-
if (!array || (array.length ?? 0) === 0) {
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
const get2 = getter ?? ((v) => v);
|
|
277
|
-
return array.reduce((a, b) => get2(a) > get2(b) ? a : b);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
302
|
// src/array/merge.ts
|
|
281
303
|
function merge(prev, array, toKey) {
|
|
282
304
|
if (!array && !prev) {
|
|
@@ -298,15 +320,6 @@ function merge(prev, array, toKey) {
|
|
|
298
320
|
});
|
|
299
321
|
}
|
|
300
322
|
|
|
301
|
-
// src/array/min.ts
|
|
302
|
-
function min(array, getter) {
|
|
303
|
-
if (!array || (array.length ?? 0) === 0) {
|
|
304
|
-
return null;
|
|
305
|
-
}
|
|
306
|
-
const get2 = getter ?? ((v) => v);
|
|
307
|
-
return array.reduce((a, b) => get2(a) < get2(b) ? a : b);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
323
|
// src/array/objectify.ts
|
|
311
324
|
function objectify(array, getKey, getValue = (item) => item) {
|
|
312
325
|
return array.reduce(
|
|
@@ -318,19 +331,6 @@ function objectify(array, getKey, getValue = (item) => item) {
|
|
|
318
331
|
);
|
|
319
332
|
}
|
|
320
333
|
|
|
321
|
-
// src/array/range.ts
|
|
322
|
-
function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
|
|
323
|
-
const mapper = isFunction(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
|
|
324
|
-
const start = end ? startOrLength : 0;
|
|
325
|
-
const final = end ?? startOrLength;
|
|
326
|
-
for (let i = start; i <= final; i += step) {
|
|
327
|
-
yield mapper(i);
|
|
328
|
-
if (i + step > final) {
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
334
|
// src/array/replace.ts
|
|
335
335
|
function replace(array, newItem, match) {
|
|
336
336
|
if (!array) {
|
|
@@ -427,32 +427,20 @@ function sort(array, getter, desc = false) {
|
|
|
427
427
|
return array.slice().sort(desc === true ? dsc : asc);
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
// src/array/sum.ts
|
|
431
|
-
function sum(array, fn) {
|
|
432
|
-
return (array || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
430
|
// src/array/toggle.ts
|
|
436
431
|
function toggle(array, item, toKey, options) {
|
|
437
|
-
if (!array && !item) {
|
|
438
|
-
return [];
|
|
439
|
-
}
|
|
440
432
|
if (!array) {
|
|
441
|
-
return [item];
|
|
433
|
+
return item !== void 0 ? [item] : [];
|
|
442
434
|
}
|
|
443
|
-
if (
|
|
435
|
+
if (item === void 0) {
|
|
444
436
|
return [...array];
|
|
445
437
|
}
|
|
446
438
|
const matcher = toKey ? (x, idx) => toKey(x, idx) === toKey(item, idx) : (x) => x === item;
|
|
447
439
|
const existing = array.find(matcher);
|
|
448
|
-
if (existing) {
|
|
440
|
+
if (existing !== void 0) {
|
|
449
441
|
return array.filter((x, idx) => !matcher(x, idx));
|
|
450
442
|
}
|
|
451
|
-
|
|
452
|
-
if (strategy === "append") {
|
|
453
|
-
return [...array, item];
|
|
454
|
-
}
|
|
455
|
-
return [item, ...array];
|
|
443
|
+
return (options == null ? void 0 : options.strategy) === "prepend" ? [item, ...array] : [...array, item];
|
|
456
444
|
}
|
|
457
445
|
|
|
458
446
|
// src/array/unique.ts
|
|
@@ -658,7 +646,7 @@ async function retry(options, func) {
|
|
|
658
646
|
if (err._exited) {
|
|
659
647
|
throw err._exited;
|
|
660
648
|
}
|
|
661
|
-
if (++i
|
|
649
|
+
if (++i >= times) {
|
|
662
650
|
throw err;
|
|
663
651
|
}
|
|
664
652
|
if (delay) {
|
|
@@ -770,6 +758,22 @@ function memo(func, options = {}) {
|
|
|
770
758
|
return memoize({}, func, options.key ?? null, options.ttl ?? null);
|
|
771
759
|
}
|
|
772
760
|
|
|
761
|
+
// src/curry/once.ts
|
|
762
|
+
var onceSymbol = Symbol();
|
|
763
|
+
var once = (fn) => {
|
|
764
|
+
const onceFn = function(...args) {
|
|
765
|
+
if (onceFn[onceSymbol] === onceSymbol) {
|
|
766
|
+
onceFn[onceSymbol] = fn.apply(this, args);
|
|
767
|
+
}
|
|
768
|
+
return onceFn[onceSymbol];
|
|
769
|
+
};
|
|
770
|
+
onceFn[onceSymbol] = onceSymbol;
|
|
771
|
+
return onceFn;
|
|
772
|
+
};
|
|
773
|
+
once.reset = (fn) => {
|
|
774
|
+
fn[onceSymbol] = onceSymbol;
|
|
775
|
+
};
|
|
776
|
+
|
|
773
777
|
// src/curry/partial.ts
|
|
774
778
|
function partial(fn, ...args) {
|
|
775
779
|
return (...rest) => fn(...[...args, ...rest]);
|
|
@@ -811,6 +815,42 @@ function throttle({ interval }, func) {
|
|
|
811
815
|
return throttled;
|
|
812
816
|
}
|
|
813
817
|
|
|
818
|
+
// src/function/always.ts
|
|
819
|
+
function always(value) {
|
|
820
|
+
return () => value;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// src/function/castComparator.ts
|
|
824
|
+
function castComparator(mapping, compare, reverse) {
|
|
825
|
+
const map2 = isFunction(mapping) ? mapping : (obj) => obj[mapping];
|
|
826
|
+
const comparator = (left, right) => {
|
|
827
|
+
const mappedLeft = map2(left);
|
|
828
|
+
const mappedRight = map2(right);
|
|
829
|
+
if (compare) {
|
|
830
|
+
return compare(mappedLeft, mappedRight);
|
|
831
|
+
}
|
|
832
|
+
return mappedLeft > mappedRight ? 1 : mappedLeft < mappedRight ? -1 : 0;
|
|
833
|
+
};
|
|
834
|
+
return reverse ? flip(comparator) : comparator;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
// src/function/castMapping.ts
|
|
838
|
+
function castMapping(mapping) {
|
|
839
|
+
return isFunction(mapping) ? mapping : mapping != null ? (input) => input[mapping] : (input) => input;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// src/function/noop.ts
|
|
843
|
+
function noop() {
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// src/number/clamp.ts
|
|
847
|
+
function clamp(n, min2, max2) {
|
|
848
|
+
if (max2 != null && min2 != null && min2 > max2) {
|
|
849
|
+
throw new Error("invalid clamp range");
|
|
850
|
+
}
|
|
851
|
+
return max2 != null && n > max2 ? max2 : min2 != null && n < min2 ? min2 : n;
|
|
852
|
+
}
|
|
853
|
+
|
|
814
854
|
// src/number/inRange.ts
|
|
815
855
|
function inRange(number, start, end) {
|
|
816
856
|
const isTypeSafe = typeof number === "number" && typeof start === "number" && (typeof end === "undefined" || typeof end === "number");
|
|
@@ -824,6 +864,42 @@ function inRange(number, start, end) {
|
|
|
824
864
|
return number >= Math.min(start, end) && number < Math.max(start, end);
|
|
825
865
|
}
|
|
826
866
|
|
|
867
|
+
// src/number/lerp.ts
|
|
868
|
+
function lerp(from, to, amount) {
|
|
869
|
+
return from + (to - from) * amount;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// src/number/max.ts
|
|
873
|
+
function max(array, getter) {
|
|
874
|
+
if (!array || (array.length ?? 0) === 0) {
|
|
875
|
+
return null;
|
|
876
|
+
}
|
|
877
|
+
const get2 = getter ?? ((v) => v);
|
|
878
|
+
return array.reduce((a, b) => get2(a) > get2(b) ? a : b);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
// src/number/min.ts
|
|
882
|
+
function min(array, getter) {
|
|
883
|
+
if (!array || (array.length ?? 0) === 0) {
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
const get2 = getter ?? ((v) => v);
|
|
887
|
+
return array.reduce((a, b) => get2(a) < get2(b) ? a : b);
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
// src/number/range.ts
|
|
891
|
+
function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
|
|
892
|
+
const mapper = isFunction(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
|
|
893
|
+
const start = end ? startOrLength : 0;
|
|
894
|
+
const final = end ?? startOrLength;
|
|
895
|
+
for (let i = start; i <= final; i += step) {
|
|
896
|
+
yield mapper(i);
|
|
897
|
+
if (i + step > final) {
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
827
903
|
// src/number/round.ts
|
|
828
904
|
function round(value, precision, toInteger = Math.round) {
|
|
829
905
|
if (precision) {
|
|
@@ -835,6 +911,11 @@ function round(value, precision, toInteger = Math.round) {
|
|
|
835
911
|
return toInteger(value);
|
|
836
912
|
}
|
|
837
913
|
|
|
914
|
+
// src/number/sum.ts
|
|
915
|
+
function sum(array, fn) {
|
|
916
|
+
return (array || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
|
|
917
|
+
}
|
|
918
|
+
|
|
838
919
|
// src/number/toFloat.ts
|
|
839
920
|
function toFloat(value, defaultValue) {
|
|
840
921
|
const parsedValue = isSymbol(value) ? Number.NaN : Number.parseFloat(value);
|
|
@@ -854,10 +935,8 @@ function assign(initial, override) {
|
|
|
854
935
|
}
|
|
855
936
|
const proto = Object.getPrototypeOf(initial);
|
|
856
937
|
const merged = proto ? { ...initial } : Object.assign(Object.create(proto), initial);
|
|
857
|
-
for (const key
|
|
858
|
-
|
|
859
|
-
merged[key] = isPlainObject(initial[key]) ? assign(initial[key], override[key]) : override[key];
|
|
860
|
-
}
|
|
938
|
+
for (const key of Object.keys(override)) {
|
|
939
|
+
merged[key] = isPlainObject(initial[key]) && isPlainObject(override[key]) ? assign(initial[key], override[key]) : override[key];
|
|
861
940
|
}
|
|
862
941
|
return merged;
|
|
863
942
|
}
|
|
@@ -878,6 +957,73 @@ function clone(obj) {
|
|
|
878
957
|
return newObj;
|
|
879
958
|
}
|
|
880
959
|
|
|
960
|
+
// src/object/cloneDeep.ts
|
|
961
|
+
var DefaultCloningStrategy = {
|
|
962
|
+
cloneMap(input, track, clone2) {
|
|
963
|
+
const output = track(/* @__PURE__ */ new Map());
|
|
964
|
+
for (const [key, value] of input) {
|
|
965
|
+
output.set(key, clone2(value));
|
|
966
|
+
}
|
|
967
|
+
return output;
|
|
968
|
+
},
|
|
969
|
+
cloneSet(input, track, clone2) {
|
|
970
|
+
const output = track(/* @__PURE__ */ new Set());
|
|
971
|
+
for (const value of input) {
|
|
972
|
+
output.add(clone2(value));
|
|
973
|
+
}
|
|
974
|
+
return output;
|
|
975
|
+
},
|
|
976
|
+
cloneArray(input, track, clone2) {
|
|
977
|
+
const output = track(new Array(input.length));
|
|
978
|
+
input.forEach((value, index) => {
|
|
979
|
+
output[index] = clone2(value);
|
|
980
|
+
});
|
|
981
|
+
return output;
|
|
982
|
+
},
|
|
983
|
+
cloneObject(input, track, clone2) {
|
|
984
|
+
const output = track(Object.create(Object.getPrototypeOf(input)));
|
|
985
|
+
for (const key of Reflect.ownKeys(input)) {
|
|
986
|
+
const descriptor = Object.getOwnPropertyDescriptor(input, key);
|
|
987
|
+
if ("value" in descriptor) {
|
|
988
|
+
descriptor.value = clone2(descriptor.value);
|
|
989
|
+
}
|
|
990
|
+
Object.defineProperty(output, key, descriptor);
|
|
991
|
+
}
|
|
992
|
+
return output;
|
|
993
|
+
},
|
|
994
|
+
cloneOther(input, track) {
|
|
995
|
+
return track(input);
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
var FastCloningStrategy = {
|
|
999
|
+
cloneObject: (input, track, clone2) => {
|
|
1000
|
+
const output = track({ ...input });
|
|
1001
|
+
for (const key of Object.keys(input)) {
|
|
1002
|
+
output[key] = clone2(input[key]);
|
|
1003
|
+
}
|
|
1004
|
+
return output;
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
function cloneDeep(root, customStrategy) {
|
|
1008
|
+
const strategy = { ...DefaultCloningStrategy, ...customStrategy };
|
|
1009
|
+
const tracked = /* @__PURE__ */ new Map();
|
|
1010
|
+
const track = (parent, newParent) => {
|
|
1011
|
+
tracked.set(parent, newParent);
|
|
1012
|
+
return newParent;
|
|
1013
|
+
};
|
|
1014
|
+
const clone2 = (value) => value && typeof value === "object" ? tracked.get(value) ?? cloneDeep2(value, strategy) : value;
|
|
1015
|
+
const cloneDeep2 = (parent, strategy2) => {
|
|
1016
|
+
const cloneParent = isObject(parent) ? strategy2.cloneObject : isArray(parent) ? strategy2.cloneArray : isMap(parent) ? strategy2.cloneMap : isSet(parent) ? strategy2.cloneSet : strategy2.cloneOther;
|
|
1017
|
+
const newParent = cloneParent(parent, track.bind(null, parent), clone2);
|
|
1018
|
+
if (!newParent) {
|
|
1019
|
+
return cloneDeep2(parent, DefaultCloningStrategy);
|
|
1020
|
+
}
|
|
1021
|
+
tracked.set(parent, newParent);
|
|
1022
|
+
return newParent;
|
|
1023
|
+
};
|
|
1024
|
+
return cloneDeep2(root, strategy);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
881
1027
|
// src/object/construct.ts
|
|
882
1028
|
function construct(obj) {
|
|
883
1029
|
if (!obj) {
|
|
@@ -1048,19 +1194,22 @@ function omit(obj, keys2) {
|
|
|
1048
1194
|
}
|
|
1049
1195
|
|
|
1050
1196
|
// src/object/pick.ts
|
|
1051
|
-
function pick(obj,
|
|
1197
|
+
function pick(obj, filter) {
|
|
1052
1198
|
if (!obj) {
|
|
1053
1199
|
return {};
|
|
1054
1200
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
{
|
|
1063
|
-
|
|
1201
|
+
let keys2 = filter;
|
|
1202
|
+
if (isArray(filter)) {
|
|
1203
|
+
filter = null;
|
|
1204
|
+
} else {
|
|
1205
|
+
keys2 = Reflect.ownKeys(obj);
|
|
1206
|
+
}
|
|
1207
|
+
return keys2.reduce((acc, key) => {
|
|
1208
|
+
if (filterKey(obj, key, filter)) {
|
|
1209
|
+
acc[key] = obj[key];
|
|
1210
|
+
}
|
|
1211
|
+
return acc;
|
|
1212
|
+
}, {});
|
|
1064
1213
|
}
|
|
1065
1214
|
|
|
1066
1215
|
// src/object/set.ts
|
|
@@ -1096,6 +1245,104 @@ function shake(obj, filter = (value) => value === void 0) {
|
|
|
1096
1245
|
}, {});
|
|
1097
1246
|
}
|
|
1098
1247
|
|
|
1248
|
+
// src/object/traverse.ts
|
|
1249
|
+
function traverse(root, visitor, options, outerContext) {
|
|
1250
|
+
const context = outerContext ?? {
|
|
1251
|
+
value: null,
|
|
1252
|
+
key: null,
|
|
1253
|
+
parent: null,
|
|
1254
|
+
parents: [],
|
|
1255
|
+
path: [],
|
|
1256
|
+
skipped: /* @__PURE__ */ new Set(),
|
|
1257
|
+
skip(obj) {
|
|
1258
|
+
context.skipped.add(obj ?? context.value);
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
const { rootNeedsVisit } = options ??= {};
|
|
1262
|
+
const ownKeys = options.ownKeys ?? Object.keys;
|
|
1263
|
+
const nestedOptions = {
|
|
1264
|
+
...options,
|
|
1265
|
+
rootNeedsVisit: null
|
|
1266
|
+
};
|
|
1267
|
+
let ok = true;
|
|
1268
|
+
const visit = (value, key) => {
|
|
1269
|
+
if (context.parent.constructor === Map) {
|
|
1270
|
+
;
|
|
1271
|
+
[key, value] = value;
|
|
1272
|
+
}
|
|
1273
|
+
context.path.push(key);
|
|
1274
|
+
const result = visitor(
|
|
1275
|
+
context.value = value,
|
|
1276
|
+
context.key = key,
|
|
1277
|
+
context.parent,
|
|
1278
|
+
context,
|
|
1279
|
+
nestedOptions
|
|
1280
|
+
);
|
|
1281
|
+
if (result === false) {
|
|
1282
|
+
return ok = false;
|
|
1283
|
+
}
|
|
1284
|
+
if (value !== null && typeof value === "object" && (isArray(value) || isPlainObject(value)) && !context.skipped.has(value) && !context.parents.includes(value)) {
|
|
1285
|
+
traverse2(value, result);
|
|
1286
|
+
}
|
|
1287
|
+
context.path.pop();
|
|
1288
|
+
return ok;
|
|
1289
|
+
};
|
|
1290
|
+
const traverse2 = (parent, parentResult) => {
|
|
1291
|
+
context.parents.push(parent);
|
|
1292
|
+
context.parent = parent;
|
|
1293
|
+
if (rootNeedsVisit && parent === root) {
|
|
1294
|
+
parentResult = visitor(
|
|
1295
|
+
context.value = parent,
|
|
1296
|
+
context.key = null,
|
|
1297
|
+
context.parent,
|
|
1298
|
+
context,
|
|
1299
|
+
nestedOptions
|
|
1300
|
+
);
|
|
1301
|
+
if (parentResult === false) {
|
|
1302
|
+
return ok;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
if (isArray(parent)) {
|
|
1306
|
+
parent.slice().forEach((value, index, values) => {
|
|
1307
|
+
if (visit(value, index) === false) {
|
|
1308
|
+
values.length = 0;
|
|
1309
|
+
}
|
|
1310
|
+
});
|
|
1311
|
+
} else if (parent === root && isIterable(parent)) {
|
|
1312
|
+
let index = 0;
|
|
1313
|
+
for (const value of parent) {
|
|
1314
|
+
if (visit(value, index) === false) {
|
|
1315
|
+
return ok;
|
|
1316
|
+
}
|
|
1317
|
+
index++;
|
|
1318
|
+
}
|
|
1319
|
+
} else {
|
|
1320
|
+
for (const key of ownKeys(parent)) {
|
|
1321
|
+
if (visit(parent[key], key) === false) {
|
|
1322
|
+
return ok;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
context.parents.pop();
|
|
1327
|
+
context.parent = last(context.parents);
|
|
1328
|
+
if (ok && isFunction(parentResult)) {
|
|
1329
|
+
ok = parentResult() !== false;
|
|
1330
|
+
}
|
|
1331
|
+
return ok;
|
|
1332
|
+
};
|
|
1333
|
+
if (outerContext) {
|
|
1334
|
+
if (outerContext.skipped.has(root)) {
|
|
1335
|
+
return true;
|
|
1336
|
+
}
|
|
1337
|
+
const { value, key } = context;
|
|
1338
|
+
traverse2(root);
|
|
1339
|
+
context.value = value;
|
|
1340
|
+
context.key = key;
|
|
1341
|
+
return ok;
|
|
1342
|
+
}
|
|
1343
|
+
return traverse2(root);
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1099
1346
|
// src/object/upperize.ts
|
|
1100
1347
|
function upperize(obj) {
|
|
1101
1348
|
return mapKeys(obj, (k) => k.toUpperCase());
|
|
@@ -1291,9 +1538,14 @@ function trim(str, charsToTrim = " ") {
|
|
|
1291
1538
|
// src/typed/isArray.ts
|
|
1292
1539
|
var isArray = Array.isArray;
|
|
1293
1540
|
|
|
1541
|
+
// src/typed/isBoolean.ts
|
|
1542
|
+
function isBoolean(value) {
|
|
1543
|
+
return typeof value === "boolean";
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1294
1546
|
// src/typed/isDate.ts
|
|
1295
1547
|
function isDate(value) {
|
|
1296
|
-
return
|
|
1548
|
+
return isTagged(value, "[object Date]");
|
|
1297
1549
|
}
|
|
1298
1550
|
|
|
1299
1551
|
// src/typed/isEmpty.ts
|
|
@@ -1369,9 +1621,7 @@ function isFunction(value) {
|
|
|
1369
1621
|
}
|
|
1370
1622
|
|
|
1371
1623
|
// src/typed/isInt.ts
|
|
1372
|
-
|
|
1373
|
-
return isNumber(value) && value % 1 === 0;
|
|
1374
|
-
}
|
|
1624
|
+
var isInt = Number.isInteger;
|
|
1375
1625
|
|
|
1376
1626
|
// src/typed/isIntString.ts
|
|
1377
1627
|
function isIntString(value) {
|
|
@@ -1382,18 +1632,24 @@ function isIntString(value) {
|
|
|
1382
1632
|
return Number.isInteger(num) && `${num}` === value;
|
|
1383
1633
|
}
|
|
1384
1634
|
|
|
1635
|
+
// src/typed/isIterable.ts
|
|
1636
|
+
function isIterable(value) {
|
|
1637
|
+
return typeof value === "object" && value !== null && Symbol.iterator in value;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// src/typed/isMap.ts
|
|
1641
|
+
function isMap(value) {
|
|
1642
|
+
return isTagged(value, "[object Map]");
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1385
1645
|
// src/typed/isNumber.ts
|
|
1386
1646
|
function isNumber(value) {
|
|
1387
|
-
|
|
1388
|
-
return Number(value) === value;
|
|
1389
|
-
} catch {
|
|
1390
|
-
return false;
|
|
1391
|
-
}
|
|
1647
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
1392
1648
|
}
|
|
1393
1649
|
|
|
1394
1650
|
// src/typed/isObject.ts
|
|
1395
1651
|
function isObject(value) {
|
|
1396
|
-
return
|
|
1652
|
+
return isTagged(value, "[object Object]");
|
|
1397
1653
|
}
|
|
1398
1654
|
|
|
1399
1655
|
// src/typed/isPlainObject.ts
|
|
@@ -1402,7 +1658,12 @@ function isPlainObject(value) {
|
|
|
1402
1658
|
return false;
|
|
1403
1659
|
}
|
|
1404
1660
|
const prototype = Object.getPrototypeOf(value);
|
|
1405
|
-
return (
|
|
1661
|
+
return (
|
|
1662
|
+
// Fast path for most common objects.
|
|
1663
|
+
prototype === Object.prototype || // Support objects created without a prototype.
|
|
1664
|
+
prototype === null || // Support plain objects from other realms.
|
|
1665
|
+
Object.getPrototypeOf(prototype) === null
|
|
1666
|
+
);
|
|
1406
1667
|
}
|
|
1407
1668
|
|
|
1408
1669
|
// src/typed/isPrimitive.ts
|
|
@@ -1415,27 +1676,61 @@ function isPromise(value) {
|
|
|
1415
1676
|
return !!value && isFunction(value.then);
|
|
1416
1677
|
}
|
|
1417
1678
|
|
|
1679
|
+
// src/typed/isRegExp.ts
|
|
1680
|
+
function isRegExp(value) {
|
|
1681
|
+
return isTagged(value, "[object RegExp]");
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
// src/typed/isSet.ts
|
|
1685
|
+
function isSet(value) {
|
|
1686
|
+
return isTagged(value, "[object Set]");
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1418
1689
|
// src/typed/isString.ts
|
|
1419
1690
|
function isString(value) {
|
|
1420
|
-
return typeof value === "string"
|
|
1691
|
+
return typeof value === "string";
|
|
1421
1692
|
}
|
|
1422
1693
|
|
|
1423
1694
|
// src/typed/isSymbol.ts
|
|
1424
1695
|
function isSymbol(value) {
|
|
1425
1696
|
return typeof value === "symbol";
|
|
1426
1697
|
}
|
|
1698
|
+
|
|
1699
|
+
// src/typed/isTagged.ts
|
|
1700
|
+
function isTagged(value, tag) {
|
|
1701
|
+
return Object.prototype.toString.call(value) === tag;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
// src/typed/isWeakMap.ts
|
|
1705
|
+
function isWeakMap(value) {
|
|
1706
|
+
return isTagged(value, "[object WeakMap]");
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
// src/typed/isWeakSet.ts
|
|
1710
|
+
function isWeakSet(value) {
|
|
1711
|
+
return isTagged(value, "[object WeakSet]");
|
|
1712
|
+
}
|
|
1427
1713
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1428
1714
|
0 && (module.exports = {
|
|
1429
1715
|
AggregateError,
|
|
1716
|
+
DefaultCloningStrategy,
|
|
1717
|
+
FastCloningStrategy,
|
|
1430
1718
|
all,
|
|
1431
1719
|
alphabetical,
|
|
1720
|
+
always,
|
|
1432
1721
|
assign,
|
|
1433
1722
|
boil,
|
|
1434
1723
|
callable,
|
|
1435
1724
|
camel,
|
|
1436
1725
|
capitalize,
|
|
1726
|
+
castArray,
|
|
1727
|
+
castArrayIfExists,
|
|
1728
|
+
castComparator,
|
|
1729
|
+
castMapping,
|
|
1437
1730
|
chain,
|
|
1731
|
+
clamp,
|
|
1438
1732
|
clone,
|
|
1733
|
+
cloneDeep,
|
|
1439
1734
|
cluster,
|
|
1440
1735
|
compose,
|
|
1441
1736
|
construct,
|
|
@@ -1458,6 +1753,7 @@ function isSymbol(value) {
|
|
|
1458
1753
|
intersects,
|
|
1459
1754
|
invert,
|
|
1460
1755
|
isArray,
|
|
1756
|
+
isBoolean,
|
|
1461
1757
|
isDate,
|
|
1462
1758
|
isEmpty,
|
|
1463
1759
|
isEqual,
|
|
@@ -1465,16 +1761,24 @@ function isSymbol(value) {
|
|
|
1465
1761
|
isFunction,
|
|
1466
1762
|
isInt,
|
|
1467
1763
|
isIntString,
|
|
1764
|
+
isIterable,
|
|
1765
|
+
isMap,
|
|
1468
1766
|
isNumber,
|
|
1469
1767
|
isObject,
|
|
1470
1768
|
isPlainObject,
|
|
1471
1769
|
isPrimitive,
|
|
1472
1770
|
isPromise,
|
|
1771
|
+
isRegExp,
|
|
1772
|
+
isSet,
|
|
1473
1773
|
isString,
|
|
1474
1774
|
isSymbol,
|
|
1775
|
+
isTagged,
|
|
1776
|
+
isWeakMap,
|
|
1777
|
+
isWeakSet,
|
|
1475
1778
|
iterate,
|
|
1476
1779
|
keys,
|
|
1477
1780
|
last,
|
|
1781
|
+
lerp,
|
|
1478
1782
|
list,
|
|
1479
1783
|
listify,
|
|
1480
1784
|
lowerize,
|
|
@@ -1487,8 +1791,10 @@ function isSymbol(value) {
|
|
|
1487
1791
|
memo,
|
|
1488
1792
|
merge,
|
|
1489
1793
|
min,
|
|
1794
|
+
noop,
|
|
1490
1795
|
objectify,
|
|
1491
1796
|
omit,
|
|
1797
|
+
once,
|
|
1492
1798
|
parallel,
|
|
1493
1799
|
partial,
|
|
1494
1800
|
partob,
|
|
@@ -1520,6 +1826,7 @@ function isSymbol(value) {
|
|
|
1520
1826
|
toFloat,
|
|
1521
1827
|
toInt,
|
|
1522
1828
|
toggle,
|
|
1829
|
+
traverse,
|
|
1523
1830
|
trim,
|
|
1524
1831
|
try: null,
|
|
1525
1832
|
tryit,
|