@vinicunca/perkakas 0.1.0 → 0.2.1
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/index.cjs +1061 -621
- package/dist/index.d.cts +912 -115
- package/dist/index.d.ts +912 -115
- package/dist/index.js +1039 -621
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -22,232 +22,6 @@ var KEY_CODES = {
|
|
|
22
22
|
TAB: "Tab"
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
// src/function/pipe.ts
|
|
26
|
-
function pipe(value, ...operations) {
|
|
27
|
-
let ret = value;
|
|
28
|
-
const lazyOps = operations.map((op) => {
|
|
29
|
-
const { lazy, lazyArgs } = op;
|
|
30
|
-
if (lazy) {
|
|
31
|
-
const fn = lazy(...lazyArgs || []);
|
|
32
|
-
fn.indexed = lazy.indexed;
|
|
33
|
-
fn.single = lazy.single;
|
|
34
|
-
fn.index = 0;
|
|
35
|
-
fn.items = [];
|
|
36
|
-
return fn;
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
});
|
|
40
|
-
let opIdx = 0;
|
|
41
|
-
while (opIdx < operations.length) {
|
|
42
|
-
const op = operations[opIdx];
|
|
43
|
-
const lazyOp = lazyOps[opIdx];
|
|
44
|
-
if (!lazyOp) {
|
|
45
|
-
ret = op(ret);
|
|
46
|
-
opIdx++;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const lazySeq = [];
|
|
50
|
-
for (let j = opIdx; j < operations.length; j++) {
|
|
51
|
-
if (lazyOps[j]) {
|
|
52
|
-
lazySeq.push(lazyOps[j]);
|
|
53
|
-
if (lazyOps[j].single) {
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const acc = [];
|
|
61
|
-
for (const item of ret) {
|
|
62
|
-
if (_processItem({ acc, item, lazySeq })) {
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const lastLazySeq = lazySeq[lazySeq.length - 1];
|
|
67
|
-
if (lastLazySeq.single) {
|
|
68
|
-
ret = acc[0];
|
|
69
|
-
} else {
|
|
70
|
-
ret = acc;
|
|
71
|
-
}
|
|
72
|
-
opIdx += lazySeq.length;
|
|
73
|
-
}
|
|
74
|
-
return ret;
|
|
75
|
-
}
|
|
76
|
-
function _processItem({
|
|
77
|
-
acc,
|
|
78
|
-
item,
|
|
79
|
-
lazySeq
|
|
80
|
-
}) {
|
|
81
|
-
if (lazySeq.length === 0) {
|
|
82
|
-
acc.push(item);
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
let lazyResult = { done: false, hasNext: false };
|
|
86
|
-
let isDone = false;
|
|
87
|
-
for (let i = 0; i < lazySeq.length; i++) {
|
|
88
|
-
const lazyFn = lazySeq[i];
|
|
89
|
-
const indexed = lazyFn.indexed;
|
|
90
|
-
const index = lazyFn.index;
|
|
91
|
-
const items = lazyFn.items;
|
|
92
|
-
items.push(item);
|
|
93
|
-
lazyResult = indexed ? lazyFn(item, index, items) : lazyFn(item);
|
|
94
|
-
lazyFn.index++;
|
|
95
|
-
if (lazyResult.hasNext) {
|
|
96
|
-
if (lazyResult.hasMany) {
|
|
97
|
-
const nextValues = lazyResult.next;
|
|
98
|
-
for (const subItem of nextValues) {
|
|
99
|
-
const subResult = _processItem({
|
|
100
|
-
acc,
|
|
101
|
-
item: subItem,
|
|
102
|
-
lazySeq: lazySeq.slice(i + 1)
|
|
103
|
-
});
|
|
104
|
-
if (subResult) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
} else {
|
|
110
|
-
item = lazyResult.next;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (!lazyResult.hasNext) {
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
if (lazyResult.done) {
|
|
117
|
-
isDone = true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (lazyResult.hasNext) {
|
|
121
|
-
acc.push(item);
|
|
122
|
-
}
|
|
123
|
-
return !!isDone;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// src/function/create-pipe.ts
|
|
127
|
-
function createPipe(...operations) {
|
|
128
|
-
return (value) => pipe(value, ...operations);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// src/function/identity.ts
|
|
132
|
-
function identity(value) {
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/function/noop.ts
|
|
137
|
-
function noop() {
|
|
138
|
-
return void 0;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// src/function/once.ts
|
|
142
|
-
function once(fn) {
|
|
143
|
-
let called = false;
|
|
144
|
-
let ret;
|
|
145
|
-
return () => {
|
|
146
|
-
if (!called) {
|
|
147
|
-
ret = fn();
|
|
148
|
-
called = true;
|
|
149
|
-
}
|
|
150
|
-
return ret;
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// src/function/debounce.ts
|
|
155
|
-
function debounce(func, {
|
|
156
|
-
maxWaitMs,
|
|
157
|
-
timing = "trailing",
|
|
158
|
-
waitMs
|
|
159
|
-
}) {
|
|
160
|
-
if (maxWaitMs !== void 0 && waitMs !== void 0 && maxWaitMs < waitMs) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
`debounce: maxWaitMs (${maxWaitMs}) cannot be less than waitMs (${waitMs})`
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
let coolDownTimeoutId;
|
|
166
|
-
let maxWaitTimeoutId;
|
|
167
|
-
let latestCallArgs;
|
|
168
|
-
let result;
|
|
169
|
-
function handleDebouncedCall(args) {
|
|
170
|
-
latestCallArgs = args;
|
|
171
|
-
if (maxWaitMs !== void 0 && maxWaitTimeoutId === void 0) {
|
|
172
|
-
maxWaitTimeoutId = setTimeout(handleInvoke, maxWaitMs);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function handleInvoke() {
|
|
176
|
-
if (latestCallArgs === void 0) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (maxWaitTimeoutId !== void 0) {
|
|
180
|
-
const timeoutId = maxWaitTimeoutId;
|
|
181
|
-
maxWaitTimeoutId = void 0;
|
|
182
|
-
clearTimeout(timeoutId);
|
|
183
|
-
}
|
|
184
|
-
const args = latestCallArgs;
|
|
185
|
-
latestCallArgs = void 0;
|
|
186
|
-
result = func(...args);
|
|
187
|
-
}
|
|
188
|
-
function handleCoolDownEnd() {
|
|
189
|
-
if (coolDownTimeoutId === void 0) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
const timeoutId = coolDownTimeoutId;
|
|
193
|
-
coolDownTimeoutId = void 0;
|
|
194
|
-
clearTimeout(timeoutId);
|
|
195
|
-
if (latestCallArgs !== void 0) {
|
|
196
|
-
handleInvoke();
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
get cachedValue() {
|
|
201
|
-
return result;
|
|
202
|
-
},
|
|
203
|
-
call: (...args) => {
|
|
204
|
-
if (coolDownTimeoutId === void 0) {
|
|
205
|
-
if (timing === "trailing") {
|
|
206
|
-
handleDebouncedCall(args);
|
|
207
|
-
} else {
|
|
208
|
-
result = func(...args);
|
|
209
|
-
}
|
|
210
|
-
} else {
|
|
211
|
-
if (timing !== "leading") {
|
|
212
|
-
handleDebouncedCall(args);
|
|
213
|
-
}
|
|
214
|
-
const timeoutId = coolDownTimeoutId;
|
|
215
|
-
coolDownTimeoutId = void 0;
|
|
216
|
-
clearTimeout(timeoutId);
|
|
217
|
-
}
|
|
218
|
-
coolDownTimeoutId = setTimeout(
|
|
219
|
-
handleCoolDownEnd,
|
|
220
|
-
// If waitMs is not defined but maxWaitMs *is* it means the user is only
|
|
221
|
-
// interested in the leaky-bucket nature of the debouncer which is
|
|
222
|
-
// achieved by setting waitMs === maxWaitMs. If both are not defined we
|
|
223
|
-
// default to 0 which would wait until the end of the execution frame.
|
|
224
|
-
waitMs ?? maxWaitMs ?? 0
|
|
225
|
-
);
|
|
226
|
-
return result;
|
|
227
|
-
},
|
|
228
|
-
cancel: () => {
|
|
229
|
-
if (coolDownTimeoutId !== void 0) {
|
|
230
|
-
const timeoutId = coolDownTimeoutId;
|
|
231
|
-
coolDownTimeoutId = void 0;
|
|
232
|
-
clearTimeout(timeoutId);
|
|
233
|
-
}
|
|
234
|
-
if (maxWaitTimeoutId !== void 0) {
|
|
235
|
-
const timeoutId = maxWaitTimeoutId;
|
|
236
|
-
maxWaitTimeoutId = void 0;
|
|
237
|
-
clearTimeout(timeoutId);
|
|
238
|
-
}
|
|
239
|
-
latestCallArgs = void 0;
|
|
240
|
-
},
|
|
241
|
-
flush: () => {
|
|
242
|
-
handleCoolDownEnd();
|
|
243
|
-
return result;
|
|
244
|
-
},
|
|
245
|
-
get isPending() {
|
|
246
|
-
return coolDownTimeoutId !== void 0;
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
25
|
// src/function/purry.ts
|
|
252
26
|
function purry(fn, args, lazy) {
|
|
253
27
|
const diff = fn.length - args.length;
|
|
@@ -266,13 +40,6 @@ function purry(fn, args, lazy) {
|
|
|
266
40
|
throw new Error("Wrong number of arguments");
|
|
267
41
|
}
|
|
268
42
|
|
|
269
|
-
// src/function/sleep.ts
|
|
270
|
-
function sleep(timeout) {
|
|
271
|
-
return new Promise((resolve) => {
|
|
272
|
-
setTimeout(resolve, timeout);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
43
|
// src/array/all-pass.ts
|
|
277
44
|
function allPass(...args) {
|
|
278
45
|
return purry(_allPass, args);
|
|
@@ -303,148 +70,56 @@ function _chunk(array, size) {
|
|
|
303
70
|
return ret;
|
|
304
71
|
}
|
|
305
72
|
|
|
306
|
-
// src/guard/is-
|
|
307
|
-
function
|
|
308
|
-
return
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// src/guard/is-boolean.ts
|
|
312
|
-
function isBoolean(data) {
|
|
313
|
-
return typeof data === "boolean";
|
|
73
|
+
// src/guard/is-truthy.ts
|
|
74
|
+
function isTruthy(data) {
|
|
75
|
+
return !!data;
|
|
314
76
|
}
|
|
315
77
|
|
|
316
|
-
// src/
|
|
317
|
-
function
|
|
318
|
-
return
|
|
78
|
+
// src/array/compact.ts
|
|
79
|
+
function compact(items) {
|
|
80
|
+
return items.filter(isTruthy);
|
|
319
81
|
}
|
|
320
82
|
|
|
321
|
-
// src/
|
|
322
|
-
function
|
|
323
|
-
return
|
|
83
|
+
// src/array/concat.ts
|
|
84
|
+
function concat(...args) {
|
|
85
|
+
return purry(_concat, args);
|
|
324
86
|
}
|
|
325
|
-
(
|
|
326
|
-
|
|
327
|
-
return data !== void 0;
|
|
328
|
-
}
|
|
329
|
-
isDefined2.strict = strict;
|
|
330
|
-
})(isDefined || (isDefined = {}));
|
|
331
|
-
|
|
332
|
-
// src/base.ts
|
|
333
|
-
function toString(value) {
|
|
334
|
-
return Object.prototype.toString.call(value);
|
|
87
|
+
function _concat(arr1, arr2) {
|
|
88
|
+
return arr1.concat(arr2);
|
|
335
89
|
}
|
|
336
90
|
|
|
337
|
-
// src/
|
|
338
|
-
function
|
|
339
|
-
return
|
|
91
|
+
// src/array/count-by.ts
|
|
92
|
+
function _countBy(indexed) {
|
|
93
|
+
return (array, fn) => {
|
|
94
|
+
return array.reduce((ret, item, index) => {
|
|
95
|
+
const value = indexed ? fn(item, index, array) : fn(item);
|
|
96
|
+
return ret + (value ? 1 : 0);
|
|
97
|
+
}, 0);
|
|
98
|
+
};
|
|
340
99
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
function isString(data) {
|
|
344
|
-
return typeof data === "string";
|
|
100
|
+
function countBy(...args) {
|
|
101
|
+
return purry(_countBy(false), args);
|
|
345
102
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if (isArray(data) || isString(data)) {
|
|
350
|
-
return data.length === 0;
|
|
103
|
+
((countBy2) => {
|
|
104
|
+
function indexed(...args) {
|
|
105
|
+
return purry(_countBy(true), args);
|
|
351
106
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
107
|
+
countBy2.indexed = indexed;
|
|
108
|
+
})(countBy || (countBy = {}));
|
|
109
|
+
|
|
110
|
+
// src/utils/reduce-lazy.ts
|
|
111
|
+
function reduceLazy(array, lazy, indexed) {
|
|
112
|
+
const newArray = [];
|
|
113
|
+
for (let index = 0; index < array.length; index++) {
|
|
114
|
+
const item = array[index];
|
|
115
|
+
const result = indexed ? lazy(item, index, array) : lazy(item);
|
|
116
|
+
if (result.hasMany === true) {
|
|
117
|
+
newArray.push(...result.next);
|
|
118
|
+
} else if (result.hasNext) {
|
|
119
|
+
newArray.push(result.next);
|
|
355
120
|
}
|
|
356
|
-
return !(data instanceof RegExp);
|
|
357
121
|
}
|
|
358
|
-
return
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// src/guard/is-error.ts
|
|
362
|
-
function isError(data) {
|
|
363
|
-
return data instanceof Error;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// src/guard/is-function.ts
|
|
367
|
-
function isFunction(data) {
|
|
368
|
-
return typeof data === "function";
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// src/guard/is-nil.ts
|
|
372
|
-
function isNil(data) {
|
|
373
|
-
return data == null;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// src/guard/is-non-null.ts
|
|
377
|
-
function isNonNull(data) {
|
|
378
|
-
return data !== null;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// src/guard/is-not.ts
|
|
382
|
-
function isNot(predicate) {
|
|
383
|
-
return (data) => {
|
|
384
|
-
return !predicate(data);
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// src/guard/is-number.ts
|
|
389
|
-
function isNumber(data) {
|
|
390
|
-
return typeof data === "number" && !Number.isNaN(data);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// src/guard/is-promise.ts
|
|
394
|
-
function isPromise(data) {
|
|
395
|
-
return data instanceof Promise;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// src/guard/is-truthy.ts
|
|
399
|
-
function isTruthy(data) {
|
|
400
|
-
return !!data;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// src/array/compact.ts
|
|
404
|
-
function compact(items) {
|
|
405
|
-
return items.filter(isTruthy);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// src/array/concat.ts
|
|
409
|
-
function concat(...args) {
|
|
410
|
-
return purry(_concat, args);
|
|
411
|
-
}
|
|
412
|
-
function _concat(arr1, arr2) {
|
|
413
|
-
return arr1.concat(arr2);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// src/array/count-by.ts
|
|
417
|
-
function _countBy(indexed) {
|
|
418
|
-
return (array, fn) => {
|
|
419
|
-
return array.reduce((ret, item, index) => {
|
|
420
|
-
const value = indexed ? fn(item, index, array) : fn(item);
|
|
421
|
-
return ret + (value ? 1 : 0);
|
|
422
|
-
}, 0);
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
function countBy(...args) {
|
|
426
|
-
return purry(_countBy(false), args);
|
|
427
|
-
}
|
|
428
|
-
((countBy2) => {
|
|
429
|
-
function indexed(...args) {
|
|
430
|
-
return purry(_countBy(true), args);
|
|
431
|
-
}
|
|
432
|
-
countBy2.indexed = indexed;
|
|
433
|
-
})(countBy || (countBy = {}));
|
|
434
|
-
|
|
435
|
-
// src/utils/reduce-lazy.ts
|
|
436
|
-
function _reduceLazy(array, lazy, indexed) {
|
|
437
|
-
const newArray = [];
|
|
438
|
-
for (let index = 0; index < array.length; index++) {
|
|
439
|
-
const item = array[index];
|
|
440
|
-
const result = indexed ? lazy(item, index, array) : lazy(item);
|
|
441
|
-
if (result.hasMany === true) {
|
|
442
|
-
newArray.push(...result.next);
|
|
443
|
-
} else if (result.hasNext) {
|
|
444
|
-
newArray.push(result.next);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
return newArray;
|
|
122
|
+
return newArray;
|
|
448
123
|
}
|
|
449
124
|
|
|
450
125
|
// src/array/difference-with.ts
|
|
@@ -453,7 +128,7 @@ function differenceWith(...args) {
|
|
|
453
128
|
}
|
|
454
129
|
function _differenceWith(array, other, isEquals) {
|
|
455
130
|
const lazy = differenceWith.lazy(other, isEquals);
|
|
456
|
-
return
|
|
131
|
+
return reduceLazy(array, lazy);
|
|
457
132
|
}
|
|
458
133
|
((differenceWith2) => {
|
|
459
134
|
function lazy(other, isEquals) {
|
|
@@ -480,7 +155,7 @@ function difference(...args) {
|
|
|
480
155
|
}
|
|
481
156
|
function _difference(array, other) {
|
|
482
157
|
const lazy = difference.lazy(other);
|
|
483
|
-
return
|
|
158
|
+
return reduceLazy(array, lazy);
|
|
484
159
|
}
|
|
485
160
|
((difference2) => {
|
|
486
161
|
function lazy(other) {
|
|
@@ -519,7 +194,7 @@ function drop(...args) {
|
|
|
519
194
|
return purry(_drop, args, drop.lazy);
|
|
520
195
|
}
|
|
521
196
|
function _drop(array, n) {
|
|
522
|
-
return
|
|
197
|
+
return reduceLazy(array, drop.lazy(n));
|
|
523
198
|
}
|
|
524
199
|
((drop2) => {
|
|
525
200
|
function lazy(n) {
|
|
@@ -542,26 +217,179 @@ function _drop(array, n) {
|
|
|
542
217
|
drop2.lazy = lazy;
|
|
543
218
|
})(drop || (drop = {}));
|
|
544
219
|
|
|
220
|
+
// src/array/has-at-least.ts
|
|
221
|
+
function hasAtLeast(...args) {
|
|
222
|
+
return purry(hasAtLeastImplementation, args);
|
|
223
|
+
}
|
|
224
|
+
function hasAtLeastImplementation(data, minimum) {
|
|
225
|
+
return data.length >= minimum;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/utils/swap-in-place.ts
|
|
229
|
+
function swapInPlace(data, i, j) {
|
|
230
|
+
[data[i], data[j]] = [data[j], data[i]];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/utils/heap.ts
|
|
234
|
+
function heapify(heap, compareFn) {
|
|
235
|
+
for (let i = Math.floor(heap.length / 2) - 1; i >= 0; i--) {
|
|
236
|
+
heapSiftDown(heap, i, compareFn);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function heapMaybeInsert(heap, compareFn, item) {
|
|
240
|
+
if (!hasAtLeast(heap, 1)) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const head = heap[0];
|
|
244
|
+
if (compareFn(item, head) >= 0) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
heap[0] = item;
|
|
248
|
+
heapSiftDown(heap, 0, compareFn);
|
|
249
|
+
return head;
|
|
250
|
+
}
|
|
251
|
+
function heapSiftDown(heap, index, compareFn) {
|
|
252
|
+
let currentIndex = index;
|
|
253
|
+
while (currentIndex * 2 + 1 < heap.length) {
|
|
254
|
+
const firstChildIndex = currentIndex * 2 + 1;
|
|
255
|
+
let swapIndex = compareFn(heap[currentIndex], heap[firstChildIndex]) < 0 ? firstChildIndex : currentIndex;
|
|
256
|
+
const secondChildIndex = firstChildIndex + 1;
|
|
257
|
+
if (secondChildIndex < heap.length && compareFn(heap[swapIndex], heap[secondChildIndex]) < 0) {
|
|
258
|
+
swapIndex = secondChildIndex;
|
|
259
|
+
}
|
|
260
|
+
if (swapIndex === currentIndex) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
swapInPlace(heap, currentIndex, swapIndex);
|
|
264
|
+
currentIndex = swapIndex;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// src/utils/purry-order-rules.ts
|
|
269
|
+
var COMPARATORS = {
|
|
270
|
+
asc: (x, y) => x > y,
|
|
271
|
+
desc: (x, y) => x < y
|
|
272
|
+
};
|
|
273
|
+
function purryOrderRules(func, inputArgs) {
|
|
274
|
+
const [dataOrRule, ...rules] = Array.isArray(inputArgs) ? inputArgs : Array.from(inputArgs);
|
|
275
|
+
if (!isOrderRule(dataOrRule)) {
|
|
276
|
+
const compareFn2 = orderRuleComparer(...rules);
|
|
277
|
+
return func(dataOrRule, compareFn2);
|
|
278
|
+
}
|
|
279
|
+
const compareFn = orderRuleComparer(dataOrRule, ...rules);
|
|
280
|
+
return (data) => func(data, compareFn);
|
|
281
|
+
}
|
|
282
|
+
function purryOrderRulesWithArgument(func, inputArgs) {
|
|
283
|
+
const [first2, second, ...rest] = Array.from(inputArgs);
|
|
284
|
+
let arg;
|
|
285
|
+
let argRemoved;
|
|
286
|
+
if (isOrderRule(second)) {
|
|
287
|
+
arg = first2;
|
|
288
|
+
argRemoved = [second, ...rest];
|
|
289
|
+
} else {
|
|
290
|
+
arg = second;
|
|
291
|
+
argRemoved = [first2, ...rest];
|
|
292
|
+
}
|
|
293
|
+
return purryOrderRules((...args) => func(...args, arg), argRemoved);
|
|
294
|
+
}
|
|
295
|
+
function orderRuleComparer(primaryRule, secondaryRule, ...otherRules) {
|
|
296
|
+
const projector = typeof primaryRule === "function" ? primaryRule : primaryRule[0];
|
|
297
|
+
const direction = typeof primaryRule === "function" ? "asc" : primaryRule[1];
|
|
298
|
+
const comparator = COMPARATORS[direction];
|
|
299
|
+
const nextComparer = secondaryRule === void 0 ? void 0 : orderRuleComparer(secondaryRule, ...otherRules);
|
|
300
|
+
return (a, b) => {
|
|
301
|
+
const projectedA = projector(a);
|
|
302
|
+
const projectedB = projector(b);
|
|
303
|
+
if (comparator(projectedA, projectedB)) {
|
|
304
|
+
return 1;
|
|
305
|
+
}
|
|
306
|
+
if (comparator(projectedB, projectedA)) {
|
|
307
|
+
return -1;
|
|
308
|
+
}
|
|
309
|
+
return nextComparer?.(a, b) ?? 0;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function isOrderRule(x) {
|
|
313
|
+
if (isProjection(x)) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
if (typeof x !== "object" || !Array.isArray(x)) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
const [maybeProjection, maybeDirection, ...rest] = x;
|
|
320
|
+
return isProjection(maybeProjection) && maybeDirection in COMPARATORS && rest.length === 0;
|
|
321
|
+
}
|
|
322
|
+
function isProjection(x) {
|
|
323
|
+
return typeof x === "function" && x.length === 1;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/array/drop-first-by.ts
|
|
327
|
+
function dropFirstBy(...args) {
|
|
328
|
+
return purryOrderRulesWithArgument(dropFirstByImplementation, args);
|
|
329
|
+
}
|
|
330
|
+
function dropFirstByImplementation(data, compareFn, n) {
|
|
331
|
+
if (n >= data.length) {
|
|
332
|
+
return [];
|
|
333
|
+
}
|
|
334
|
+
if (n <= 0) {
|
|
335
|
+
return [...data];
|
|
336
|
+
}
|
|
337
|
+
const heap = data.slice(0, n);
|
|
338
|
+
heapify(heap, compareFn);
|
|
339
|
+
const out = [];
|
|
340
|
+
const rest = data.slice(n);
|
|
341
|
+
for (const item of rest) {
|
|
342
|
+
const previousHead = heapMaybeInsert(heap, compareFn, item);
|
|
343
|
+
out.push(previousHead ?? item);
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/array/drop-last-while.ts
|
|
349
|
+
function dropLastWhile(...args) {
|
|
350
|
+
return purry(_dropLastWhile, args);
|
|
351
|
+
}
|
|
352
|
+
function _dropLastWhile(data, predicate) {
|
|
353
|
+
for (let i = data.length - 1; i >= 0; i--) {
|
|
354
|
+
if (!predicate(data[i])) {
|
|
355
|
+
return data.slice(0, i + 1);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return [];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/array/drop-while.ts
|
|
362
|
+
function dropWhile(...args) {
|
|
363
|
+
return purry(_dropWhile, args);
|
|
364
|
+
}
|
|
365
|
+
function _dropWhile(data, predicate) {
|
|
366
|
+
for (let i = 0; i < data.length; i++) {
|
|
367
|
+
if (!predicate(data[i])) {
|
|
368
|
+
return data.slice(i);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
373
|
+
|
|
545
374
|
// src/utils/to-lazy-indexed.ts
|
|
546
375
|
function toLazyIndexed(fn) {
|
|
547
|
-
fn
|
|
548
|
-
return fn;
|
|
376
|
+
return Object.assign(fn, { indexed: true });
|
|
549
377
|
}
|
|
550
378
|
|
|
551
379
|
// src/array/filter.ts
|
|
552
380
|
function filter(...args) {
|
|
553
|
-
return purry(
|
|
381
|
+
return purry(filter_(false), args, filter.lazy);
|
|
554
382
|
}
|
|
555
|
-
function
|
|
383
|
+
function filter_(indexed) {
|
|
556
384
|
return (array, fn) => {
|
|
557
|
-
return
|
|
385
|
+
return reduceLazy(
|
|
558
386
|
array,
|
|
559
387
|
indexed ? filter.lazyIndexed(fn) : filter.lazy(fn),
|
|
560
388
|
indexed
|
|
561
389
|
);
|
|
562
390
|
};
|
|
563
391
|
}
|
|
564
|
-
function
|
|
392
|
+
function lazy_(indexed) {
|
|
565
393
|
return (fn) => {
|
|
566
394
|
return (value, index, array) => {
|
|
567
395
|
const valid = indexed ? fn(value, index, array) : fn(value);
|
|
@@ -581,11 +409,11 @@ function _lazy(indexed) {
|
|
|
581
409
|
}
|
|
582
410
|
((filter2) => {
|
|
583
411
|
function indexed(...args) {
|
|
584
|
-
return purry(
|
|
412
|
+
return purry(filter_(true), args, filter2.lazyIndexed);
|
|
585
413
|
}
|
|
586
414
|
filter2.indexed = indexed;
|
|
587
|
-
filter2.lazy =
|
|
588
|
-
filter2.lazyIndexed = toLazyIndexed(
|
|
415
|
+
filter2.lazy = lazy_(false);
|
|
416
|
+
filter2.lazyIndexed = toLazyIndexed(lazy_(true));
|
|
589
417
|
})(filter || (filter = {}));
|
|
590
418
|
|
|
591
419
|
// src/utils/to-single.ts
|
|
@@ -606,7 +434,7 @@ function _findIndex(indexed) {
|
|
|
606
434
|
return array.findIndex((x) => fn(x));
|
|
607
435
|
};
|
|
608
436
|
}
|
|
609
|
-
function
|
|
437
|
+
function _lazy(indexed) {
|
|
610
438
|
return (fn) => {
|
|
611
439
|
let i = 0;
|
|
612
440
|
return (value, index, array) => {
|
|
@@ -631,8 +459,8 @@ function _lazy2(indexed) {
|
|
|
631
459
|
return purry(_findIndex(true), args, findIndex2.lazyIndexed);
|
|
632
460
|
}
|
|
633
461
|
findIndex2.indexed = indexed;
|
|
634
|
-
findIndex2.lazy = toSingle(
|
|
635
|
-
findIndex2.lazyIndexed = toSingle(toLazyIndexed(
|
|
462
|
+
findIndex2.lazy = toSingle(_lazy(false));
|
|
463
|
+
findIndex2.lazyIndexed = toSingle(toLazyIndexed(_lazy(true)));
|
|
636
464
|
})(findIndex || (findIndex = {}));
|
|
637
465
|
|
|
638
466
|
// src/array/find-last-index.ts
|
|
@@ -667,6 +495,7 @@ function _findLast(indexed) {
|
|
|
667
495
|
return array[i];
|
|
668
496
|
}
|
|
669
497
|
}
|
|
498
|
+
return void 0;
|
|
670
499
|
};
|
|
671
500
|
}
|
|
672
501
|
((findLast2) => {
|
|
@@ -688,7 +517,7 @@ function _find(indexed) {
|
|
|
688
517
|
return array.find((x) => fn(x));
|
|
689
518
|
};
|
|
690
519
|
}
|
|
691
|
-
function
|
|
520
|
+
function _lazy2(indexed) {
|
|
692
521
|
return (fn) => {
|
|
693
522
|
return (value, index, array) => {
|
|
694
523
|
const valid = indexed ? fn(value, index, array) : fn(value);
|
|
@@ -705,8 +534,8 @@ function _lazy3(indexed) {
|
|
|
705
534
|
return purry(_find(true), args, find2.lazyIndexed);
|
|
706
535
|
}
|
|
707
536
|
find2.indexed = indexed;
|
|
708
|
-
find2.lazy = toSingle(
|
|
709
|
-
find2.lazyIndexed = toSingle(toLazyIndexed(
|
|
537
|
+
find2.lazy = toSingle(_lazy2(false));
|
|
538
|
+
find2.lazyIndexed = toSingle(toLazyIndexed(_lazy2(true)));
|
|
710
539
|
})(find || (find = {}));
|
|
711
540
|
|
|
712
541
|
// src/array/first.ts
|
|
@@ -732,6 +561,24 @@ function _first([first2]) {
|
|
|
732
561
|
})(lazy = first2.lazy || (first2.lazy = {}));
|
|
733
562
|
})(first || (first = {}));
|
|
734
563
|
|
|
564
|
+
// src/array/first-by.ts
|
|
565
|
+
function firstBy(...args) {
|
|
566
|
+
return purryOrderRules(firstByImplementation, args);
|
|
567
|
+
}
|
|
568
|
+
function firstByImplementation(data, compareFn) {
|
|
569
|
+
if (!hasAtLeast(data, 2)) {
|
|
570
|
+
return data[0];
|
|
571
|
+
}
|
|
572
|
+
let [currentFirst] = data;
|
|
573
|
+
const [, ...rest] = data;
|
|
574
|
+
for (const item of rest) {
|
|
575
|
+
if (compareFn(item, currentFirst) < 0) {
|
|
576
|
+
currentFirst = item;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return currentFirst;
|
|
580
|
+
}
|
|
581
|
+
|
|
735
582
|
// src/array/flat-map-to-obj.ts
|
|
736
583
|
function flatMapToObj(...args) {
|
|
737
584
|
return purry(_flatMapToObj(false), args);
|
|
@@ -759,7 +606,7 @@ function flatten(...args) {
|
|
|
759
606
|
return purry(_flatten, args, flatten.lazy);
|
|
760
607
|
}
|
|
761
608
|
function _flatten(items) {
|
|
762
|
-
return
|
|
609
|
+
return reduceLazy(items, flatten.lazy());
|
|
763
610
|
}
|
|
764
611
|
((flatten2) => {
|
|
765
612
|
function lazy() {
|
|
@@ -816,7 +663,7 @@ function flattenDeep(...args) {
|
|
|
816
663
|
return purry(_flattenDeep, args, flattenDeep.lazy);
|
|
817
664
|
}
|
|
818
665
|
function _flattenDeep(items) {
|
|
819
|
-
return
|
|
666
|
+
return reduceLazy(items, flattenDeep.lazy());
|
|
820
667
|
}
|
|
821
668
|
function _flattenDeepValue(value) {
|
|
822
669
|
if (!Array.isArray(value)) {
|
|
@@ -860,14 +707,14 @@ function forEach(...args) {
|
|
|
860
707
|
}
|
|
861
708
|
function _forEach(indexed) {
|
|
862
709
|
return (array, fn) => {
|
|
863
|
-
return
|
|
710
|
+
return reduceLazy(
|
|
864
711
|
array,
|
|
865
712
|
indexed ? forEach.lazyIndexed(fn) : forEach.lazy(fn),
|
|
866
713
|
indexed
|
|
867
714
|
);
|
|
868
715
|
};
|
|
869
716
|
}
|
|
870
|
-
function
|
|
717
|
+
function _lazy3(indexed) {
|
|
871
718
|
return (fn) => {
|
|
872
719
|
return (value, index, array) => {
|
|
873
720
|
if (indexed) {
|
|
@@ -888,8 +735,8 @@ function _lazy4(indexed) {
|
|
|
888
735
|
return purry(_forEach(true), args, forEach2.lazyIndexed);
|
|
889
736
|
}
|
|
890
737
|
forEach2.indexed = indexed;
|
|
891
|
-
forEach2.lazy =
|
|
892
|
-
forEach2.lazyIndexed = toLazyIndexed(
|
|
738
|
+
forEach2.lazy = _lazy3(false);
|
|
739
|
+
forEach2.lazyIndexed = toLazyIndexed(_lazy3(true));
|
|
893
740
|
})(forEach || (forEach = {}));
|
|
894
741
|
|
|
895
742
|
// src/array/group-by.ts
|
|
@@ -903,10 +750,12 @@ function _groupBy(indexed) {
|
|
|
903
750
|
const key = indexed ? fn(item, index, array) : fn(item);
|
|
904
751
|
if (key !== void 0) {
|
|
905
752
|
const actualKey = String(key);
|
|
906
|
-
|
|
907
|
-
|
|
753
|
+
let items = ret[actualKey];
|
|
754
|
+
if (items === void 0) {
|
|
755
|
+
items = [];
|
|
756
|
+
ret[actualKey] = items;
|
|
908
757
|
}
|
|
909
|
-
|
|
758
|
+
items.push(item);
|
|
910
759
|
}
|
|
911
760
|
});
|
|
912
761
|
return ret;
|
|
@@ -947,7 +796,7 @@ function intersection(...args) {
|
|
|
947
796
|
}
|
|
948
797
|
function _intersection(array, other) {
|
|
949
798
|
const lazy = intersection.lazy(other);
|
|
950
|
-
return
|
|
799
|
+
return reduceLazy(array, lazy);
|
|
951
800
|
}
|
|
952
801
|
((intersection2) => {
|
|
953
802
|
function lazy(other) {
|
|
@@ -975,7 +824,7 @@ function intersectionWith(...args) {
|
|
|
975
824
|
}
|
|
976
825
|
function _intersectionWith(array, other, comparator) {
|
|
977
826
|
const lazy = intersectionWith.lazy(other, comparator);
|
|
978
|
-
return
|
|
827
|
+
return reduceLazy(array, lazy);
|
|
979
828
|
}
|
|
980
829
|
((intersectionWith2) => {
|
|
981
830
|
function lazy(other, comparator) {
|
|
@@ -1026,14 +875,14 @@ function map(...args) {
|
|
|
1026
875
|
}
|
|
1027
876
|
function _map(indexed) {
|
|
1028
877
|
return (array, fn) => {
|
|
1029
|
-
return
|
|
878
|
+
return reduceLazy(
|
|
1030
879
|
array,
|
|
1031
880
|
indexed ? map.lazyIndexed(fn) : map.lazy(fn),
|
|
1032
881
|
indexed
|
|
1033
882
|
);
|
|
1034
883
|
};
|
|
1035
884
|
}
|
|
1036
|
-
function
|
|
885
|
+
function _lazy4(indexed) {
|
|
1037
886
|
return (fn) => {
|
|
1038
887
|
return (value, index, array) => {
|
|
1039
888
|
return {
|
|
@@ -1049,8 +898,8 @@ function _lazy5(indexed) {
|
|
|
1049
898
|
return purry(_map(true), args, map2.lazyIndexed);
|
|
1050
899
|
}
|
|
1051
900
|
map2.indexed = indexed;
|
|
1052
|
-
map2.lazy =
|
|
1053
|
-
map2.lazyIndexed = toLazyIndexed(
|
|
901
|
+
map2.lazy = _lazy4(false);
|
|
902
|
+
map2.lazyIndexed = toLazyIndexed(_lazy4(true));
|
|
1054
903
|
map2.strict = map2;
|
|
1055
904
|
})(map || (map = {}));
|
|
1056
905
|
|
|
@@ -1060,11 +909,14 @@ function mapToObj(...args) {
|
|
|
1060
909
|
}
|
|
1061
910
|
function _mapToObj(indexed) {
|
|
1062
911
|
return (array, fn) => {
|
|
1063
|
-
return array.reduce(
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
912
|
+
return array.reduce(
|
|
913
|
+
(result, element, index) => {
|
|
914
|
+
const [key, value] = indexed ? fn(element, index, array) : fn(element);
|
|
915
|
+
result[key] = value;
|
|
916
|
+
return result;
|
|
917
|
+
},
|
|
918
|
+
{}
|
|
919
|
+
);
|
|
1068
920
|
};
|
|
1069
921
|
}
|
|
1070
922
|
((mapToObj2) => {
|
|
@@ -1152,8 +1004,70 @@ function minBy(...args) {
|
|
|
1152
1004
|
minBy2.indexed = indexed;
|
|
1153
1005
|
})(minBy || (minBy = {}));
|
|
1154
1006
|
|
|
1007
|
+
// src/utils/quick-select.ts
|
|
1008
|
+
function quickSelect(data, index, compareFn) {
|
|
1009
|
+
return index < 0 || index >= data.length ? void 0 : quickSelectImplementation(
|
|
1010
|
+
// We need to clone the array because quickSelect mutates it in-place.
|
|
1011
|
+
[...data],
|
|
1012
|
+
0,
|
|
1013
|
+
data.length - 1,
|
|
1014
|
+
index,
|
|
1015
|
+
compareFn
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
1018
|
+
function quickSelectImplementation(data, left, right, index, compareFn) {
|
|
1019
|
+
if (left === right) {
|
|
1020
|
+
return data[left];
|
|
1021
|
+
}
|
|
1022
|
+
const pivotIndex = partition(data, left, right, compareFn);
|
|
1023
|
+
return index === pivotIndex ? data[index] : quickSelectImplementation(
|
|
1024
|
+
data,
|
|
1025
|
+
// We continue by recursing into the partition where index would be
|
|
1026
|
+
index < pivotIndex ? left : pivotIndex + 1,
|
|
1027
|
+
index < pivotIndex ? pivotIndex - 1 : right,
|
|
1028
|
+
index,
|
|
1029
|
+
compareFn
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
function partition(data, left, right, compareFn) {
|
|
1033
|
+
const pivot = data[right];
|
|
1034
|
+
let i = left;
|
|
1035
|
+
for (let j = left; j < right; j++) {
|
|
1036
|
+
if (compareFn(data[j], pivot) < 0) {
|
|
1037
|
+
swapInPlace(data, i, j);
|
|
1038
|
+
i++;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
swapInPlace(data, i, right);
|
|
1042
|
+
return i;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// src/array/nth-by.ts
|
|
1046
|
+
function nthBy(...args) {
|
|
1047
|
+
return purryOrderRulesWithArgument(nthByImplementation, args);
|
|
1048
|
+
}
|
|
1049
|
+
function nthByImplementation(data, compareFn, index) {
|
|
1050
|
+
return quickSelect(
|
|
1051
|
+
data,
|
|
1052
|
+
// Allow negative indices gracefully
|
|
1053
|
+
index >= 0 ? index : data.length + index,
|
|
1054
|
+
compareFn
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// src/array/only.ts
|
|
1059
|
+
function only(...args) {
|
|
1060
|
+
return purry(_only, args);
|
|
1061
|
+
}
|
|
1062
|
+
function _only(array) {
|
|
1063
|
+
if (array.length === 1) {
|
|
1064
|
+
return array[0];
|
|
1065
|
+
}
|
|
1066
|
+
return void 0;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1155
1069
|
// src/array/partition.ts
|
|
1156
|
-
function
|
|
1070
|
+
function partition2(...args) {
|
|
1157
1071
|
return purry(_partition(false), args);
|
|
1158
1072
|
}
|
|
1159
1073
|
function _partition(indexed) {
|
|
@@ -1166,12 +1080,12 @@ function _partition(indexed) {
|
|
|
1166
1080
|
return ret;
|
|
1167
1081
|
};
|
|
1168
1082
|
}
|
|
1169
|
-
((
|
|
1083
|
+
((partition3) => {
|
|
1170
1084
|
function indexed(...args) {
|
|
1171
1085
|
return purry(_partition(true), args);
|
|
1172
1086
|
}
|
|
1173
|
-
|
|
1174
|
-
})(
|
|
1087
|
+
partition3.indexed = indexed;
|
|
1088
|
+
})(partition2 || (partition2 = {}));
|
|
1175
1089
|
|
|
1176
1090
|
// src/array/range.ts
|
|
1177
1091
|
function range(...args) {
|
|
@@ -1185,6 +1099,20 @@ function _range(start, end) {
|
|
|
1185
1099
|
return ret;
|
|
1186
1100
|
}
|
|
1187
1101
|
|
|
1102
|
+
// src/array/rank-by.ts
|
|
1103
|
+
function rankBy(...args) {
|
|
1104
|
+
return purryOrderRulesWithArgument(rankByImplementation, args);
|
|
1105
|
+
}
|
|
1106
|
+
function rankByImplementation(data, compareFn, targetItem) {
|
|
1107
|
+
let rank = 0;
|
|
1108
|
+
for (const item of data) {
|
|
1109
|
+
if (compareFn(targetItem, item) > 0) {
|
|
1110
|
+
rank++;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
return rank;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1188
1116
|
// src/array/reduce.ts
|
|
1189
1117
|
function reduce(...args) {
|
|
1190
1118
|
return purry(_reduce(false), args);
|
|
@@ -1210,14 +1138,14 @@ function reject(...args) {
|
|
|
1210
1138
|
}
|
|
1211
1139
|
function _reject(indexed) {
|
|
1212
1140
|
return (array, fn) => {
|
|
1213
|
-
return
|
|
1141
|
+
return reduceLazy(
|
|
1214
1142
|
array,
|
|
1215
1143
|
indexed ? reject.lazyIndexed(fn) : reject.lazy(fn),
|
|
1216
1144
|
indexed
|
|
1217
1145
|
);
|
|
1218
1146
|
};
|
|
1219
1147
|
}
|
|
1220
|
-
function
|
|
1148
|
+
function _lazy5(indexed) {
|
|
1221
1149
|
return (fn) => {
|
|
1222
1150
|
return (value, index, array) => {
|
|
1223
1151
|
const valid = indexed ? fn(value, index, array) : fn(value);
|
|
@@ -1240,8 +1168,8 @@ function _lazy6(indexed) {
|
|
|
1240
1168
|
return purry(_reject(true), args, reject2.lazyIndexed);
|
|
1241
1169
|
}
|
|
1242
1170
|
reject2.indexed = indexed;
|
|
1243
|
-
reject2.lazy =
|
|
1244
|
-
reject2.lazyIndexed = toLazyIndexed(
|
|
1171
|
+
reject2.lazy = _lazy5(false);
|
|
1172
|
+
reject2.lazyIndexed = toLazyIndexed(_lazy5(true));
|
|
1245
1173
|
})(reject || (reject = {}));
|
|
1246
1174
|
|
|
1247
1175
|
// src/array/reverse.ts
|
|
@@ -1353,6 +1281,16 @@ function comparer(primaryRule, secondaryRule, ...otherRules) {
|
|
|
1353
1281
|
sortBy2.strict = sortBy2;
|
|
1354
1282
|
})(sortBy || (sortBy = {}));
|
|
1355
1283
|
|
|
1284
|
+
// src/array/splice.ts
|
|
1285
|
+
function splice(...args) {
|
|
1286
|
+
return purry(_splice, args);
|
|
1287
|
+
}
|
|
1288
|
+
function _splice(items, start, deleteCount, replacement) {
|
|
1289
|
+
const result = [...items];
|
|
1290
|
+
result.splice(start, deleteCount, ...replacement);
|
|
1291
|
+
return result;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1356
1294
|
// src/array/split-at.ts
|
|
1357
1295
|
function splitAt(...args) {
|
|
1358
1296
|
return purry(_splitAt, args);
|
|
@@ -1421,193 +1359,611 @@ function _swapArray(item, index1, index2) {
|
|
|
1421
1359
|
result[positiveIndexB] = item[positiveIndexA];
|
|
1422
1360
|
return result;
|
|
1423
1361
|
}
|
|
1424
|
-
function _swapString(item, index1, index2) {
|
|
1425
|
-
const result = _swapArray(item.split(""), index1, index2);
|
|
1426
|
-
return result.join("");
|
|
1362
|
+
function _swapString(item, index1, index2) {
|
|
1363
|
+
const result = _swapArray(item.split(""), index1, index2);
|
|
1364
|
+
return result.join("");
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
// src/array/take.ts
|
|
1368
|
+
function take(...args) {
|
|
1369
|
+
return purry(_take, args, take.lazy);
|
|
1370
|
+
}
|
|
1371
|
+
function _take(array, n) {
|
|
1372
|
+
return reduceLazy(array, take.lazy(n));
|
|
1373
|
+
}
|
|
1374
|
+
((take2) => {
|
|
1375
|
+
function lazy(n) {
|
|
1376
|
+
return (value) => {
|
|
1377
|
+
if (n === 0) {
|
|
1378
|
+
return {
|
|
1379
|
+
done: true,
|
|
1380
|
+
hasNext: false
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
n--;
|
|
1384
|
+
if (n === 0) {
|
|
1385
|
+
return {
|
|
1386
|
+
done: true,
|
|
1387
|
+
hasNext: true,
|
|
1388
|
+
next: value
|
|
1389
|
+
};
|
|
1390
|
+
}
|
|
1391
|
+
return {
|
|
1392
|
+
done: false,
|
|
1393
|
+
hasNext: true,
|
|
1394
|
+
next: value
|
|
1395
|
+
};
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
take2.lazy = lazy;
|
|
1399
|
+
})(take || (take = {}));
|
|
1400
|
+
|
|
1401
|
+
// src/array/take-first-by.ts
|
|
1402
|
+
function takeFirstBy(...args) {
|
|
1403
|
+
return purryOrderRulesWithArgument(takeFirstByImplementation, args);
|
|
1404
|
+
}
|
|
1405
|
+
function takeFirstByImplementation(data, compareFn, n) {
|
|
1406
|
+
if (n <= 0) {
|
|
1407
|
+
return [];
|
|
1408
|
+
}
|
|
1409
|
+
if (n >= data.length) {
|
|
1410
|
+
return [...data];
|
|
1411
|
+
}
|
|
1412
|
+
const heap = data.slice(0, n);
|
|
1413
|
+
heapify(heap, compareFn);
|
|
1414
|
+
const rest = data.slice(n);
|
|
1415
|
+
for (const item of rest) {
|
|
1416
|
+
heapMaybeInsert(heap, compareFn, item);
|
|
1417
|
+
}
|
|
1418
|
+
return heap;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
// src/array/take-while.ts
|
|
1422
|
+
function takeWhile(...args) {
|
|
1423
|
+
return purry(_takeWhile, args);
|
|
1424
|
+
}
|
|
1425
|
+
function _takeWhile(array, fn) {
|
|
1426
|
+
const ret = [];
|
|
1427
|
+
for (const item of array) {
|
|
1428
|
+
if (!fn(item)) {
|
|
1429
|
+
break;
|
|
1430
|
+
}
|
|
1431
|
+
ret.push(item);
|
|
1432
|
+
}
|
|
1433
|
+
return ret;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
// src/array/uniq.ts
|
|
1437
|
+
function uniq(...args) {
|
|
1438
|
+
return purry(_uniq, args, uniq.lazy);
|
|
1439
|
+
}
|
|
1440
|
+
function _uniq(array) {
|
|
1441
|
+
return reduceLazy(array, uniq.lazy());
|
|
1442
|
+
}
|
|
1443
|
+
((uniq2) => {
|
|
1444
|
+
function lazy() {
|
|
1445
|
+
const set2 = /* @__PURE__ */ new Set();
|
|
1446
|
+
return (value) => {
|
|
1447
|
+
if (set2.has(value)) {
|
|
1448
|
+
return {
|
|
1449
|
+
done: false,
|
|
1450
|
+
hasNext: false
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
set2.add(value);
|
|
1454
|
+
return {
|
|
1455
|
+
done: false,
|
|
1456
|
+
hasNext: true,
|
|
1457
|
+
next: value
|
|
1458
|
+
};
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
uniq2.lazy = lazy;
|
|
1462
|
+
})(uniq || (uniq = {}));
|
|
1463
|
+
|
|
1464
|
+
// src/array/uniq-by.ts
|
|
1465
|
+
function uniqBy(...args) {
|
|
1466
|
+
return purry(_uniqBy, args, lazyUniqBy);
|
|
1467
|
+
}
|
|
1468
|
+
function _uniqBy(array, transformer) {
|
|
1469
|
+
return reduceLazy(array, lazyUniqBy(transformer));
|
|
1470
|
+
}
|
|
1471
|
+
function lazyUniqBy(transformer) {
|
|
1472
|
+
const set2 = /* @__PURE__ */ new Set();
|
|
1473
|
+
return (value) => {
|
|
1474
|
+
const appliedItem = transformer(value);
|
|
1475
|
+
if (set2.has(appliedItem)) {
|
|
1476
|
+
return {
|
|
1477
|
+
done: false,
|
|
1478
|
+
hasNext: false
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
set2.add(appliedItem);
|
|
1482
|
+
return {
|
|
1483
|
+
done: false,
|
|
1484
|
+
hasNext: true,
|
|
1485
|
+
next: value
|
|
1486
|
+
};
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// src/array/uniq-with.ts
|
|
1491
|
+
function uniqWith(...args) {
|
|
1492
|
+
return purry(_uniqWith, args, uniqWith.lazy);
|
|
1493
|
+
}
|
|
1494
|
+
function _uniqWith(array, isEquals) {
|
|
1495
|
+
const lazy = uniqWith.lazy(isEquals);
|
|
1496
|
+
return reduceLazy(array, lazy, true);
|
|
1497
|
+
}
|
|
1498
|
+
function _lazy6(isEquals) {
|
|
1499
|
+
return (value, index, array) => {
|
|
1500
|
+
if (array && array.findIndex((otherValue) => isEquals(value, otherValue)) === index) {
|
|
1501
|
+
return {
|
|
1502
|
+
done: false,
|
|
1503
|
+
hasNext: true,
|
|
1504
|
+
next: value
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
return {
|
|
1508
|
+
done: false,
|
|
1509
|
+
hasNext: false
|
|
1510
|
+
};
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
((uniqWith2) => {
|
|
1514
|
+
uniqWith2.lazy = toLazyIndexed(_lazy6);
|
|
1515
|
+
})(uniqWith || (uniqWith = {}));
|
|
1516
|
+
|
|
1517
|
+
// src/array/zip.ts
|
|
1518
|
+
function zip(...args) {
|
|
1519
|
+
return purry(_zip, args);
|
|
1520
|
+
}
|
|
1521
|
+
function _zip(first2, second) {
|
|
1522
|
+
const resultLength = first2.length > second.length ? second.length : first2.length;
|
|
1523
|
+
const result = [];
|
|
1524
|
+
for (let i = 0; i < resultLength; i++) {
|
|
1525
|
+
result.push([first2[i], second[i]]);
|
|
1526
|
+
}
|
|
1527
|
+
return result;
|
|
1528
|
+
}
|
|
1529
|
+
((zip2) => {
|
|
1530
|
+
zip2.strict = zip2;
|
|
1531
|
+
})(zip || (zip = {}));
|
|
1532
|
+
|
|
1533
|
+
// src/array/zip-obj.ts
|
|
1534
|
+
function zipObj(...args) {
|
|
1535
|
+
return purry(_zipObj, args);
|
|
1536
|
+
}
|
|
1537
|
+
function _zipObj(first2, second) {
|
|
1538
|
+
const resultLength = first2.length > second.length ? second.length : first2.length;
|
|
1539
|
+
const result = {};
|
|
1540
|
+
for (let i = 0; i < resultLength; i++) {
|
|
1541
|
+
result[first2[i]] = second[i];
|
|
1542
|
+
}
|
|
1543
|
+
return result;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
// src/array/zip-with.ts
|
|
1547
|
+
function zipWith(arg0, arg1, arg2) {
|
|
1548
|
+
if (typeof arg0 === "function") {
|
|
1549
|
+
return arg1 === void 0 ? (f, s) => _zipWith(f, s, arg0) : (f) => _zipWith(f, arg1, arg0);
|
|
1550
|
+
}
|
|
1551
|
+
if (arg1 === void 0 || arg2 === void 0) {
|
|
1552
|
+
throw new Error("zipWith: Missing arguments in dataFirst function call");
|
|
1553
|
+
}
|
|
1554
|
+
return _zipWith(arg0, arg1, arg2);
|
|
1555
|
+
}
|
|
1556
|
+
function _zipWith(first2, second, fn) {
|
|
1557
|
+
const resultLength = first2.length > second.length ? second.length : first2.length;
|
|
1558
|
+
const result = [];
|
|
1559
|
+
for (let i = 0; i < resultLength; i++) {
|
|
1560
|
+
result.push(fn(first2[i], second[i]));
|
|
1561
|
+
}
|
|
1562
|
+
return result;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
// src/utils/purry-on.ts
|
|
1566
|
+
function purryOn(isArg, implementation, args) {
|
|
1567
|
+
const callArgs = Array.from(args);
|
|
1568
|
+
return isArg(args[0]) ? (data) => implementation(data, ...callArgs) : implementation(...callArgs);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
// src/function/conditional.ts
|
|
1572
|
+
function conditional(...args) {
|
|
1573
|
+
return purryOn(isCase, conditionalImplementation, args);
|
|
1574
|
+
}
|
|
1575
|
+
function conditionalImplementation(data, ...cases) {
|
|
1576
|
+
for (const [when, then] of cases) {
|
|
1577
|
+
if (when(data)) {
|
|
1578
|
+
return then(data);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
throw new Error("conditional: data failed for all cases");
|
|
1582
|
+
}
|
|
1583
|
+
function isCase(maybeCase) {
|
|
1584
|
+
if (!Array.isArray(maybeCase)) {
|
|
1585
|
+
return false;
|
|
1586
|
+
}
|
|
1587
|
+
const [when, then, ...rest] = maybeCase;
|
|
1588
|
+
return typeof when === "function" && when.length <= 1 && typeof then === "function" && then.length <= 1 && rest.length === 0;
|
|
1589
|
+
}
|
|
1590
|
+
var trivialDefaultCase = () => void 0;
|
|
1591
|
+
((conditional2) => {
|
|
1592
|
+
function defaultCase(then = trivialDefaultCase) {
|
|
1593
|
+
return [() => true, then];
|
|
1594
|
+
}
|
|
1595
|
+
conditional2.defaultCase = defaultCase;
|
|
1596
|
+
})(conditional || (conditional = {}));
|
|
1597
|
+
|
|
1598
|
+
// src/function/pipe.ts
|
|
1599
|
+
function pipe(input, ...operations) {
|
|
1600
|
+
let output = input;
|
|
1601
|
+
const lazyOperations = operations.map(
|
|
1602
|
+
(op) => "lazy" in op ? toPipedLazy(op) : void 0
|
|
1603
|
+
);
|
|
1604
|
+
let operationIndex = 0;
|
|
1605
|
+
while (operationIndex < operations.length) {
|
|
1606
|
+
const lazyOperation = lazyOperations[operationIndex];
|
|
1607
|
+
if (lazyOperation === void 0 || !isIterable(output)) {
|
|
1608
|
+
const operation = operations[operationIndex];
|
|
1609
|
+
output = operation(output);
|
|
1610
|
+
operationIndex++;
|
|
1611
|
+
continue;
|
|
1612
|
+
}
|
|
1613
|
+
const lazySequence = [];
|
|
1614
|
+
for (let j = operationIndex; j < operations.length; j++) {
|
|
1615
|
+
const lazyOp = lazyOperations[j];
|
|
1616
|
+
if (lazyOp === void 0) {
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
1619
|
+
lazySequence.push(lazyOp);
|
|
1620
|
+
if (lazyOp.isSingle) {
|
|
1621
|
+
break;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
const accumulator = [];
|
|
1625
|
+
const iterator = output[Symbol.iterator]();
|
|
1626
|
+
while (true) {
|
|
1627
|
+
const result = iterator.next();
|
|
1628
|
+
if (result.done ?? false) {
|
|
1629
|
+
break;
|
|
1630
|
+
}
|
|
1631
|
+
const shouldExitEarly = processItem_(
|
|
1632
|
+
result.value,
|
|
1633
|
+
accumulator,
|
|
1634
|
+
lazySequence
|
|
1635
|
+
);
|
|
1636
|
+
if (shouldExitEarly) {
|
|
1637
|
+
break;
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
const { isSingle } = lazySequence[lazySequence.length - 1];
|
|
1641
|
+
if (isSingle) {
|
|
1642
|
+
output = accumulator[0];
|
|
1643
|
+
} else {
|
|
1644
|
+
output = accumulator;
|
|
1645
|
+
}
|
|
1646
|
+
operationIndex += lazySequence.length;
|
|
1647
|
+
}
|
|
1648
|
+
return output;
|
|
1649
|
+
}
|
|
1650
|
+
function processItem_(item, accumulator, lazySequence) {
|
|
1651
|
+
if (lazySequence.length === 0) {
|
|
1652
|
+
accumulator.push(item);
|
|
1653
|
+
return false;
|
|
1654
|
+
}
|
|
1655
|
+
let lazyResult = { done: false, hasNext: false };
|
|
1656
|
+
let isDone = false;
|
|
1657
|
+
for (let i = 0; i < lazySequence.length; i++) {
|
|
1658
|
+
const lazyFn = lazySequence[i];
|
|
1659
|
+
const { index, isIndexed, items } = lazyFn;
|
|
1660
|
+
items.push(item);
|
|
1661
|
+
lazyResult = isIndexed ? lazyFn(item, index, items) : lazyFn(item);
|
|
1662
|
+
lazyFn.index++;
|
|
1663
|
+
if (lazyResult.hasNext) {
|
|
1664
|
+
if (lazyResult.hasMany) {
|
|
1665
|
+
const nextValues = lazyResult.next;
|
|
1666
|
+
for (const subItem of nextValues) {
|
|
1667
|
+
const subResult = processItem_(
|
|
1668
|
+
subItem,
|
|
1669
|
+
accumulator,
|
|
1670
|
+
lazySequence.slice(i + 1)
|
|
1671
|
+
);
|
|
1672
|
+
if (subResult) {
|
|
1673
|
+
return true;
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
return false;
|
|
1677
|
+
} else {
|
|
1678
|
+
item = lazyResult.next;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
if (!lazyResult.hasNext) {
|
|
1682
|
+
break;
|
|
1683
|
+
}
|
|
1684
|
+
if (lazyResult.done) {
|
|
1685
|
+
isDone = true;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
if (lazyResult.hasNext) {
|
|
1689
|
+
accumulator.push(item);
|
|
1690
|
+
}
|
|
1691
|
+
return isDone;
|
|
1692
|
+
}
|
|
1693
|
+
function toPipedLazy(op) {
|
|
1694
|
+
const { lazy, lazyArgs } = op;
|
|
1695
|
+
const fn = lazy(...lazyArgs ?? []);
|
|
1696
|
+
return Object.assign(fn, {
|
|
1697
|
+
index: 0,
|
|
1698
|
+
isIndexed: lazy.indexed,
|
|
1699
|
+
isSingle: lazy.single,
|
|
1700
|
+
items: []
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
function isIterable(something) {
|
|
1704
|
+
return typeof something === "string" || typeof something === "object" && something !== null && Symbol.iterator in something;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
// src/function/create-pipe.ts
|
|
1708
|
+
function createPipe(...operations) {
|
|
1709
|
+
return (value) => pipe(value, ...operations);
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
// src/function/identity.ts
|
|
1713
|
+
function identity(value) {
|
|
1714
|
+
return value;
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
// src/function/noop.ts
|
|
1718
|
+
function noop() {
|
|
1719
|
+
return void 0;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
// src/function/once.ts
|
|
1723
|
+
function once(fn) {
|
|
1724
|
+
let called = false;
|
|
1725
|
+
let ret;
|
|
1726
|
+
return () => {
|
|
1727
|
+
if (!called) {
|
|
1728
|
+
ret = fn();
|
|
1729
|
+
called = true;
|
|
1730
|
+
}
|
|
1731
|
+
return ret;
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
// src/function/debounce.ts
|
|
1736
|
+
function debounce(func, {
|
|
1737
|
+
maxWaitMs,
|
|
1738
|
+
timing = "trailing",
|
|
1739
|
+
waitMs
|
|
1740
|
+
}) {
|
|
1741
|
+
if (maxWaitMs !== void 0 && waitMs !== void 0 && maxWaitMs < waitMs) {
|
|
1742
|
+
throw new Error(
|
|
1743
|
+
`debounce: maxWaitMs (${maxWaitMs}) cannot be less than waitMs (${waitMs})`
|
|
1744
|
+
);
|
|
1745
|
+
}
|
|
1746
|
+
let coolDownTimeoutId;
|
|
1747
|
+
let maxWaitTimeoutId;
|
|
1748
|
+
let latestCallArgs;
|
|
1749
|
+
let result;
|
|
1750
|
+
function handleDebouncedCall(args) {
|
|
1751
|
+
latestCallArgs = args;
|
|
1752
|
+
if (maxWaitMs !== void 0 && maxWaitTimeoutId === void 0) {
|
|
1753
|
+
maxWaitTimeoutId = setTimeout(handleInvoke, maxWaitMs);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
function handleInvoke() {
|
|
1757
|
+
if (latestCallArgs === void 0) {
|
|
1758
|
+
return;
|
|
1759
|
+
}
|
|
1760
|
+
if (maxWaitTimeoutId !== void 0) {
|
|
1761
|
+
const timeoutId = maxWaitTimeoutId;
|
|
1762
|
+
maxWaitTimeoutId = void 0;
|
|
1763
|
+
clearTimeout(timeoutId);
|
|
1764
|
+
}
|
|
1765
|
+
const args = latestCallArgs;
|
|
1766
|
+
latestCallArgs = void 0;
|
|
1767
|
+
result = func(...args);
|
|
1768
|
+
}
|
|
1769
|
+
function handleCoolDownEnd() {
|
|
1770
|
+
if (coolDownTimeoutId === void 0) {
|
|
1771
|
+
return;
|
|
1772
|
+
}
|
|
1773
|
+
const timeoutId = coolDownTimeoutId;
|
|
1774
|
+
coolDownTimeoutId = void 0;
|
|
1775
|
+
clearTimeout(timeoutId);
|
|
1776
|
+
if (latestCallArgs !== void 0) {
|
|
1777
|
+
handleInvoke();
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
return {
|
|
1781
|
+
get cachedValue() {
|
|
1782
|
+
return result;
|
|
1783
|
+
},
|
|
1784
|
+
call: (...args) => {
|
|
1785
|
+
if (coolDownTimeoutId === void 0) {
|
|
1786
|
+
if (timing === "trailing") {
|
|
1787
|
+
handleDebouncedCall(args);
|
|
1788
|
+
} else {
|
|
1789
|
+
result = func(...args);
|
|
1790
|
+
}
|
|
1791
|
+
} else {
|
|
1792
|
+
if (timing !== "leading") {
|
|
1793
|
+
handleDebouncedCall(args);
|
|
1794
|
+
}
|
|
1795
|
+
const timeoutId = coolDownTimeoutId;
|
|
1796
|
+
coolDownTimeoutId = void 0;
|
|
1797
|
+
clearTimeout(timeoutId);
|
|
1798
|
+
}
|
|
1799
|
+
coolDownTimeoutId = setTimeout(
|
|
1800
|
+
handleCoolDownEnd,
|
|
1801
|
+
// If waitMs is not defined but maxWaitMs *is* it means the user is only
|
|
1802
|
+
// interested in the leaky-bucket nature of the debouncer which is
|
|
1803
|
+
// achieved by setting waitMs === maxWaitMs. If both are not defined we
|
|
1804
|
+
// default to 0 which would wait until the end of the execution frame.
|
|
1805
|
+
waitMs ?? maxWaitMs ?? 0
|
|
1806
|
+
);
|
|
1807
|
+
return result;
|
|
1808
|
+
},
|
|
1809
|
+
cancel: () => {
|
|
1810
|
+
if (coolDownTimeoutId !== void 0) {
|
|
1811
|
+
const timeoutId = coolDownTimeoutId;
|
|
1812
|
+
coolDownTimeoutId = void 0;
|
|
1813
|
+
clearTimeout(timeoutId);
|
|
1814
|
+
}
|
|
1815
|
+
if (maxWaitTimeoutId !== void 0) {
|
|
1816
|
+
const timeoutId = maxWaitTimeoutId;
|
|
1817
|
+
maxWaitTimeoutId = void 0;
|
|
1818
|
+
clearTimeout(timeoutId);
|
|
1819
|
+
}
|
|
1820
|
+
latestCallArgs = void 0;
|
|
1821
|
+
},
|
|
1822
|
+
flush: () => {
|
|
1823
|
+
handleCoolDownEnd();
|
|
1824
|
+
return result;
|
|
1825
|
+
},
|
|
1826
|
+
get isPending() {
|
|
1827
|
+
return coolDownTimeoutId !== void 0;
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// src/function/sleep.ts
|
|
1833
|
+
function sleep(timeout) {
|
|
1834
|
+
return new Promise((resolve) => {
|
|
1835
|
+
setTimeout(resolve, timeout);
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
// src/guard/is-array.ts
|
|
1840
|
+
function isArray(data) {
|
|
1841
|
+
return Array.isArray(data);
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
// src/guard/is-boolean.ts
|
|
1845
|
+
function isBoolean(data) {
|
|
1846
|
+
return typeof data === "boolean";
|
|
1427
1847
|
}
|
|
1428
1848
|
|
|
1429
|
-
// src/
|
|
1430
|
-
function
|
|
1431
|
-
return
|
|
1849
|
+
// src/guard/is-date.ts
|
|
1850
|
+
function isDate(data) {
|
|
1851
|
+
return data instanceof Date;
|
|
1432
1852
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1853
|
+
|
|
1854
|
+
// src/guard/is-defined.ts
|
|
1855
|
+
function isDefined(data) {
|
|
1856
|
+
return typeof data !== "undefined" && data !== null;
|
|
1435
1857
|
}
|
|
1436
|
-
((
|
|
1437
|
-
function
|
|
1438
|
-
return
|
|
1439
|
-
if (n === 0) {
|
|
1440
|
-
return {
|
|
1441
|
-
done: true,
|
|
1442
|
-
hasNext: false
|
|
1443
|
-
};
|
|
1444
|
-
}
|
|
1445
|
-
n--;
|
|
1446
|
-
if (n === 0) {
|
|
1447
|
-
return {
|
|
1448
|
-
done: true,
|
|
1449
|
-
hasNext: true,
|
|
1450
|
-
next: value
|
|
1451
|
-
};
|
|
1452
|
-
}
|
|
1453
|
-
return {
|
|
1454
|
-
done: false,
|
|
1455
|
-
hasNext: true,
|
|
1456
|
-
next: value
|
|
1457
|
-
};
|
|
1458
|
-
};
|
|
1858
|
+
((isDefined2) => {
|
|
1859
|
+
function strict(data) {
|
|
1860
|
+
return data !== void 0;
|
|
1459
1861
|
}
|
|
1460
|
-
|
|
1461
|
-
})(
|
|
1862
|
+
isDefined2.strict = strict;
|
|
1863
|
+
})(isDefined || (isDefined = {}));
|
|
1462
1864
|
|
|
1463
|
-
// src/
|
|
1464
|
-
function
|
|
1465
|
-
|
|
1865
|
+
// src/guard/is-object.ts
|
|
1866
|
+
function isObject(data) {
|
|
1867
|
+
if (typeof data !== "object" || data === null) {
|
|
1868
|
+
return false;
|
|
1869
|
+
}
|
|
1870
|
+
const proto = Object.getPrototypeOf(data);
|
|
1871
|
+
return proto === null || proto === Object.prototype;
|
|
1466
1872
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1873
|
+
|
|
1874
|
+
// src/guard/is-string.ts
|
|
1875
|
+
function isString(data) {
|
|
1876
|
+
return typeof data === "string";
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
// src/guard/is-empty.ts
|
|
1880
|
+
function isEmpty(data) {
|
|
1881
|
+
if (isArray(data) || isString(data)) {
|
|
1882
|
+
return data.length === 0;
|
|
1883
|
+
}
|
|
1884
|
+
if (isObject(data)) {
|
|
1885
|
+
for (const _ in data) {
|
|
1886
|
+
return false;
|
|
1472
1887
|
}
|
|
1473
|
-
|
|
1888
|
+
return !(data instanceof RegExp);
|
|
1474
1889
|
}
|
|
1475
|
-
return
|
|
1890
|
+
return false;
|
|
1476
1891
|
}
|
|
1477
1892
|
|
|
1478
|
-
// src/
|
|
1479
|
-
function
|
|
1480
|
-
return
|
|
1893
|
+
// src/guard/is-error.ts
|
|
1894
|
+
function isError(data) {
|
|
1895
|
+
return data instanceof Error;
|
|
1481
1896
|
}
|
|
1482
|
-
|
|
1483
|
-
|
|
1897
|
+
|
|
1898
|
+
// src/guard/is-function.ts
|
|
1899
|
+
function isFunction(data) {
|
|
1900
|
+
return typeof data === "function";
|
|
1484
1901
|
}
|
|
1485
|
-
((uniq2) => {
|
|
1486
|
-
function lazy() {
|
|
1487
|
-
const set2 = /* @__PURE__ */ new Set();
|
|
1488
|
-
return (value) => {
|
|
1489
|
-
if (set2.has(value)) {
|
|
1490
|
-
return {
|
|
1491
|
-
done: false,
|
|
1492
|
-
hasNext: false
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
set2.add(value);
|
|
1496
|
-
return {
|
|
1497
|
-
done: false,
|
|
1498
|
-
hasNext: true,
|
|
1499
|
-
next: value
|
|
1500
|
-
};
|
|
1501
|
-
};
|
|
1502
|
-
}
|
|
1503
|
-
uniq2.lazy = lazy;
|
|
1504
|
-
})(uniq || (uniq = {}));
|
|
1505
1902
|
|
|
1506
|
-
// src/
|
|
1507
|
-
function
|
|
1508
|
-
return
|
|
1903
|
+
// src/guard/is-nil.ts
|
|
1904
|
+
function isNil(data) {
|
|
1905
|
+
return data == null;
|
|
1509
1906
|
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1907
|
+
|
|
1908
|
+
// src/guard/is-non-null.ts
|
|
1909
|
+
function isNonNull(data) {
|
|
1910
|
+
return data !== null;
|
|
1512
1911
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
return {
|
|
1519
|
-
done: false,
|
|
1520
|
-
hasNext: false
|
|
1521
|
-
};
|
|
1522
|
-
}
|
|
1523
|
-
set2.add(appliedItem);
|
|
1524
|
-
return {
|
|
1525
|
-
done: false,
|
|
1526
|
-
hasNext: true,
|
|
1527
|
-
next: value
|
|
1528
|
-
};
|
|
1912
|
+
|
|
1913
|
+
// src/guard/is-not.ts
|
|
1914
|
+
function isNot(predicate) {
|
|
1915
|
+
return (data) => {
|
|
1916
|
+
return !predicate(data);
|
|
1529
1917
|
};
|
|
1530
1918
|
}
|
|
1531
1919
|
|
|
1532
|
-
// src/
|
|
1533
|
-
function
|
|
1534
|
-
return
|
|
1535
|
-
}
|
|
1536
|
-
function _uniqWith(array, isEquals) {
|
|
1537
|
-
const lazy = uniqWith.lazy(isEquals);
|
|
1538
|
-
return _reduceLazy(array, lazy, true);
|
|
1539
|
-
}
|
|
1540
|
-
function _lazy7(isEquals) {
|
|
1541
|
-
return (value, index, array) => {
|
|
1542
|
-
if (array && array.findIndex((otherValue) => isEquals(value, otherValue)) === index) {
|
|
1543
|
-
return {
|
|
1544
|
-
done: false,
|
|
1545
|
-
hasNext: true,
|
|
1546
|
-
next: value
|
|
1547
|
-
};
|
|
1548
|
-
}
|
|
1549
|
-
return {
|
|
1550
|
-
done: false,
|
|
1551
|
-
hasNext: false
|
|
1552
|
-
};
|
|
1553
|
-
};
|
|
1920
|
+
// src/guard/is-number.ts
|
|
1921
|
+
function isNumber(data) {
|
|
1922
|
+
return typeof data === "number" && !Number.isNaN(data);
|
|
1554
1923
|
}
|
|
1555
|
-
((uniqWith2) => {
|
|
1556
|
-
uniqWith2.lazy = toLazyIndexed(_lazy7);
|
|
1557
|
-
})(uniqWith || (uniqWith = {}));
|
|
1558
1924
|
|
|
1559
|
-
// src/
|
|
1560
|
-
function
|
|
1561
|
-
return
|
|
1925
|
+
// src/guard/is-promise.ts
|
|
1926
|
+
function isPromise(data) {
|
|
1927
|
+
return data instanceof Promise;
|
|
1562
1928
|
}
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
result.push([first2[i], second[i]]);
|
|
1568
|
-
}
|
|
1569
|
-
return result;
|
|
1929
|
+
|
|
1930
|
+
// src/guard/is-symbol.ts
|
|
1931
|
+
function isSymbol(data) {
|
|
1932
|
+
return typeof data === "symbol";
|
|
1570
1933
|
}
|
|
1571
|
-
((zip2) => {
|
|
1572
|
-
zip2.strict = zip2;
|
|
1573
|
-
})(zip || (zip = {}));
|
|
1574
1934
|
|
|
1575
|
-
// src/
|
|
1576
|
-
function
|
|
1577
|
-
return purry(
|
|
1935
|
+
// src/number/add.ts
|
|
1936
|
+
function add(...args) {
|
|
1937
|
+
return purry(_add, args);
|
|
1578
1938
|
}
|
|
1579
|
-
function
|
|
1580
|
-
|
|
1581
|
-
const result = {};
|
|
1582
|
-
for (let i = 0; i < resultLength; i++) {
|
|
1583
|
-
result[first2[i]] = second[i];
|
|
1584
|
-
}
|
|
1585
|
-
return result;
|
|
1939
|
+
function _add(value, addend) {
|
|
1940
|
+
return value + addend;
|
|
1586
1941
|
}
|
|
1587
1942
|
|
|
1588
|
-
// src/
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1943
|
+
// src/utils/with-precision.ts
|
|
1944
|
+
var MAX_PRECISION = 15;
|
|
1945
|
+
function withPrecision(roundingFn) {
|
|
1946
|
+
return (value, precision) => {
|
|
1947
|
+
if (precision === 0) {
|
|
1948
|
+
return roundingFn(value);
|
|
1949
|
+
}
|
|
1950
|
+
if (!Number.isInteger(precision)) {
|
|
1951
|
+
throw new TypeError(`precision must be an integer: ${precision}`);
|
|
1952
|
+
}
|
|
1953
|
+
if (precision > MAX_PRECISION || precision < -MAX_PRECISION) {
|
|
1954
|
+
throw new RangeError(`precision must be between ${-MAX_PRECISION} and ${MAX_PRECISION}`);
|
|
1955
|
+
}
|
|
1956
|
+
if (Number.isNaN(value) || !Number.isFinite(value)) {
|
|
1957
|
+
return roundingFn(value);
|
|
1958
|
+
}
|
|
1959
|
+
const multiplier = 10 ** precision;
|
|
1960
|
+
return roundingFn(value * multiplier) / multiplier;
|
|
1961
|
+
};
|
|
1603
1962
|
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
result.push(fn(first2[i], second[i]));
|
|
1609
|
-
}
|
|
1610
|
-
return result;
|
|
1963
|
+
|
|
1964
|
+
// src/number/ceil.ts
|
|
1965
|
+
function ceil(...args) {
|
|
1966
|
+
return purry(withPrecision(Math.ceil), args);
|
|
1611
1967
|
}
|
|
1612
1968
|
|
|
1613
1969
|
// src/number/clamp.ts
|
|
@@ -1624,6 +1980,40 @@ function _clamp(value, limits) {
|
|
|
1624
1980
|
return value;
|
|
1625
1981
|
}
|
|
1626
1982
|
|
|
1983
|
+
// src/number/divide.ts
|
|
1984
|
+
function divide(...args) {
|
|
1985
|
+
return purry(_divide, args);
|
|
1986
|
+
}
|
|
1987
|
+
function _divide(value, divisor) {
|
|
1988
|
+
return value / divisor;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
// src/number/floor.ts
|
|
1992
|
+
function floor(...args) {
|
|
1993
|
+
return purry(withPrecision(Math.floor), args);
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
// src/number/multiply.ts
|
|
1997
|
+
function multiply(...args) {
|
|
1998
|
+
return purry(_multiply, args);
|
|
1999
|
+
}
|
|
2000
|
+
function _multiply(value, multiplicand) {
|
|
2001
|
+
return value * multiplicand;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
// src/number/round.ts
|
|
2005
|
+
function round(...args) {
|
|
2006
|
+
return purry(withPrecision(Math.round), args);
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
// src/number/subtract.ts
|
|
2010
|
+
function subtract(...args) {
|
|
2011
|
+
return purry(_subtract, args);
|
|
2012
|
+
}
|
|
2013
|
+
function _subtract(value, subtrahend) {
|
|
2014
|
+
return value - subtrahend;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
1627
2017
|
// src/object/add-prop.ts
|
|
1628
2018
|
function addProp(...args) {
|
|
1629
2019
|
return purry(_addProp, args);
|
|
@@ -1813,32 +2203,36 @@ function keys(source) {
|
|
|
1813
2203
|
keys2.strict = keys2;
|
|
1814
2204
|
})(keys || (keys = {}));
|
|
1815
2205
|
|
|
2206
|
+
// src/object/to-pairs.ts
|
|
2207
|
+
function toPairs(...args) {
|
|
2208
|
+
return purry(Object.entries, args);
|
|
2209
|
+
}
|
|
2210
|
+
((toPairs2) => {
|
|
2211
|
+
toPairs2.strict = toPairs2;
|
|
2212
|
+
})(toPairs || (toPairs = {}));
|
|
2213
|
+
|
|
1816
2214
|
// src/object/map-keys.ts
|
|
1817
|
-
function mapKeys(
|
|
1818
|
-
|
|
1819
|
-
return (data) => _mapKeys(data, arg1);
|
|
1820
|
-
}
|
|
1821
|
-
return _mapKeys(arg1, arg2);
|
|
2215
|
+
function mapKeys(...args) {
|
|
2216
|
+
return purry(_mapKeys, args);
|
|
1822
2217
|
}
|
|
1823
|
-
function _mapKeys(
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
}
|
|
2218
|
+
function _mapKeys(data, fn) {
|
|
2219
|
+
const out = {};
|
|
2220
|
+
for (const [key, value] of toPairs.strict(data)) {
|
|
2221
|
+
out[fn(key, value)] = value;
|
|
2222
|
+
}
|
|
2223
|
+
return out;
|
|
1828
2224
|
}
|
|
1829
2225
|
|
|
1830
2226
|
// src/object/map-values.ts
|
|
1831
|
-
function mapValues(
|
|
1832
|
-
|
|
1833
|
-
return (data) => _mapValues(data, arg1);
|
|
1834
|
-
}
|
|
1835
|
-
return _mapValues(arg1, arg2);
|
|
2227
|
+
function mapValues(...args) {
|
|
2228
|
+
return purry(_mapValues, args);
|
|
1836
2229
|
}
|
|
1837
|
-
function _mapValues(
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
}
|
|
2230
|
+
function _mapValues(data, fn) {
|
|
2231
|
+
const out = {};
|
|
2232
|
+
for (const [key, value] of toPairs.strict(data)) {
|
|
2233
|
+
out[key] = fn(value, key);
|
|
2234
|
+
}
|
|
2235
|
+
return out;
|
|
1842
2236
|
}
|
|
1843
2237
|
|
|
1844
2238
|
// src/object/merge.ts
|
|
@@ -1880,10 +2274,10 @@ function omit(...args) {
|
|
|
1880
2274
|
return purry(_omit, args);
|
|
1881
2275
|
}
|
|
1882
2276
|
function _omit(data, propNames) {
|
|
1883
|
-
if (propNames
|
|
2277
|
+
if (!hasAtLeast(propNames, 1)) {
|
|
1884
2278
|
return { ...data };
|
|
1885
2279
|
}
|
|
1886
|
-
if (propNames
|
|
2280
|
+
if (!hasAtLeast(propNames, 2)) {
|
|
1887
2281
|
const [propName] = propNames;
|
|
1888
2282
|
const {
|
|
1889
2283
|
[propName]: omitted,
|
|
@@ -1905,7 +2299,10 @@ function omitBy(...args) {
|
|
|
1905
2299
|
return purry(_omitBy, args);
|
|
1906
2300
|
}
|
|
1907
2301
|
function _omitBy(object, fn) {
|
|
1908
|
-
|
|
2302
|
+
if (object === void 0 || object === null) {
|
|
2303
|
+
return object;
|
|
2304
|
+
}
|
|
2305
|
+
return keys.strict(object).reduce((acc, key) => {
|
|
1909
2306
|
if (!fn(object[key], key)) {
|
|
1910
2307
|
acc[key] = object[key];
|
|
1911
2308
|
}
|
|
@@ -1952,7 +2349,7 @@ function _pickBy(object, fn) {
|
|
|
1952
2349
|
if (object == null) {
|
|
1953
2350
|
return {};
|
|
1954
2351
|
}
|
|
1955
|
-
return
|
|
2352
|
+
return keys.strict(object).reduce((acc, key) => {
|
|
1956
2353
|
if (fn(object[key], key)) {
|
|
1957
2354
|
acc[key] = object[key];
|
|
1958
2355
|
}
|
|
@@ -2011,17 +2408,6 @@ function _swapProps(obj, key1, key2) {
|
|
|
2011
2408
|
};
|
|
2012
2409
|
}
|
|
2013
2410
|
|
|
2014
|
-
// src/object/to-pairs.ts
|
|
2015
|
-
function toPairs(object) {
|
|
2016
|
-
return Object.entries(object);
|
|
2017
|
-
}
|
|
2018
|
-
((toPairs2) => {
|
|
2019
|
-
function strict(object) {
|
|
2020
|
-
return Object.entries(object);
|
|
2021
|
-
}
|
|
2022
|
-
toPairs2.strict = strict;
|
|
2023
|
-
})(toPairs || (toPairs = {}));
|
|
2024
|
-
|
|
2025
2411
|
// src/object/values.ts
|
|
2026
2412
|
function values(source) {
|
|
2027
2413
|
return Object.values(source);
|
|
@@ -2034,18 +2420,18 @@ function isUppercase(char = "") {
|
|
|
2034
2420
|
if (RE_NUMBER_CHAR.test(char)) {
|
|
2035
2421
|
return void 0;
|
|
2036
2422
|
}
|
|
2037
|
-
return char.
|
|
2423
|
+
return char !== char.toLowerCase();
|
|
2038
2424
|
}
|
|
2039
|
-
function splitByCase(
|
|
2425
|
+
function splitByCase(str, separators) {
|
|
2040
2426
|
const splitters = separators ?? STR_SPLITTERS;
|
|
2041
2427
|
const parts = [];
|
|
2042
|
-
if (!
|
|
2428
|
+
if (!str || !isString(str)) {
|
|
2043
2429
|
return parts;
|
|
2044
2430
|
}
|
|
2045
2431
|
let buff = "";
|
|
2046
2432
|
let previousUpper;
|
|
2047
2433
|
let previousSplitter;
|
|
2048
|
-
for (const char of
|
|
2434
|
+
for (const char of str) {
|
|
2049
2435
|
const isSplitter = splitters.includes(char);
|
|
2050
2436
|
if (isSplitter === true) {
|
|
2051
2437
|
parts.push(buff);
|
|
@@ -2062,7 +2448,7 @@ function splitByCase(string_, separators) {
|
|
|
2062
2448
|
continue;
|
|
2063
2449
|
}
|
|
2064
2450
|
if (previousUpper === true && isUpper === false && buff.length > 1) {
|
|
2065
|
-
const lastChar = buff
|
|
2451
|
+
const lastChar = buff.at(-1);
|
|
2066
2452
|
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
|
|
2067
2453
|
buff = lastChar + char;
|
|
2068
2454
|
previousUpper = isUpper;
|
|
@@ -2076,23 +2462,33 @@ function splitByCase(string_, separators) {
|
|
|
2076
2462
|
parts.push(buff);
|
|
2077
2463
|
return parts;
|
|
2078
2464
|
}
|
|
2079
|
-
function toUpperFirst(
|
|
2080
|
-
return
|
|
2465
|
+
function toUpperFirst(str) {
|
|
2466
|
+
return str ? str[0].toUpperCase() + str.slice(1) : "";
|
|
2467
|
+
}
|
|
2468
|
+
function toLowerFirst(str) {
|
|
2469
|
+
return str ? str[0].toLowerCase() + str.slice(1) : "";
|
|
2470
|
+
}
|
|
2471
|
+
function toPascalCase(str, opts) {
|
|
2472
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => toUpperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
|
|
2473
|
+
}
|
|
2474
|
+
function toCamelCase(str, opts) {
|
|
2475
|
+
return toLowerFirst(toPascalCase(str || "", opts));
|
|
2081
2476
|
}
|
|
2082
|
-
function
|
|
2083
|
-
return
|
|
2477
|
+
function toKebabCase(str, joiner) {
|
|
2478
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
|
|
2084
2479
|
}
|
|
2085
|
-
function
|
|
2086
|
-
return
|
|
2480
|
+
function toSnakeCase(str) {
|
|
2481
|
+
return toKebabCase(str || "", "_");
|
|
2087
2482
|
}
|
|
2088
|
-
function
|
|
2089
|
-
return
|
|
2483
|
+
function toFlatCase(str) {
|
|
2484
|
+
return toKebabCase(str || "", "");
|
|
2090
2485
|
}
|
|
2091
|
-
function
|
|
2092
|
-
return
|
|
2486
|
+
function toTrainCase(str, opts) {
|
|
2487
|
+
return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => toUpperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
|
|
2093
2488
|
}
|
|
2094
|
-
|
|
2095
|
-
|
|
2489
|
+
var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
|
|
2490
|
+
function titleCase(str, opts) {
|
|
2491
|
+
return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => titleCaseExceptions.test(p) ? p.toLowerCase() : toUpperFirst(opts?.normalize ? p.toLowerCase() : p)).join(" ");
|
|
2096
2492
|
}
|
|
2097
2493
|
|
|
2098
2494
|
// src/string/human-readable-file-size.ts
|
|
@@ -2142,21 +2538,28 @@ var isBrowser = typeof window !== "undefined";
|
|
|
2142
2538
|
export {
|
|
2143
2539
|
KEY_CODES,
|
|
2144
2540
|
_setPath,
|
|
2541
|
+
add,
|
|
2145
2542
|
addProp,
|
|
2146
2543
|
allPass,
|
|
2147
2544
|
anyPass,
|
|
2545
|
+
ceil,
|
|
2148
2546
|
chunk,
|
|
2149
2547
|
clamp,
|
|
2150
2548
|
clone,
|
|
2151
2549
|
compact,
|
|
2152
2550
|
concat,
|
|
2551
|
+
conditional,
|
|
2153
2552
|
countBy,
|
|
2154
2553
|
createPipe,
|
|
2155
2554
|
debounce,
|
|
2156
2555
|
difference,
|
|
2157
2556
|
differenceWith,
|
|
2557
|
+
divide,
|
|
2158
2558
|
drop,
|
|
2559
|
+
dropFirstBy,
|
|
2159
2560
|
dropLast,
|
|
2561
|
+
dropLastWhile,
|
|
2562
|
+
dropWhile,
|
|
2160
2563
|
equals,
|
|
2161
2564
|
filter,
|
|
2162
2565
|
find,
|
|
@@ -2164,14 +2567,17 @@ export {
|
|
|
2164
2567
|
findLast,
|
|
2165
2568
|
findLastIndex,
|
|
2166
2569
|
first,
|
|
2570
|
+
firstBy,
|
|
2167
2571
|
flatMap,
|
|
2168
2572
|
flatMapToObj,
|
|
2169
2573
|
flatten,
|
|
2170
2574
|
flattenDeep,
|
|
2575
|
+
floor,
|
|
2171
2576
|
forEach,
|
|
2172
2577
|
forEachObj,
|
|
2173
2578
|
fromPairs,
|
|
2174
2579
|
groupBy,
|
|
2580
|
+
hasAtLeast,
|
|
2175
2581
|
humanReadableFileSize,
|
|
2176
2582
|
identity,
|
|
2177
2583
|
indexBy,
|
|
@@ -2193,6 +2599,7 @@ export {
|
|
|
2193
2599
|
isObject,
|
|
2194
2600
|
isPromise,
|
|
2195
2601
|
isString,
|
|
2602
|
+
isSymbol,
|
|
2196
2603
|
isTruthy,
|
|
2197
2604
|
isUppercase,
|
|
2198
2605
|
join,
|
|
@@ -2209,11 +2616,14 @@ export {
|
|
|
2209
2616
|
mergeAll,
|
|
2210
2617
|
mergeDeep,
|
|
2211
2618
|
minBy,
|
|
2619
|
+
multiply,
|
|
2212
2620
|
noop,
|
|
2621
|
+
nthBy,
|
|
2213
2622
|
omit,
|
|
2214
2623
|
omitBy,
|
|
2215
2624
|
once,
|
|
2216
|
-
|
|
2625
|
+
only,
|
|
2626
|
+
partition2 as partition,
|
|
2217
2627
|
pathOr,
|
|
2218
2628
|
pick,
|
|
2219
2629
|
pickBy,
|
|
@@ -2222,9 +2632,11 @@ export {
|
|
|
2222
2632
|
purry,
|
|
2223
2633
|
randomString,
|
|
2224
2634
|
range,
|
|
2635
|
+
rankBy,
|
|
2225
2636
|
reduce,
|
|
2226
2637
|
reject,
|
|
2227
2638
|
reverse,
|
|
2639
|
+
round,
|
|
2228
2640
|
sample,
|
|
2229
2641
|
set,
|
|
2230
2642
|
setPath,
|
|
@@ -2233,21 +2645,27 @@ export {
|
|
|
2233
2645
|
slugify,
|
|
2234
2646
|
sort,
|
|
2235
2647
|
sortBy,
|
|
2648
|
+
splice,
|
|
2236
2649
|
splitAt,
|
|
2237
2650
|
splitByCase,
|
|
2238
2651
|
splitWhen,
|
|
2239
2652
|
stringToPath,
|
|
2653
|
+
subtract,
|
|
2240
2654
|
sumBy,
|
|
2241
2655
|
swapIndices,
|
|
2242
2656
|
swapProps,
|
|
2243
2657
|
take,
|
|
2658
|
+
takeFirstBy,
|
|
2244
2659
|
takeWhile,
|
|
2660
|
+
titleCase,
|
|
2245
2661
|
toCamelCase,
|
|
2662
|
+
toFlatCase,
|
|
2246
2663
|
toKebabCase,
|
|
2247
2664
|
toLowerFirst,
|
|
2248
2665
|
toPairs,
|
|
2249
2666
|
toPascalCase,
|
|
2250
2667
|
toSnakeCase,
|
|
2668
|
+
toTrainCase,
|
|
2251
2669
|
toUpperFirst,
|
|
2252
2670
|
type,
|
|
2253
2671
|
uniq,
|