radashi 12.4.0 → 13.0.0-beta.55909fb
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 +58 -251
- package/dist/radashi.d.cts +2118 -2228
- package/dist/radashi.d.ts +2118 -2228
- package/dist/radashi.js +59 -247
- package/package.json +3 -3
package/dist/radashi.cjs
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
// src/array/alphabetical.ts
|
|
4
4
|
function alphabetical(array, getter, direction = "asc") {
|
|
5
|
-
if (!array) {
|
|
6
|
-
return [];
|
|
7
|
-
}
|
|
8
5
|
const asc = (a, b) => `${getter(a)}`.localeCompare(getter(b));
|
|
9
6
|
const dsc = (a, b) => `${getter(b)}`.localeCompare(getter(a));
|
|
10
7
|
return array.slice().sort(direction === "desc" ? dsc : asc);
|
|
@@ -12,10 +9,7 @@ function alphabetical(array, getter, direction = "asc") {
|
|
|
12
9
|
|
|
13
10
|
// src/array/boil.ts
|
|
14
11
|
function boil(array, compareFunc) {
|
|
15
|
-
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return array.reduce(compareFunc);
|
|
12
|
+
return array.length ? array.reduce(compareFunc) : null;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
// src/array/cartesianProduct.ts
|
|
@@ -56,9 +50,6 @@ function cluster(array, size = 2) {
|
|
|
56
50
|
|
|
57
51
|
// src/array/counting.ts
|
|
58
52
|
function counting(array, identity) {
|
|
59
|
-
if (!array) {
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
53
|
return array.reduce(
|
|
63
54
|
(acc, item) => {
|
|
64
55
|
const id = identity(item);
|
|
@@ -71,15 +62,6 @@ function counting(array, identity) {
|
|
|
71
62
|
|
|
72
63
|
// src/array/diff.ts
|
|
73
64
|
function diff(root, other, identity = (t) => t) {
|
|
74
|
-
if (!(root == null ? void 0 : root.length) && !(other == null ? void 0 : other.length)) {
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
if ((root == null ? void 0 : root.length) === void 0) {
|
|
78
|
-
return [...other];
|
|
79
|
-
}
|
|
80
|
-
if (!(other == null ? void 0 : other.length)) {
|
|
81
|
-
return [...root];
|
|
82
|
-
}
|
|
83
65
|
const bKeys = other.reduce(
|
|
84
66
|
(acc, item) => {
|
|
85
67
|
acc[identity(item)] = true;
|
|
@@ -92,7 +74,7 @@ function diff(root, other, identity = (t) => t) {
|
|
|
92
74
|
|
|
93
75
|
// src/array/first.ts
|
|
94
76
|
function first(array, defaultValue) {
|
|
95
|
-
return
|
|
77
|
+
return array.length > 0 ? array[0] : defaultValue;
|
|
96
78
|
}
|
|
97
79
|
|
|
98
80
|
// src/array/flat.ts
|
|
@@ -106,10 +88,8 @@ function flat(lists) {
|
|
|
106
88
|
// src/array/fork.ts
|
|
107
89
|
function fork(array, condition) {
|
|
108
90
|
const forked = [[], []];
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
forked[condition(item) ? 0 : 1].push(item);
|
|
112
|
-
}
|
|
91
|
+
for (const item of array) {
|
|
92
|
+
forked[condition(item) ? 0 : 1].push(item);
|
|
113
93
|
}
|
|
114
94
|
return forked;
|
|
115
95
|
}
|
|
@@ -131,9 +111,6 @@ function group(array, getGroupId) {
|
|
|
131
111
|
|
|
132
112
|
// src/array/intersects.ts
|
|
133
113
|
function intersects(listA, listB, identity) {
|
|
134
|
-
if (!listA || !listB) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
114
|
if (identity) {
|
|
138
115
|
const known = new Set(listA.map(identity));
|
|
139
116
|
return listB.some((item) => known.has(identity(item)));
|
|
@@ -152,7 +129,7 @@ function iterate(count, func, initValue) {
|
|
|
152
129
|
|
|
153
130
|
// src/array/last.ts
|
|
154
131
|
function last(array, defaultValue) {
|
|
155
|
-
return
|
|
132
|
+
return array.length > 0 ? array[array.length - 1] : defaultValue;
|
|
156
133
|
}
|
|
157
134
|
|
|
158
135
|
// src/array/list.ts
|
|
@@ -171,18 +148,6 @@ function mapify(array, getKey, getValue = (item) => item) {
|
|
|
171
148
|
|
|
172
149
|
// src/array/merge.ts
|
|
173
150
|
function merge(prev, array, toKey) {
|
|
174
|
-
if (!array && !prev) {
|
|
175
|
-
return [];
|
|
176
|
-
}
|
|
177
|
-
if (!array) {
|
|
178
|
-
return [...prev];
|
|
179
|
-
}
|
|
180
|
-
if (!prev) {
|
|
181
|
-
return [];
|
|
182
|
-
}
|
|
183
|
-
if (!toKey) {
|
|
184
|
-
return [...prev];
|
|
185
|
-
}
|
|
186
151
|
const keys2 = /* @__PURE__ */ new Map();
|
|
187
152
|
for (const item of array) {
|
|
188
153
|
keys2.set(toKey(item), item);
|
|
@@ -204,16 +169,8 @@ function objectify(array, getKey, getValue = (item) => item) {
|
|
|
204
169
|
);
|
|
205
170
|
}
|
|
206
171
|
|
|
207
|
-
// src/array/remove.ts
|
|
208
|
-
function remove(array, predicate) {
|
|
209
|
-
return array.filter((item) => !predicate(item));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
172
|
// src/array/replace.ts
|
|
213
173
|
function replace(array, newItem, match) {
|
|
214
|
-
if (!array) {
|
|
215
|
-
return [];
|
|
216
|
-
}
|
|
217
174
|
if (newItem === void 0) {
|
|
218
175
|
return [...array];
|
|
219
176
|
}
|
|
@@ -229,15 +186,9 @@ function replace(array, newItem, match) {
|
|
|
229
186
|
|
|
230
187
|
// src/array/replaceOrAppend.ts
|
|
231
188
|
function replaceOrAppend(array, newItem, match) {
|
|
232
|
-
if (
|
|
233
|
-
return [];
|
|
234
|
-
}
|
|
235
|
-
if (!newItem) {
|
|
189
|
+
if (newItem === void 0) {
|
|
236
190
|
return [...array];
|
|
237
191
|
}
|
|
238
|
-
if (!array) {
|
|
239
|
-
return [newItem];
|
|
240
|
-
}
|
|
241
192
|
const out = array.slice();
|
|
242
193
|
for (let index = 0; index < array.length; index++) {
|
|
243
194
|
if (match(array[index], index)) {
|
|
@@ -251,9 +202,6 @@ function replaceOrAppend(array, newItem, match) {
|
|
|
251
202
|
|
|
252
203
|
// src/array/select.ts
|
|
253
204
|
function select(array, mapper, condition) {
|
|
254
|
-
if (!array) {
|
|
255
|
-
return [];
|
|
256
|
-
}
|
|
257
205
|
let mapped;
|
|
258
206
|
return array.reduce((acc, item, index) => {
|
|
259
207
|
if (condition) {
|
|
@@ -267,9 +215,6 @@ function select(array, mapper, condition) {
|
|
|
267
215
|
|
|
268
216
|
// src/array/selectFirst.ts
|
|
269
217
|
function selectFirst(array, mapper, condition) {
|
|
270
|
-
if (!array) {
|
|
271
|
-
return void 0;
|
|
272
|
-
}
|
|
273
218
|
let foundIndex = -1;
|
|
274
219
|
const found = array.find((item, index) => {
|
|
275
220
|
foundIndex = index;
|
|
@@ -297,9 +242,6 @@ function sift(array) {
|
|
|
297
242
|
|
|
298
243
|
// src/array/sort.ts
|
|
299
244
|
function sort(array, getter, desc = false) {
|
|
300
|
-
if (!array) {
|
|
301
|
-
return [];
|
|
302
|
-
}
|
|
303
245
|
const asc = (a, b) => getter(a) - getter(b);
|
|
304
246
|
const dsc = (a, b) => getter(b) - getter(a);
|
|
305
247
|
return array.slice().sort(desc === true ? dsc : asc);
|
|
@@ -307,9 +249,6 @@ function sort(array, getter, desc = false) {
|
|
|
307
249
|
|
|
308
250
|
// src/array/toggle.ts
|
|
309
251
|
function toggle(array, item, toKey, options) {
|
|
310
|
-
if (!array) {
|
|
311
|
-
return item !== void 0 ? [item] : [];
|
|
312
|
-
}
|
|
313
252
|
if (item === void 0) {
|
|
314
253
|
return [...array];
|
|
315
254
|
}
|
|
@@ -345,9 +284,6 @@ function unique(array, toKey) {
|
|
|
345
284
|
|
|
346
285
|
// src/array/unzip.ts
|
|
347
286
|
function unzip(arrays) {
|
|
348
|
-
if (!arrays || !arrays.length) {
|
|
349
|
-
return [];
|
|
350
|
-
}
|
|
351
287
|
const out = new Array(
|
|
352
288
|
arrays.reduce((max2, arr) => Math.max(max2, arr.length), 0)
|
|
353
289
|
);
|
|
@@ -366,9 +302,6 @@ function zip(...arrays) {
|
|
|
366
302
|
|
|
367
303
|
// src/array/zipToObject.ts
|
|
368
304
|
function zipToObject(keys2, values) {
|
|
369
|
-
if (!keys2 || !keys2.length) {
|
|
370
|
-
return {};
|
|
371
|
-
}
|
|
372
305
|
const getValue = isFunction(values) ? values : isArray(values) ? (_k, i) => values[i] : (_k, _i) => values;
|
|
373
306
|
return keys2.reduce(
|
|
374
307
|
(acc, key, idx) => {
|
|
@@ -455,9 +388,6 @@ function guard(func, shouldGuard) {
|
|
|
455
388
|
|
|
456
389
|
// src/async/map.ts
|
|
457
390
|
async function map(array, asyncMapFunc) {
|
|
458
|
-
if (!array) {
|
|
459
|
-
return [];
|
|
460
|
-
}
|
|
461
391
|
const result = [];
|
|
462
392
|
let index = 0;
|
|
463
393
|
for (const value of array) {
|
|
@@ -527,19 +457,17 @@ async function parallel(options, array, func) {
|
|
|
527
457
|
|
|
528
458
|
// src/async/reduce.ts
|
|
529
459
|
async function reduce(array, reducer, initialValue) {
|
|
530
|
-
|
|
531
|
-
array = [];
|
|
532
|
-
}
|
|
533
|
-
let index = 0;
|
|
460
|
+
const indices = array.keys();
|
|
534
461
|
let acc = initialValue;
|
|
535
462
|
if (acc === void 0 && arguments.length < 3) {
|
|
536
463
|
if (!array.length) {
|
|
537
464
|
throw new TypeError("Reduce of empty array with no initial value");
|
|
538
465
|
}
|
|
539
|
-
acc = array[
|
|
466
|
+
acc = array[0];
|
|
467
|
+
indices.next();
|
|
540
468
|
}
|
|
541
|
-
|
|
542
|
-
acc = await reducer(acc, array[index], index
|
|
469
|
+
for (const index of indices) {
|
|
470
|
+
acc = await reducer(acc, array[index], index);
|
|
543
471
|
}
|
|
544
472
|
return acc;
|
|
545
473
|
}
|
|
@@ -597,19 +525,6 @@ function timeout(ms, error) {
|
|
|
597
525
|
);
|
|
598
526
|
}
|
|
599
527
|
|
|
600
|
-
// src/async/toResult.ts
|
|
601
|
-
async function toResult(promise) {
|
|
602
|
-
try {
|
|
603
|
-
const result = await promise;
|
|
604
|
-
return [void 0, result];
|
|
605
|
-
} catch (error) {
|
|
606
|
-
if (isError(error)) {
|
|
607
|
-
return [error, void 0];
|
|
608
|
-
}
|
|
609
|
-
throw error;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
|
|
613
528
|
// src/async/tryit.ts
|
|
614
529
|
function tryit(func) {
|
|
615
530
|
return (...args) => {
|
|
@@ -661,31 +576,30 @@ function compose(...funcs) {
|
|
|
661
576
|
}
|
|
662
577
|
|
|
663
578
|
// src/curry/debounce.ts
|
|
664
|
-
function debounce({ delay, leading },
|
|
665
|
-
let
|
|
666
|
-
let active = true;
|
|
579
|
+
function debounce({ delay, leading }, callee) {
|
|
580
|
+
let timeout2;
|
|
667
581
|
const debounced = (...args) => {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
timer = void 0;
|
|
673
|
-
}, delay);
|
|
674
|
-
if (leading) {
|
|
675
|
-
func(...args);
|
|
676
|
-
leading = false;
|
|
677
|
-
}
|
|
582
|
+
clearTimeout(timeout2);
|
|
583
|
+
if (leading) {
|
|
584
|
+
leading = false;
|
|
585
|
+
callee(...args);
|
|
678
586
|
} else {
|
|
679
|
-
|
|
587
|
+
timeout2 = setTimeout(
|
|
588
|
+
debounced.flush = () => {
|
|
589
|
+
debounced.flush = noop;
|
|
590
|
+
clearTimeout(timeout2);
|
|
591
|
+
callee(...args);
|
|
592
|
+
},
|
|
593
|
+
delay
|
|
594
|
+
);
|
|
680
595
|
}
|
|
681
596
|
};
|
|
682
|
-
debounced.
|
|
683
|
-
|
|
684
|
-
};
|
|
597
|
+
debounced.callee = callee;
|
|
598
|
+
debounced.flush = noop;
|
|
685
599
|
debounced.cancel = () => {
|
|
686
|
-
|
|
600
|
+
debounced.flush = noop;
|
|
601
|
+
clearTimeout(timeout2);
|
|
687
602
|
};
|
|
688
|
-
debounced.flush = (...args) => func(...args);
|
|
689
603
|
return debounced;
|
|
690
604
|
}
|
|
691
605
|
|
|
@@ -719,21 +633,6 @@ function memo(func, options = {}) {
|
|
|
719
633
|
return memoize({}, func, options.key ?? null, options.ttl ?? null);
|
|
720
634
|
}
|
|
721
635
|
|
|
722
|
-
// src/curry/memoLastCall.ts
|
|
723
|
-
function memoLastCall(fn) {
|
|
724
|
-
let lastArgs = null;
|
|
725
|
-
let lastResult = null;
|
|
726
|
-
return (...args) => {
|
|
727
|
-
if (lastArgs && lastArgs.length === args.length && lastArgs.every((arg, i) => Object.is(arg, args[i]))) {
|
|
728
|
-
return lastResult;
|
|
729
|
-
}
|
|
730
|
-
const result = fn(...args);
|
|
731
|
-
lastArgs = args;
|
|
732
|
-
lastResult = result;
|
|
733
|
-
return result;
|
|
734
|
-
};
|
|
735
|
-
}
|
|
736
|
-
|
|
737
636
|
// src/curry/once.ts
|
|
738
637
|
var once = /* @__PURE__ */ (() => {
|
|
739
638
|
const onceSymbol = /* @__PURE__ */ Symbol();
|
|
@@ -839,15 +738,7 @@ function clamp(n, min2, max2) {
|
|
|
839
738
|
}
|
|
840
739
|
|
|
841
740
|
// src/number/inRange.ts
|
|
842
|
-
function inRange(number, start, end) {
|
|
843
|
-
const isTypeSafe = typeof number === "number" && typeof start === "number" && (typeof end === "undefined" || typeof end === "number");
|
|
844
|
-
if (!isTypeSafe) {
|
|
845
|
-
return false;
|
|
846
|
-
}
|
|
847
|
-
if (typeof end === "undefined") {
|
|
848
|
-
end = start;
|
|
849
|
-
start = 0;
|
|
850
|
-
}
|
|
741
|
+
function inRange(number, start, end = 0) {
|
|
851
742
|
return number >= Math.min(start, end) && number < Math.max(start, end);
|
|
852
743
|
}
|
|
853
744
|
|
|
@@ -858,7 +749,7 @@ function lerp(from, to, amount) {
|
|
|
858
749
|
|
|
859
750
|
// src/number/max.ts
|
|
860
751
|
function max(array, getter) {
|
|
861
|
-
if (!array
|
|
752
|
+
if (!array.length) {
|
|
862
753
|
return null;
|
|
863
754
|
}
|
|
864
755
|
const get2 = getter ?? ((v) => v);
|
|
@@ -867,7 +758,7 @@ function max(array, getter) {
|
|
|
867
758
|
|
|
868
759
|
// src/number/min.ts
|
|
869
760
|
function min(array, getter) {
|
|
870
|
-
if (!array
|
|
761
|
+
if (!array.length) {
|
|
871
762
|
return null;
|
|
872
763
|
}
|
|
873
764
|
const get2 = getter ?? ((v) => v);
|
|
@@ -917,9 +808,6 @@ function toInt(value, defaultValue) {
|
|
|
917
808
|
|
|
918
809
|
// src/object/assign.ts
|
|
919
810
|
function assign(initial, override) {
|
|
920
|
-
if (!initial || !override) {
|
|
921
|
-
return initial ?? override ?? {};
|
|
922
|
-
}
|
|
923
811
|
const proto = Object.getPrototypeOf(initial);
|
|
924
812
|
const merged = proto ? { ...initial } : Object.assign(Object.create(proto), initial);
|
|
925
813
|
for (const key of Object.keys(override)) {
|
|
@@ -930,12 +818,6 @@ function assign(initial, override) {
|
|
|
930
818
|
|
|
931
819
|
// src/object/clone.ts
|
|
932
820
|
function clone(obj) {
|
|
933
|
-
if (isPrimitive(obj)) {
|
|
934
|
-
return obj;
|
|
935
|
-
}
|
|
936
|
-
if (typeof obj === "function") {
|
|
937
|
-
return obj.bind({});
|
|
938
|
-
}
|
|
939
821
|
const proto = Object.getPrototypeOf(obj);
|
|
940
822
|
const newObj = typeof (proto == null ? void 0 : proto.constructor) === "function" ? new proto.constructor() : Object.create(proto);
|
|
941
823
|
for (const key of Object.getOwnPropertyNames(obj)) {
|
|
@@ -1013,9 +895,6 @@ function cloneDeep(root, customStrategy) {
|
|
|
1013
895
|
|
|
1014
896
|
// src/object/construct.ts
|
|
1015
897
|
function construct(obj) {
|
|
1016
|
-
if (!obj) {
|
|
1017
|
-
return {};
|
|
1018
|
-
}
|
|
1019
898
|
return Object.keys(obj).reduce((acc, path) => {
|
|
1020
899
|
return set(acc, path, obj[path]);
|
|
1021
900
|
}, {});
|
|
@@ -1023,9 +902,6 @@ function construct(obj) {
|
|
|
1023
902
|
|
|
1024
903
|
// src/object/crush.ts
|
|
1025
904
|
function crush(value) {
|
|
1026
|
-
if (!value) {
|
|
1027
|
-
return {};
|
|
1028
|
-
}
|
|
1029
905
|
return function crushReducer(crushed, value2, path) {
|
|
1030
906
|
if (isObject(value2) || isArray(value2)) {
|
|
1031
907
|
for (const [prop, propValue] of Object.entries(value2)) {
|
|
@@ -1068,9 +944,6 @@ function get(value, path, defaultValue) {
|
|
|
1068
944
|
|
|
1069
945
|
// src/object/invert.ts
|
|
1070
946
|
function invert(obj) {
|
|
1071
|
-
if (!obj) {
|
|
1072
|
-
return {};
|
|
1073
|
-
}
|
|
1074
947
|
const keys2 = Object.keys(obj);
|
|
1075
948
|
return keys2.reduce(
|
|
1076
949
|
(acc, key) => {
|
|
@@ -1083,9 +956,6 @@ function invert(obj) {
|
|
|
1083
956
|
|
|
1084
957
|
// src/object/keys.ts
|
|
1085
958
|
function keys(value) {
|
|
1086
|
-
if (!value) {
|
|
1087
|
-
return [];
|
|
1088
|
-
}
|
|
1089
959
|
const keys2 = [];
|
|
1090
960
|
const keyPath = [];
|
|
1091
961
|
const recurse = (value2) => {
|
|
@@ -1111,14 +981,7 @@ function keys(value) {
|
|
|
1111
981
|
|
|
1112
982
|
// src/object/listify.ts
|
|
1113
983
|
function listify(obj, toItem) {
|
|
1114
|
-
|
|
1115
|
-
return [];
|
|
1116
|
-
}
|
|
1117
|
-
const entries = Object.entries(obj);
|
|
1118
|
-
if (entries.length === 0) {
|
|
1119
|
-
return [];
|
|
1120
|
-
}
|
|
1121
|
-
return entries.reduce((acc, entry) => {
|
|
984
|
+
return Object.entries(obj).reduce((acc, entry) => {
|
|
1122
985
|
acc.push(toItem(entry[0], entry[1]));
|
|
1123
986
|
return acc;
|
|
1124
987
|
}, []);
|
|
@@ -1131,9 +994,6 @@ function lowerize(obj) {
|
|
|
1131
994
|
|
|
1132
995
|
// src/object/mapEntries.ts
|
|
1133
996
|
function mapEntries(obj, toEntry) {
|
|
1134
|
-
if (!obj) {
|
|
1135
|
-
return {};
|
|
1136
|
-
}
|
|
1137
997
|
return Object.entries(obj).reduce(
|
|
1138
998
|
(acc, [key, value]) => {
|
|
1139
999
|
const [newKey, newValue] = toEntry(key, value);
|
|
@@ -1169,10 +1029,7 @@ function mapValues(obj, mapFunc) {
|
|
|
1169
1029
|
|
|
1170
1030
|
// src/object/omit.ts
|
|
1171
1031
|
function omit(obj, keys2) {
|
|
1172
|
-
if (
|
|
1173
|
-
return {};
|
|
1174
|
-
}
|
|
1175
|
-
if (!keys2 || keys2.length === 0) {
|
|
1032
|
+
if (keys2.length === 0) {
|
|
1176
1033
|
return obj;
|
|
1177
1034
|
}
|
|
1178
1035
|
return keys2.reduce(
|
|
@@ -1186,9 +1043,6 @@ function omit(obj, keys2) {
|
|
|
1186
1043
|
|
|
1187
1044
|
// src/object/pick.ts
|
|
1188
1045
|
function pick(obj, filter) {
|
|
1189
|
-
if (!obj) {
|
|
1190
|
-
return {};
|
|
1191
|
-
}
|
|
1192
1046
|
let keys2 = filter;
|
|
1193
1047
|
if (isArray(filter)) {
|
|
1194
1048
|
filter = null;
|
|
@@ -1205,28 +1059,20 @@ function pick(obj, filter) {
|
|
|
1205
1059
|
|
|
1206
1060
|
// src/object/set.ts
|
|
1207
1061
|
function set(initial, path, value) {
|
|
1208
|
-
if (
|
|
1209
|
-
return {};
|
|
1210
|
-
}
|
|
1211
|
-
if (!path || value === void 0) {
|
|
1062
|
+
if (value === void 0) {
|
|
1212
1063
|
return initial;
|
|
1213
1064
|
}
|
|
1214
1065
|
const root = clone(initial);
|
|
1215
1066
|
const keys2 = path.match(/[^.[\]]+/g);
|
|
1216
|
-
|
|
1217
|
-
keys2.
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
);
|
|
1221
|
-
}
|
|
1067
|
+
keys2 == null ? void 0 : keys2.reduce(
|
|
1068
|
+
(object, key, i) => i < keys2.length - 1 ? object[key] ??= isIntString(keys2[i + 1]) ? [] : {} : object[key] = value,
|
|
1069
|
+
root
|
|
1070
|
+
);
|
|
1222
1071
|
return root;
|
|
1223
1072
|
}
|
|
1224
1073
|
|
|
1225
1074
|
// src/object/shake.ts
|
|
1226
1075
|
function shake(obj, filter = (value) => value === void 0) {
|
|
1227
|
-
if (!obj) {
|
|
1228
|
-
return {};
|
|
1229
|
-
}
|
|
1230
1076
|
return Object.keys(obj).reduce((acc, key) => {
|
|
1231
1077
|
if (!filter(obj[key])) {
|
|
1232
1078
|
acc[key] = obj[key];
|
|
@@ -1433,14 +1279,7 @@ var series = (items, toKey = (item) => `${item}`) => {
|
|
|
1433
1279
|
|
|
1434
1280
|
// src/string/camel.ts
|
|
1435
1281
|
function camel(str) {
|
|
1436
|
-
|
|
1437
|
-
const parts = ((_a = str == null ? void 0 : str.replace(/([A-Z])+/g, capitalize)) == null ? void 0 : _a.split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase())) ?? [];
|
|
1438
|
-
if (parts.length === 0) {
|
|
1439
|
-
return "";
|
|
1440
|
-
}
|
|
1441
|
-
if (parts.length === 1) {
|
|
1442
|
-
return parts[0];
|
|
1443
|
-
}
|
|
1282
|
+
const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
|
|
1444
1283
|
return parts.reduce((acc, part) => {
|
|
1445
1284
|
return `${acc}${part.charAt(0).toUpperCase()}${part.slice(1)}`;
|
|
1446
1285
|
});
|
|
@@ -1448,23 +1287,13 @@ function camel(str) {
|
|
|
1448
1287
|
|
|
1449
1288
|
// src/string/capitalize.ts
|
|
1450
1289
|
function capitalize(str) {
|
|
1451
|
-
if (!str || str.length === 0) {
|
|
1452
|
-
return "";
|
|
1453
|
-
}
|
|
1454
1290
|
const lower = str.toLowerCase();
|
|
1455
1291
|
return lower.substring(0, 1).toUpperCase() + lower.substring(1, lower.length);
|
|
1456
1292
|
}
|
|
1457
1293
|
|
|
1458
1294
|
// src/string/dash.ts
|
|
1459
1295
|
function dash(str) {
|
|
1460
|
-
|
|
1461
|
-
const parts = ((_a = str == null ? void 0 : str.replace(/([A-Z])+/g, capitalize)) == null ? void 0 : _a.split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase())) ?? [];
|
|
1462
|
-
if (parts.length === 0) {
|
|
1463
|
-
return "";
|
|
1464
|
-
}
|
|
1465
|
-
if (parts.length === 1) {
|
|
1466
|
-
return parts[0];
|
|
1467
|
-
}
|
|
1296
|
+
const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
|
|
1468
1297
|
return parts.reduce((acc, part) => {
|
|
1469
1298
|
return `${acc}-${part.toLowerCase()}`;
|
|
1470
1299
|
});
|
|
@@ -1496,9 +1325,6 @@ function dedent(text, ...values) {
|
|
|
1496
1325
|
|
|
1497
1326
|
// src/string/pascal.ts
|
|
1498
1327
|
function pascal(str) {
|
|
1499
|
-
if (!str) {
|
|
1500
|
-
return "";
|
|
1501
|
-
}
|
|
1502
1328
|
const result = str.replace(
|
|
1503
1329
|
/(?:[^\w\d]|_|\s)+(\w)([A-Z]+)?/g,
|
|
1504
1330
|
(_, firstCharacter, capitalizedLetters) => {
|
|
@@ -1561,13 +1387,7 @@ function similarity(str1, str2) {
|
|
|
1561
1387
|
|
|
1562
1388
|
// src/string/snake.ts
|
|
1563
1389
|
function snake(str, options) {
|
|
1564
|
-
const parts =
|
|
1565
|
-
if (parts.length === 0) {
|
|
1566
|
-
return "";
|
|
1567
|
-
}
|
|
1568
|
-
if (parts.length === 1) {
|
|
1569
|
-
return parts[0];
|
|
1570
|
-
}
|
|
1390
|
+
const parts = str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase());
|
|
1571
1391
|
const result = parts.reduce((acc, part) => {
|
|
1572
1392
|
return `${acc}_${part.toLowerCase()}`;
|
|
1573
1393
|
});
|
|
@@ -1588,17 +1408,11 @@ function template(str, data, regex = /\{\{(.+?)\}\}/g) {
|
|
|
1588
1408
|
|
|
1589
1409
|
// src/string/title.ts
|
|
1590
1410
|
function title(str) {
|
|
1591
|
-
if (!str) {
|
|
1592
|
-
return "";
|
|
1593
|
-
}
|
|
1594
1411
|
return str.split(/(?=[A-Z])|[\.\-\s_]/).map((s) => s.trim()).filter((s) => !!s).map((s) => capitalize(s.toLowerCase())).join(" ");
|
|
1595
1412
|
}
|
|
1596
1413
|
|
|
1597
1414
|
// src/string/trim.ts
|
|
1598
1415
|
function trim(str, charsToTrim = " ") {
|
|
1599
|
-
if (!str) {
|
|
1600
|
-
return "";
|
|
1601
|
-
}
|
|
1602
1416
|
const toTrim = charsToTrim.replace(/[\W]{1}/g, "\\$&");
|
|
1603
1417
|
const regex = new RegExp(`^[${toTrim}]+|[${toTrim}]+$`, "g");
|
|
1604
1418
|
return str.replace(regex, "");
|
|
@@ -1607,20 +1421,6 @@ function trim(str, charsToTrim = " ") {
|
|
|
1607
1421
|
// src/typed/isArray.ts
|
|
1608
1422
|
var isArray = /* @__PURE__ */ (() => Array.isArray)();
|
|
1609
1423
|
|
|
1610
|
-
// src/typed/isAsyncIterable.ts
|
|
1611
|
-
var asyncIteratorSymbol = (
|
|
1612
|
-
/* c8 ignore next */
|
|
1613
|
-
Symbol.asyncIterator || Symbol.for("Symbol.asyncIterator")
|
|
1614
|
-
);
|
|
1615
|
-
function isAsyncIterable(value) {
|
|
1616
|
-
return !!value && typeof value === "object" && typeof value[asyncIteratorSymbol] === "function";
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
// src/typed/isBigInt.ts
|
|
1620
|
-
function isBigInt(value) {
|
|
1621
|
-
return typeof value === "bigint";
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
1424
|
// src/typed/isBoolean.ts
|
|
1625
1425
|
function isBoolean(value) {
|
|
1626
1426
|
return typeof value === "boolean";
|
|
@@ -1638,12 +1438,24 @@ function isDate(value) {
|
|
|
1638
1438
|
|
|
1639
1439
|
// src/typed/isEmpty.ts
|
|
1640
1440
|
function isEmpty(value) {
|
|
1641
|
-
if (
|
|
1642
|
-
return
|
|
1441
|
+
if (value === true || value === false) {
|
|
1442
|
+
return true;
|
|
1443
|
+
}
|
|
1444
|
+
if (value === null || value === void 0) {
|
|
1445
|
+
return true;
|
|
1446
|
+
}
|
|
1447
|
+
if (isNumber(value)) {
|
|
1448
|
+
return value === 0;
|
|
1643
1449
|
}
|
|
1644
1450
|
if (isDate(value)) {
|
|
1645
1451
|
return Number.isNaN(value.getTime());
|
|
1646
1452
|
}
|
|
1453
|
+
if (isFunction(value)) {
|
|
1454
|
+
return false;
|
|
1455
|
+
}
|
|
1456
|
+
if (isSymbol(value)) {
|
|
1457
|
+
return false;
|
|
1458
|
+
}
|
|
1647
1459
|
const length = value.length;
|
|
1648
1460
|
if (isNumber(length)) {
|
|
1649
1461
|
return length === 0;
|
|
@@ -1693,7 +1505,7 @@ function isError(value) {
|
|
|
1693
1505
|
|
|
1694
1506
|
// src/typed/isFloat.ts
|
|
1695
1507
|
function isFloat(value) {
|
|
1696
|
-
return isNumber(value) && value % 1 !== 0;
|
|
1508
|
+
return isNumber(value) && !Number.isNaN(value) && value % 1 !== 0;
|
|
1697
1509
|
}
|
|
1698
1510
|
|
|
1699
1511
|
// src/typed/isFunction.ts
|
|
@@ -1730,7 +1542,7 @@ function isNullish(value) {
|
|
|
1730
1542
|
|
|
1731
1543
|
// src/typed/isNumber.ts
|
|
1732
1544
|
function isNumber(value) {
|
|
1733
|
-
return typeof value === "number"
|
|
1545
|
+
return typeof value === "number";
|
|
1734
1546
|
}
|
|
1735
1547
|
|
|
1736
1548
|
// src/typed/isObject.ts
|
|
@@ -1861,8 +1673,6 @@ exports.inRange = inRange;
|
|
|
1861
1673
|
exports.intersects = intersects;
|
|
1862
1674
|
exports.invert = invert;
|
|
1863
1675
|
exports.isArray = isArray;
|
|
1864
|
-
exports.isAsyncIterable = isAsyncIterable;
|
|
1865
|
-
exports.isBigInt = isBigInt;
|
|
1866
1676
|
exports.isBoolean = isBoolean;
|
|
1867
1677
|
exports.isClass = isClass;
|
|
1868
1678
|
exports.isDate = isDate;
|
|
@@ -1906,7 +1716,6 @@ exports.mapValues = mapValues;
|
|
|
1906
1716
|
exports.mapify = mapify;
|
|
1907
1717
|
exports.max = max;
|
|
1908
1718
|
exports.memo = memo;
|
|
1909
|
-
exports.memoLastCall = memoLastCall;
|
|
1910
1719
|
exports.merge = merge;
|
|
1911
1720
|
exports.min = min;
|
|
1912
1721
|
exports.noop = noop;
|
|
@@ -1922,7 +1731,6 @@ exports.proxied = proxied;
|
|
|
1922
1731
|
exports.random = random;
|
|
1923
1732
|
exports.range = range;
|
|
1924
1733
|
exports.reduce = reduce;
|
|
1925
|
-
exports.remove = remove;
|
|
1926
1734
|
exports.replace = replace;
|
|
1927
1735
|
exports.replaceOrAppend = replaceOrAppend;
|
|
1928
1736
|
exports.retry = retry;
|
|
@@ -1946,7 +1754,6 @@ exports.timeout = timeout;
|
|
|
1946
1754
|
exports.title = title;
|
|
1947
1755
|
exports.toFloat = toFloat;
|
|
1948
1756
|
exports.toInt = toInt;
|
|
1949
|
-
exports.toResult = toResult;
|
|
1950
1757
|
exports.toggle = toggle;
|
|
1951
1758
|
exports.traverse = traverse;
|
|
1952
1759
|
exports.trim = trim;
|