radashi 12.2.0-beta.cd4d01e → 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/LICENSE.md +1 -1
- package/README.md +88 -44
- package/dist/radashi.cjs +592 -201
- package/dist/radashi.d.cts +1603 -212
- package/dist/radashi.d.ts +1603 -212
- package/dist/radashi.js +566 -201
- package/package.json +52 -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,
|
|
@@ -43,6 +52,7 @@ __export(mod_exports, {
|
|
|
43
52
|
filterKey: () => filterKey,
|
|
44
53
|
first: () => first,
|
|
45
54
|
flat: () => flat,
|
|
55
|
+
flip: () => flip,
|
|
46
56
|
fork: () => fork,
|
|
47
57
|
get: () => get,
|
|
48
58
|
group: () => group,
|
|
@@ -51,6 +61,7 @@ __export(mod_exports, {
|
|
|
51
61
|
intersects: () => intersects,
|
|
52
62
|
invert: () => invert,
|
|
53
63
|
isArray: () => isArray,
|
|
64
|
+
isBoolean: () => isBoolean,
|
|
54
65
|
isDate: () => isDate,
|
|
55
66
|
isEmpty: () => isEmpty,
|
|
56
67
|
isEqual: () => isEqual,
|
|
@@ -58,16 +69,24 @@ __export(mod_exports, {
|
|
|
58
69
|
isFunction: () => isFunction,
|
|
59
70
|
isInt: () => isInt,
|
|
60
71
|
isIntString: () => isIntString,
|
|
72
|
+
isIterable: () => isIterable,
|
|
73
|
+
isMap: () => isMap,
|
|
61
74
|
isNumber: () => isNumber,
|
|
62
75
|
isObject: () => isObject,
|
|
63
76
|
isPlainObject: () => isPlainObject,
|
|
64
77
|
isPrimitive: () => isPrimitive,
|
|
65
78
|
isPromise: () => isPromise,
|
|
79
|
+
isRegExp: () => isRegExp,
|
|
80
|
+
isSet: () => isSet,
|
|
66
81
|
isString: () => isString,
|
|
67
82
|
isSymbol: () => isSymbol,
|
|
83
|
+
isTagged: () => isTagged,
|
|
84
|
+
isWeakMap: () => isWeakMap,
|
|
85
|
+
isWeakSet: () => isWeakSet,
|
|
68
86
|
iterate: () => iterate,
|
|
69
87
|
keys: () => keys,
|
|
70
88
|
last: () => last,
|
|
89
|
+
lerp: () => lerp,
|
|
71
90
|
list: () => list,
|
|
72
91
|
listify: () => listify,
|
|
73
92
|
lowerize: () => lowerize,
|
|
@@ -75,12 +94,15 @@ __export(mod_exports, {
|
|
|
75
94
|
mapEntries: () => mapEntries,
|
|
76
95
|
mapKeys: () => mapKeys,
|
|
77
96
|
mapValues: () => mapValues,
|
|
97
|
+
mapify: () => mapify,
|
|
78
98
|
max: () => max,
|
|
79
99
|
memo: () => memo,
|
|
80
100
|
merge: () => merge,
|
|
81
101
|
min: () => min,
|
|
102
|
+
noop: () => noop,
|
|
82
103
|
objectify: () => objectify,
|
|
83
104
|
omit: () => omit,
|
|
105
|
+
once: () => once,
|
|
84
106
|
parallel: () => parallel,
|
|
85
107
|
partial: () => partial,
|
|
86
108
|
partob: () => partob,
|
|
@@ -93,7 +115,9 @@ __export(mod_exports, {
|
|
|
93
115
|
replace: () => replace,
|
|
94
116
|
replaceOrAppend: () => replaceOrAppend,
|
|
95
117
|
retry: () => retry,
|
|
118
|
+
round: () => round,
|
|
96
119
|
select: () => select,
|
|
120
|
+
selectFirst: () => selectFirst,
|
|
97
121
|
series: () => series,
|
|
98
122
|
set: () => set,
|
|
99
123
|
shake: () => shake,
|
|
@@ -110,11 +134,13 @@ __export(mod_exports, {
|
|
|
110
134
|
toFloat: () => toFloat,
|
|
111
135
|
toInt: () => toInt,
|
|
112
136
|
toggle: () => toggle,
|
|
137
|
+
traverse: () => traverse,
|
|
113
138
|
trim: () => trim,
|
|
114
139
|
try: () => tryit,
|
|
115
140
|
tryit: () => tryit,
|
|
116
141
|
uid: () => uid,
|
|
117
142
|
unique: () => unique,
|
|
143
|
+
unzip: () => unzip,
|
|
118
144
|
upperize: () => upperize,
|
|
119
145
|
zip: () => zip,
|
|
120
146
|
zipToObject: () => zipToObject
|
|
@@ -122,13 +148,13 @@ __export(mod_exports, {
|
|
|
122
148
|
module.exports = __toCommonJS(mod_exports);
|
|
123
149
|
|
|
124
150
|
// src/array/alphabetical.ts
|
|
125
|
-
function alphabetical(array, getter,
|
|
151
|
+
function alphabetical(array, getter, direction = "asc") {
|
|
126
152
|
if (!array) {
|
|
127
153
|
return [];
|
|
128
154
|
}
|
|
129
155
|
const asc = (a, b) => `${getter(a)}`.localeCompare(getter(b));
|
|
130
156
|
const dsc = (a, b) => `${getter(b)}`.localeCompare(getter(a));
|
|
131
|
-
return array.slice().sort(
|
|
157
|
+
return array.slice().sort(direction === "desc" ? dsc : asc);
|
|
132
158
|
}
|
|
133
159
|
|
|
134
160
|
// src/array/boil.ts
|
|
@@ -139,12 +165,23 @@ function boil(array, compareFunc) {
|
|
|
139
165
|
return array.reduce(compareFunc);
|
|
140
166
|
}
|
|
141
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
|
+
|
|
142
178
|
// src/array/cluster.ts
|
|
143
|
-
function cluster(
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
179
|
+
function cluster(array, size = 2) {
|
|
180
|
+
const clusters = [];
|
|
181
|
+
for (let i = 0; i < array.length; i += size) {
|
|
182
|
+
clusters.push(array.slice(i, i + size));
|
|
183
|
+
}
|
|
184
|
+
return clusters;
|
|
148
185
|
}
|
|
149
186
|
|
|
150
187
|
// src/array/counting.ts
|
|
@@ -152,11 +189,14 @@ function counting(array, identity) {
|
|
|
152
189
|
if (!array) {
|
|
153
190
|
return {};
|
|
154
191
|
}
|
|
155
|
-
return array.reduce(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
192
|
+
return array.reduce(
|
|
193
|
+
(acc, item) => {
|
|
194
|
+
const id = identity(item);
|
|
195
|
+
acc[id] = (acc[id] ?? 0) + 1;
|
|
196
|
+
return acc;
|
|
197
|
+
},
|
|
198
|
+
{}
|
|
199
|
+
);
|
|
160
200
|
}
|
|
161
201
|
|
|
162
202
|
// src/array/diff.ts
|
|
@@ -170,10 +210,13 @@ function diff(root, other, identity = (t) => t) {
|
|
|
170
210
|
if (!(other == null ? void 0 : other.length)) {
|
|
171
211
|
return [...root];
|
|
172
212
|
}
|
|
173
|
-
const bKeys = other.reduce(
|
|
174
|
-
acc
|
|
175
|
-
|
|
176
|
-
|
|
213
|
+
const bKeys = other.reduce(
|
|
214
|
+
(acc, item) => {
|
|
215
|
+
acc[identity(item)] = true;
|
|
216
|
+
return acc;
|
|
217
|
+
},
|
|
218
|
+
{}
|
|
219
|
+
);
|
|
177
220
|
return root.filter((a) => !bKeys[identity(a)]);
|
|
178
221
|
}
|
|
179
222
|
|
|
@@ -203,14 +246,17 @@ function fork(array, condition) {
|
|
|
203
246
|
|
|
204
247
|
// src/array/group.ts
|
|
205
248
|
function group(array, getGroupId) {
|
|
206
|
-
return array.reduce(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
acc[groupId]
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
249
|
+
return array.reduce(
|
|
250
|
+
(acc, item) => {
|
|
251
|
+
const groupId = getGroupId(item);
|
|
252
|
+
if (!acc[groupId]) {
|
|
253
|
+
acc[groupId] = [];
|
|
254
|
+
}
|
|
255
|
+
acc[groupId].push(item);
|
|
256
|
+
return acc;
|
|
257
|
+
},
|
|
258
|
+
{}
|
|
259
|
+
);
|
|
214
260
|
}
|
|
215
261
|
|
|
216
262
|
// src/array/intersects.ts
|
|
@@ -244,107 +290,85 @@ function list(startOrLength, end, valueOrMapper, step) {
|
|
|
244
290
|
return Array.from(range(startOrLength, end, valueOrMapper, step));
|
|
245
291
|
}
|
|
246
292
|
|
|
247
|
-
// src/array/
|
|
248
|
-
function
|
|
249
|
-
const
|
|
250
|
-
|
|
293
|
+
// src/array/mapify.ts
|
|
294
|
+
function mapify(array, getKey, getValue = (item) => item) {
|
|
295
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
296
|
+
for (const item of array) {
|
|
297
|
+
map2.set(getKey(item, map2.size), getValue(item, map2.size));
|
|
298
|
+
}
|
|
299
|
+
return map2;
|
|
251
300
|
}
|
|
252
301
|
|
|
253
302
|
// src/array/merge.ts
|
|
254
|
-
function merge(
|
|
255
|
-
if (!
|
|
303
|
+
function merge(prev, array, toKey) {
|
|
304
|
+
if (!array && !prev) {
|
|
256
305
|
return [];
|
|
257
306
|
}
|
|
258
|
-
if (!
|
|
259
|
-
return [...
|
|
307
|
+
if (!array) {
|
|
308
|
+
return [...prev];
|
|
260
309
|
}
|
|
261
|
-
if (!
|
|
310
|
+
if (!prev) {
|
|
262
311
|
return [];
|
|
263
312
|
}
|
|
264
|
-
if (!
|
|
265
|
-
return [...
|
|
313
|
+
if (!toKey) {
|
|
314
|
+
return [...prev];
|
|
266
315
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
acc.push(r);
|
|
273
|
-
}
|
|
274
|
-
return acc;
|
|
275
|
-
}, []);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// src/array/min.ts
|
|
279
|
-
function min(array, getter) {
|
|
280
|
-
const get2 = getter ?? ((v) => v);
|
|
281
|
-
return boil(array, (a, b) => get2(a) < get2(b) ? a : b);
|
|
316
|
+
const keys2 = array.map(toKey);
|
|
317
|
+
return prev.map((prevItem) => {
|
|
318
|
+
const index = keys2.indexOf(toKey(prevItem));
|
|
319
|
+
return index > -1 ? array[index] : prevItem;
|
|
320
|
+
});
|
|
282
321
|
}
|
|
283
322
|
|
|
284
323
|
// src/array/objectify.ts
|
|
285
324
|
function objectify(array, getKey, getValue = (item) => item) {
|
|
286
|
-
return array.reduce(
|
|
287
|
-
acc
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
|
|
294
|
-
const mapper = isFunction(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
|
|
295
|
-
const start = end ? startOrLength : 0;
|
|
296
|
-
const final = end ?? startOrLength;
|
|
297
|
-
for (let i = start; i <= final; i += step) {
|
|
298
|
-
yield mapper(i);
|
|
299
|
-
if (i + step > final) {
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
325
|
+
return array.reduce(
|
|
326
|
+
(acc, item) => {
|
|
327
|
+
acc[getKey(item)] = getValue(item);
|
|
328
|
+
return acc;
|
|
329
|
+
},
|
|
330
|
+
{}
|
|
331
|
+
);
|
|
303
332
|
}
|
|
304
333
|
|
|
305
334
|
// src/array/replace.ts
|
|
306
|
-
function replace(
|
|
307
|
-
if (!
|
|
335
|
+
function replace(array, newItem, match) {
|
|
336
|
+
if (!array) {
|
|
308
337
|
return [];
|
|
309
338
|
}
|
|
310
339
|
if (newItem === void 0) {
|
|
311
|
-
return [...
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
if (match(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
newItem,
|
|
319
|
-
...list2.slice(idx + 1, list2.length)
|
|
320
|
-
];
|
|
340
|
+
return [...array];
|
|
341
|
+
}
|
|
342
|
+
const out = array.slice();
|
|
343
|
+
for (let index = 0; index < array.length; index++) {
|
|
344
|
+
if (match(array[index], index)) {
|
|
345
|
+
out[index] = newItem;
|
|
346
|
+
break;
|
|
321
347
|
}
|
|
322
348
|
}
|
|
323
|
-
return
|
|
349
|
+
return out;
|
|
324
350
|
}
|
|
325
351
|
|
|
326
352
|
// src/array/replaceOrAppend.ts
|
|
327
|
-
function replaceOrAppend(
|
|
328
|
-
if (!
|
|
353
|
+
function replaceOrAppend(array, newItem, match) {
|
|
354
|
+
if (!array && !newItem) {
|
|
329
355
|
return [];
|
|
330
356
|
}
|
|
331
357
|
if (!newItem) {
|
|
332
|
-
return [...
|
|
358
|
+
return [...array];
|
|
333
359
|
}
|
|
334
|
-
if (!
|
|
360
|
+
if (!array) {
|
|
335
361
|
return [newItem];
|
|
336
362
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (match(
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
newItem,
|
|
343
|
-
...list2.slice(idx + 1, list2.length)
|
|
344
|
-
];
|
|
363
|
+
const out = array.slice();
|
|
364
|
+
for (let index = 0; index < array.length; index++) {
|
|
365
|
+
if (match(array[index], index)) {
|
|
366
|
+
out[index] = newItem;
|
|
367
|
+
return out;
|
|
345
368
|
}
|
|
346
369
|
}
|
|
347
|
-
|
|
370
|
+
out.push(newItem);
|
|
371
|
+
return out;
|
|
348
372
|
}
|
|
349
373
|
|
|
350
374
|
// src/array/select.ts
|
|
@@ -363,6 +387,19 @@ function select(array, mapper, condition) {
|
|
|
363
387
|
}, []);
|
|
364
388
|
}
|
|
365
389
|
|
|
390
|
+
// src/array/selectFirst.ts
|
|
391
|
+
function selectFirst(array, mapper, condition) {
|
|
392
|
+
if (!array) {
|
|
393
|
+
return void 0;
|
|
394
|
+
}
|
|
395
|
+
let foundIndex = -1;
|
|
396
|
+
const found = array.find((item, index) => {
|
|
397
|
+
foundIndex = index;
|
|
398
|
+
return condition ? condition(item, index) : mapper(item, index) != null;
|
|
399
|
+
});
|
|
400
|
+
return found === void 0 ? void 0 : mapper(found, foundIndex);
|
|
401
|
+
}
|
|
402
|
+
|
|
366
403
|
// src/array/shift.ts
|
|
367
404
|
function shift(arr, n) {
|
|
368
405
|
if (arr.length === 0) {
|
|
@@ -376,8 +413,8 @@ function shift(arr, n) {
|
|
|
376
413
|
}
|
|
377
414
|
|
|
378
415
|
// src/array/sift.ts
|
|
379
|
-
function sift(
|
|
380
|
-
return (
|
|
416
|
+
function sift(array) {
|
|
417
|
+
return (array == null ? void 0 : array.filter((x) => !!x)) ?? [];
|
|
381
418
|
}
|
|
382
419
|
|
|
383
420
|
// src/array/sort.ts
|
|
@@ -390,32 +427,20 @@ function sort(array, getter, desc = false) {
|
|
|
390
427
|
return array.slice().sort(desc === true ? dsc : asc);
|
|
391
428
|
}
|
|
392
429
|
|
|
393
|
-
// src/array/sum.ts
|
|
394
|
-
function sum(array, fn) {
|
|
395
|
-
return (array || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
430
|
// src/array/toggle.ts
|
|
399
|
-
function toggle(
|
|
400
|
-
if (!
|
|
401
|
-
return [];
|
|
402
|
-
}
|
|
403
|
-
if (!list2) {
|
|
404
|
-
return [item];
|
|
431
|
+
function toggle(array, item, toKey, options) {
|
|
432
|
+
if (!array) {
|
|
433
|
+
return item !== void 0 ? [item] : [];
|
|
405
434
|
}
|
|
406
|
-
if (
|
|
407
|
-
return [...
|
|
435
|
+
if (item === void 0) {
|
|
436
|
+
return [...array];
|
|
408
437
|
}
|
|
409
438
|
const matcher = toKey ? (x, idx) => toKey(x, idx) === toKey(item, idx) : (x) => x === item;
|
|
410
|
-
const existing =
|
|
411
|
-
if (existing) {
|
|
412
|
-
return
|
|
413
|
-
}
|
|
414
|
-
const strategy = (options == null ? void 0 : options.strategy) ?? "append";
|
|
415
|
-
if (strategy === "append") {
|
|
416
|
-
return [...list2, item];
|
|
439
|
+
const existing = array.find(matcher);
|
|
440
|
+
if (existing !== void 0) {
|
|
441
|
+
return array.filter((x, idx) => !matcher(x, idx));
|
|
417
442
|
}
|
|
418
|
-
return [item, ...
|
|
443
|
+
return (options == null ? void 0 : options.strategy) === "prepend" ? [item, ...array] : [...array, item];
|
|
419
444
|
}
|
|
420
445
|
|
|
421
446
|
// src/array/unique.ts
|
|
@@ -434,12 +459,25 @@ function unique(array, toKey) {
|
|
|
434
459
|
return [...new Set(array)];
|
|
435
460
|
}
|
|
436
461
|
|
|
437
|
-
// src/array/
|
|
438
|
-
function
|
|
462
|
+
// src/array/unzip.ts
|
|
463
|
+
function unzip(arrays) {
|
|
439
464
|
if (!arrays || !arrays.length) {
|
|
440
465
|
return [];
|
|
441
466
|
}
|
|
442
|
-
|
|
467
|
+
const out = new Array(
|
|
468
|
+
arrays.reduce((max2, arr) => Math.max(max2, arr.length), 0)
|
|
469
|
+
);
|
|
470
|
+
let index = 0;
|
|
471
|
+
const get2 = (array) => array[index];
|
|
472
|
+
for (; index < out.length; index++) {
|
|
473
|
+
out[index] = Array.from(arrays, get2);
|
|
474
|
+
}
|
|
475
|
+
return out;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// src/array/zip.ts
|
|
479
|
+
function zip(...arrays) {
|
|
480
|
+
return unzip(arrays);
|
|
443
481
|
}
|
|
444
482
|
|
|
445
483
|
// src/array/zipToObject.ts
|
|
@@ -448,10 +486,13 @@ function zipToObject(keys2, values) {
|
|
|
448
486
|
return {};
|
|
449
487
|
}
|
|
450
488
|
const getValue = isFunction(values) ? values : isArray(values) ? (_k, i) => values[i] : (_k, _i) => values;
|
|
451
|
-
return keys2.reduce(
|
|
452
|
-
acc
|
|
453
|
-
|
|
454
|
-
|
|
489
|
+
return keys2.reduce(
|
|
490
|
+
(acc, key, idx) => {
|
|
491
|
+
acc[key] = getValue(key, idx);
|
|
492
|
+
return acc;
|
|
493
|
+
},
|
|
494
|
+
{}
|
|
495
|
+
);
|
|
455
496
|
}
|
|
456
497
|
|
|
457
498
|
// src/async/AggregateError.ts
|
|
@@ -483,10 +524,13 @@ async function all(promises) {
|
|
|
483
524
|
if (isArray(promises)) {
|
|
484
525
|
return results.map((r) => r.result);
|
|
485
526
|
}
|
|
486
|
-
return results.reduce(
|
|
487
|
-
acc
|
|
488
|
-
|
|
489
|
-
|
|
527
|
+
return results.reduce(
|
|
528
|
+
(acc, item) => {
|
|
529
|
+
acc[item.key] = item.result;
|
|
530
|
+
return acc;
|
|
531
|
+
},
|
|
532
|
+
{}
|
|
533
|
+
);
|
|
490
534
|
}
|
|
491
535
|
|
|
492
536
|
// src/async/defer.ts
|
|
@@ -602,7 +646,7 @@ async function retry(options, func) {
|
|
|
602
646
|
if (err._exited) {
|
|
603
647
|
throw err._exited;
|
|
604
648
|
}
|
|
605
|
-
if (++i
|
|
649
|
+
if (++i >= times) {
|
|
606
650
|
throw err;
|
|
607
651
|
}
|
|
608
652
|
if (delay) {
|
|
@@ -684,6 +728,11 @@ function debounce({ delay }, func) {
|
|
|
684
728
|
return debounced;
|
|
685
729
|
}
|
|
686
730
|
|
|
731
|
+
// src/curry/flip.ts
|
|
732
|
+
function flip(fn) {
|
|
733
|
+
return (arg2, arg1, ...args) => fn(arg1, arg2, ...args);
|
|
734
|
+
}
|
|
735
|
+
|
|
687
736
|
// src/curry/memo.ts
|
|
688
737
|
function memoize(cache, func, keyFunc, ttl) {
|
|
689
738
|
return function callWithMemo(...args) {
|
|
@@ -709,6 +758,22 @@ function memo(func, options = {}) {
|
|
|
709
758
|
return memoize({}, func, options.key ?? null, options.ttl ?? null);
|
|
710
759
|
}
|
|
711
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
|
+
|
|
712
777
|
// src/curry/partial.ts
|
|
713
778
|
function partial(fn, ...args) {
|
|
714
779
|
return (...rest) => fn(...[...args, ...rest]);
|
|
@@ -716,10 +781,7 @@ function partial(fn, ...args) {
|
|
|
716
781
|
|
|
717
782
|
// src/curry/partob.ts
|
|
718
783
|
function partob(fn, argobj) {
|
|
719
|
-
return (restobj) => fn({
|
|
720
|
-
...argobj,
|
|
721
|
-
...restobj
|
|
722
|
-
});
|
|
784
|
+
return (restobj) => fn({ ...argobj, ...restobj });
|
|
723
785
|
}
|
|
724
786
|
|
|
725
787
|
// src/curry/proxied.ts
|
|
@@ -753,6 +815,42 @@ function throttle({ interval }, func) {
|
|
|
753
815
|
return throttled;
|
|
754
816
|
}
|
|
755
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
|
+
|
|
756
854
|
// src/number/inRange.ts
|
|
757
855
|
function inRange(number, start, end) {
|
|
758
856
|
const isTypeSafe = typeof number === "number" && typeof start === "number" && (typeof end === "undefined" || typeof end === "number");
|
|
@@ -766,24 +864,68 @@ function inRange(number, start, end) {
|
|
|
766
864
|
return number >= Math.min(start, end) && number < Math.max(start, end);
|
|
767
865
|
}
|
|
768
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
|
+
|
|
903
|
+
// src/number/round.ts
|
|
904
|
+
function round(value, precision, toInteger = Math.round) {
|
|
905
|
+
if (precision) {
|
|
906
|
+
const p = precision > 0 ? Math.min(precision, 292) : Math.max(precision, -323);
|
|
907
|
+
let [q, e] = `${value}e`.split("e");
|
|
908
|
+
[q, e] = `${toInteger(+`${q}e${+e + p}`)}e`.split("e");
|
|
909
|
+
return +`${q}e${+e - p}`;
|
|
910
|
+
}
|
|
911
|
+
return toInteger(value);
|
|
912
|
+
}
|
|
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
|
+
|
|
769
919
|
// src/number/toFloat.ts
|
|
770
920
|
function toFloat(value, defaultValue) {
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
return def;
|
|
774
|
-
}
|
|
775
|
-
const result = Number.parseFloat(value);
|
|
776
|
-
return Number.isNaN(result) ? def : result;
|
|
921
|
+
const parsedValue = isSymbol(value) ? Number.NaN : Number.parseFloat(value);
|
|
922
|
+
return Number.isNaN(parsedValue) ? defaultValue !== void 0 ? defaultValue : 0 : parsedValue;
|
|
777
923
|
}
|
|
778
924
|
|
|
779
925
|
// src/number/toInt.ts
|
|
780
926
|
function toInt(value, defaultValue) {
|
|
781
|
-
const
|
|
782
|
-
|
|
783
|
-
return def;
|
|
784
|
-
}
|
|
785
|
-
const result = Number.parseInt(value);
|
|
786
|
-
return Number.isNaN(result) ? def : result;
|
|
927
|
+
const parsedValue = isSymbol(value) ? Number.NaN : Number.parseInt(value);
|
|
928
|
+
return Number.isNaN(parsedValue) ? defaultValue !== void 0 ? defaultValue : 0 : parsedValue;
|
|
787
929
|
}
|
|
788
930
|
|
|
789
931
|
// src/object/assign.ts
|
|
@@ -793,10 +935,8 @@ function assign(initial, override) {
|
|
|
793
935
|
}
|
|
794
936
|
const proto = Object.getPrototypeOf(initial);
|
|
795
937
|
const merged = proto ? { ...initial } : Object.assign(Object.create(proto), initial);
|
|
796
|
-
for (const key
|
|
797
|
-
|
|
798
|
-
merged[key] = isPlainObject(initial[key]) ? assign(initial[key], override[key]) : override[key];
|
|
799
|
-
}
|
|
938
|
+
for (const key of Object.keys(override)) {
|
|
939
|
+
merged[key] = isPlainObject(initial[key]) && isPlainObject(override[key]) ? assign(initial[key], override[key]) : override[key];
|
|
800
940
|
}
|
|
801
941
|
return merged;
|
|
802
942
|
}
|
|
@@ -817,6 +957,73 @@ function clone(obj) {
|
|
|
817
957
|
return newObj;
|
|
818
958
|
}
|
|
819
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
|
+
|
|
820
1027
|
// src/object/construct.ts
|
|
821
1028
|
function construct(obj) {
|
|
822
1029
|
if (!obj) {
|
|
@@ -873,10 +1080,13 @@ function invert(obj) {
|
|
|
873
1080
|
return {};
|
|
874
1081
|
}
|
|
875
1082
|
const keys2 = Object.keys(obj);
|
|
876
|
-
return keys2.reduce(
|
|
877
|
-
acc
|
|
878
|
-
|
|
879
|
-
|
|
1083
|
+
return keys2.reduce(
|
|
1084
|
+
(acc, key) => {
|
|
1085
|
+
acc[obj[key]] = key;
|
|
1086
|
+
return acc;
|
|
1087
|
+
},
|
|
1088
|
+
{}
|
|
1089
|
+
);
|
|
880
1090
|
}
|
|
881
1091
|
|
|
882
1092
|
// src/object/keys.ts
|
|
@@ -932,29 +1142,38 @@ function mapEntries(obj, toEntry) {
|
|
|
932
1142
|
if (!obj) {
|
|
933
1143
|
return {};
|
|
934
1144
|
}
|
|
935
|
-
return Object.entries(obj).reduce(
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1145
|
+
return Object.entries(obj).reduce(
|
|
1146
|
+
(acc, [key, value]) => {
|
|
1147
|
+
const [newKey, newValue] = toEntry(key, value);
|
|
1148
|
+
acc[newKey] = newValue;
|
|
1149
|
+
return acc;
|
|
1150
|
+
},
|
|
1151
|
+
{}
|
|
1152
|
+
);
|
|
940
1153
|
}
|
|
941
1154
|
|
|
942
1155
|
// src/object/mapKeys.ts
|
|
943
1156
|
function mapKeys(obj, mapFunc) {
|
|
944
1157
|
const keys2 = Object.keys(obj);
|
|
945
|
-
return keys2.reduce(
|
|
946
|
-
acc
|
|
947
|
-
|
|
948
|
-
|
|
1158
|
+
return keys2.reduce(
|
|
1159
|
+
(acc, key) => {
|
|
1160
|
+
acc[mapFunc(key, obj[key])] = obj[key];
|
|
1161
|
+
return acc;
|
|
1162
|
+
},
|
|
1163
|
+
{}
|
|
1164
|
+
);
|
|
949
1165
|
}
|
|
950
1166
|
|
|
951
1167
|
// src/object/mapValues.ts
|
|
952
1168
|
function mapValues(obj, mapFunc) {
|
|
953
1169
|
const keys2 = Object.keys(obj);
|
|
954
|
-
return keys2.reduce(
|
|
955
|
-
acc
|
|
956
|
-
|
|
957
|
-
|
|
1170
|
+
return keys2.reduce(
|
|
1171
|
+
(acc, key) => {
|
|
1172
|
+
acc[key] = mapFunc(obj[key], key);
|
|
1173
|
+
return acc;
|
|
1174
|
+
},
|
|
1175
|
+
{}
|
|
1176
|
+
);
|
|
958
1177
|
}
|
|
959
1178
|
|
|
960
1179
|
// src/object/omit.ts
|
|
@@ -975,12 +1194,18 @@ function omit(obj, keys2) {
|
|
|
975
1194
|
}
|
|
976
1195
|
|
|
977
1196
|
// src/object/pick.ts
|
|
978
|
-
function pick(obj,
|
|
1197
|
+
function pick(obj, filter) {
|
|
979
1198
|
if (!obj) {
|
|
980
1199
|
return {};
|
|
981
1200
|
}
|
|
1201
|
+
let keys2 = filter;
|
|
1202
|
+
if (isArray(filter)) {
|
|
1203
|
+
filter = null;
|
|
1204
|
+
} else {
|
|
1205
|
+
keys2 = Reflect.ownKeys(obj);
|
|
1206
|
+
}
|
|
982
1207
|
return keys2.reduce((acc, key) => {
|
|
983
|
-
if (
|
|
1208
|
+
if (filterKey(obj, key, filter)) {
|
|
984
1209
|
acc[key] = obj[key];
|
|
985
1210
|
}
|
|
986
1211
|
return acc;
|
|
@@ -1020,6 +1245,104 @@ function shake(obj, filter = (value) => value === void 0) {
|
|
|
1020
1245
|
}, {});
|
|
1021
1246
|
}
|
|
1022
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
|
+
|
|
1023
1346
|
// src/object/upperize.ts
|
|
1024
1347
|
function upperize(obj) {
|
|
1025
1348
|
return mapKeys(obj, (k) => k.toUpperCase());
|
|
@@ -1041,8 +1364,15 @@ function random(min2, max2) {
|
|
|
1041
1364
|
}
|
|
1042
1365
|
|
|
1043
1366
|
// src/random/shuffle.ts
|
|
1044
|
-
function shuffle(array) {
|
|
1045
|
-
|
|
1367
|
+
function shuffle(array, random2 = random) {
|
|
1368
|
+
const newArray = array.slice();
|
|
1369
|
+
for (let idx = 0, randomIdx, item; idx < array.length; idx++) {
|
|
1370
|
+
randomIdx = random2(0, array.length - 1);
|
|
1371
|
+
item = newArray[randomIdx];
|
|
1372
|
+
newArray[randomIdx] = newArray[idx];
|
|
1373
|
+
newArray[idx] = item;
|
|
1374
|
+
}
|
|
1375
|
+
return newArray;
|
|
1046
1376
|
}
|
|
1047
1377
|
|
|
1048
1378
|
// src/random/uid.ts
|
|
@@ -1059,22 +1389,13 @@ function uid(length, specials = "") {
|
|
|
1059
1389
|
|
|
1060
1390
|
// src/series/series.ts
|
|
1061
1391
|
var series = (items, toKey = (item) => `${item}`) => {
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
...acc.itemsByIndex,
|
|
1070
|
-
[idx]: item
|
|
1071
|
-
}
|
|
1072
|
-
}),
|
|
1073
|
-
{
|
|
1074
|
-
indexesByKey: {},
|
|
1075
|
-
itemsByIndex: {}
|
|
1076
|
-
}
|
|
1077
|
-
);
|
|
1392
|
+
const indexesByKey = {};
|
|
1393
|
+
const itemsByIndex = {};
|
|
1394
|
+
for (const idx of range(items.length - 1)) {
|
|
1395
|
+
const item = items[idx];
|
|
1396
|
+
indexesByKey[toKey(item)] = idx;
|
|
1397
|
+
itemsByIndex[idx] = item;
|
|
1398
|
+
}
|
|
1078
1399
|
const first2 = () => itemsByIndex[0];
|
|
1079
1400
|
const last2 = () => itemsByIndex[items.length - 1];
|
|
1080
1401
|
const next = (current, defaultValue) => itemsByIndex[indexesByKey[toKey(current)] + 1] ?? defaultValue ?? first2();
|
|
@@ -1186,9 +1507,14 @@ function snake(str, options) {
|
|
|
1186
1507
|
|
|
1187
1508
|
// src/string/template.ts
|
|
1188
1509
|
function template(str, data, regex = /\{\{(.+?)\}\}/g) {
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1510
|
+
let result = "";
|
|
1511
|
+
let from = 0;
|
|
1512
|
+
let match;
|
|
1513
|
+
while (match = regex.exec(str)) {
|
|
1514
|
+
result += str.slice(from, match.index) + data[match[1]];
|
|
1515
|
+
from = regex.lastIndex;
|
|
1516
|
+
}
|
|
1517
|
+
return result + str.slice(from);
|
|
1192
1518
|
}
|
|
1193
1519
|
|
|
1194
1520
|
// src/string/title.ts
|
|
@@ -1212,9 +1538,14 @@ function trim(str, charsToTrim = " ") {
|
|
|
1212
1538
|
// src/typed/isArray.ts
|
|
1213
1539
|
var isArray = Array.isArray;
|
|
1214
1540
|
|
|
1541
|
+
// src/typed/isBoolean.ts
|
|
1542
|
+
function isBoolean(value) {
|
|
1543
|
+
return typeof value === "boolean";
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1215
1546
|
// src/typed/isDate.ts
|
|
1216
1547
|
function isDate(value) {
|
|
1217
|
-
return
|
|
1548
|
+
return isTagged(value, "[object Date]");
|
|
1218
1549
|
}
|
|
1219
1550
|
|
|
1220
1551
|
// src/typed/isEmpty.ts
|
|
@@ -1290,9 +1621,7 @@ function isFunction(value) {
|
|
|
1290
1621
|
}
|
|
1291
1622
|
|
|
1292
1623
|
// src/typed/isInt.ts
|
|
1293
|
-
|
|
1294
|
-
return isNumber(value) && value % 1 === 0;
|
|
1295
|
-
}
|
|
1624
|
+
var isInt = Number.isInteger;
|
|
1296
1625
|
|
|
1297
1626
|
// src/typed/isIntString.ts
|
|
1298
1627
|
function isIntString(value) {
|
|
@@ -1303,18 +1632,24 @@ function isIntString(value) {
|
|
|
1303
1632
|
return Number.isInteger(num) && `${num}` === value;
|
|
1304
1633
|
}
|
|
1305
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
|
+
|
|
1306
1645
|
// src/typed/isNumber.ts
|
|
1307
1646
|
function isNumber(value) {
|
|
1308
|
-
|
|
1309
|
-
return Number(value) === value;
|
|
1310
|
-
} catch {
|
|
1311
|
-
return false;
|
|
1312
|
-
}
|
|
1647
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
1313
1648
|
}
|
|
1314
1649
|
|
|
1315
1650
|
// src/typed/isObject.ts
|
|
1316
1651
|
function isObject(value) {
|
|
1317
|
-
return
|
|
1652
|
+
return isTagged(value, "[object Object]");
|
|
1318
1653
|
}
|
|
1319
1654
|
|
|
1320
1655
|
// src/typed/isPlainObject.ts
|
|
@@ -1323,7 +1658,12 @@ function isPlainObject(value) {
|
|
|
1323
1658
|
return false;
|
|
1324
1659
|
}
|
|
1325
1660
|
const prototype = Object.getPrototypeOf(value);
|
|
1326
|
-
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
|
+
);
|
|
1327
1667
|
}
|
|
1328
1668
|
|
|
1329
1669
|
// src/typed/isPrimitive.ts
|
|
@@ -1336,27 +1676,61 @@ function isPromise(value) {
|
|
|
1336
1676
|
return !!value && isFunction(value.then);
|
|
1337
1677
|
}
|
|
1338
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
|
+
|
|
1339
1689
|
// src/typed/isString.ts
|
|
1340
1690
|
function isString(value) {
|
|
1341
|
-
return typeof value === "string"
|
|
1691
|
+
return typeof value === "string";
|
|
1342
1692
|
}
|
|
1343
1693
|
|
|
1344
1694
|
// src/typed/isSymbol.ts
|
|
1345
1695
|
function isSymbol(value) {
|
|
1346
|
-
return
|
|
1696
|
+
return typeof value === "symbol";
|
|
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]");
|
|
1347
1712
|
}
|
|
1348
1713
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1349
1714
|
0 && (module.exports = {
|
|
1350
1715
|
AggregateError,
|
|
1716
|
+
DefaultCloningStrategy,
|
|
1717
|
+
FastCloningStrategy,
|
|
1351
1718
|
all,
|
|
1352
1719
|
alphabetical,
|
|
1720
|
+
always,
|
|
1353
1721
|
assign,
|
|
1354
1722
|
boil,
|
|
1355
1723
|
callable,
|
|
1356
1724
|
camel,
|
|
1357
1725
|
capitalize,
|
|
1726
|
+
castArray,
|
|
1727
|
+
castArrayIfExists,
|
|
1728
|
+
castComparator,
|
|
1729
|
+
castMapping,
|
|
1358
1730
|
chain,
|
|
1731
|
+
clamp,
|
|
1359
1732
|
clone,
|
|
1733
|
+
cloneDeep,
|
|
1360
1734
|
cluster,
|
|
1361
1735
|
compose,
|
|
1362
1736
|
construct,
|
|
@@ -1370,6 +1744,7 @@ function isSymbol(value) {
|
|
|
1370
1744
|
filterKey,
|
|
1371
1745
|
first,
|
|
1372
1746
|
flat,
|
|
1747
|
+
flip,
|
|
1373
1748
|
fork,
|
|
1374
1749
|
get,
|
|
1375
1750
|
group,
|
|
@@ -1378,6 +1753,7 @@ function isSymbol(value) {
|
|
|
1378
1753
|
intersects,
|
|
1379
1754
|
invert,
|
|
1380
1755
|
isArray,
|
|
1756
|
+
isBoolean,
|
|
1381
1757
|
isDate,
|
|
1382
1758
|
isEmpty,
|
|
1383
1759
|
isEqual,
|
|
@@ -1385,16 +1761,24 @@ function isSymbol(value) {
|
|
|
1385
1761
|
isFunction,
|
|
1386
1762
|
isInt,
|
|
1387
1763
|
isIntString,
|
|
1764
|
+
isIterable,
|
|
1765
|
+
isMap,
|
|
1388
1766
|
isNumber,
|
|
1389
1767
|
isObject,
|
|
1390
1768
|
isPlainObject,
|
|
1391
1769
|
isPrimitive,
|
|
1392
1770
|
isPromise,
|
|
1771
|
+
isRegExp,
|
|
1772
|
+
isSet,
|
|
1393
1773
|
isString,
|
|
1394
1774
|
isSymbol,
|
|
1775
|
+
isTagged,
|
|
1776
|
+
isWeakMap,
|
|
1777
|
+
isWeakSet,
|
|
1395
1778
|
iterate,
|
|
1396
1779
|
keys,
|
|
1397
1780
|
last,
|
|
1781
|
+
lerp,
|
|
1398
1782
|
list,
|
|
1399
1783
|
listify,
|
|
1400
1784
|
lowerize,
|
|
@@ -1402,12 +1786,15 @@ function isSymbol(value) {
|
|
|
1402
1786
|
mapEntries,
|
|
1403
1787
|
mapKeys,
|
|
1404
1788
|
mapValues,
|
|
1789
|
+
mapify,
|
|
1405
1790
|
max,
|
|
1406
1791
|
memo,
|
|
1407
1792
|
merge,
|
|
1408
1793
|
min,
|
|
1794
|
+
noop,
|
|
1409
1795
|
objectify,
|
|
1410
1796
|
omit,
|
|
1797
|
+
once,
|
|
1411
1798
|
parallel,
|
|
1412
1799
|
partial,
|
|
1413
1800
|
partob,
|
|
@@ -1420,7 +1807,9 @@ function isSymbol(value) {
|
|
|
1420
1807
|
replace,
|
|
1421
1808
|
replaceOrAppend,
|
|
1422
1809
|
retry,
|
|
1810
|
+
round,
|
|
1423
1811
|
select,
|
|
1812
|
+
selectFirst,
|
|
1424
1813
|
series,
|
|
1425
1814
|
set,
|
|
1426
1815
|
shake,
|
|
@@ -1437,11 +1826,13 @@ function isSymbol(value) {
|
|
|
1437
1826
|
toFloat,
|
|
1438
1827
|
toInt,
|
|
1439
1828
|
toggle,
|
|
1829
|
+
traverse,
|
|
1440
1830
|
trim,
|
|
1441
1831
|
try: null,
|
|
1442
1832
|
tryit,
|
|
1443
1833
|
uid,
|
|
1444
1834
|
unique,
|
|
1835
|
+
unzip,
|
|
1445
1836
|
upperize,
|
|
1446
1837
|
zip,
|
|
1447
1838
|
zipToObject
|