@vinicunca/perkakas 0.0.11 → 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.js CHANGED
@@ -1,159 +1,27 @@
1
1
  // src/aria/key-codes.ts
2
2
  var KEY_CODES = {
3
- TAB: "Tab",
3
+ ALT: "Alt",
4
4
  ARROW_DOWN: "ArrowDown",
5
- ARROW_UP: "ArrowUp",
6
5
  ARROW_LEFT: "ArrowLeft",
7
6
  ARROW_RIGHT: "ArrowRight",
7
+ ARROW_UP: "ArrowUp",
8
+ AT: "@",
9
+ BACKSPACE: "Backspace",
10
+ CTRL: "Control",
11
+ DELETE: "Delete",
12
+ END: "End",
8
13
  ENTER: "Enter",
9
14
  ESC: "Escape",
10
- SPACE: "Space",
11
- SHIFT: "Shift",
15
+ HOME: "Home",
12
16
  KEY_F: "KEY_F",
13
- CTRL: "Control",
14
- ALT: "Alt",
15
17
  META: "Meta",
16
- AT: "@",
17
- DELETE: "Delete",
18
- BACKSPACE: "Backspace",
19
- HOME: "Home",
20
- END: "End",
18
+ PAGE_DOWN: "PageDown",
21
19
  PAGE_UP: "PageUp",
22
- PAGE_DOWN: "PageDown"
20
+ SHIFT: "Shift",
21
+ SPACE: "Space",
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({ item, acc, 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
- item,
78
- lazySeq,
79
- acc
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
- item: subItem,
101
- acc,
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
- if (isDone) {
124
- return true;
125
- }
126
- return false;
127
- }
128
-
129
- // src/function/create-pipe.ts
130
- function createPipe(...operations) {
131
- return (value) => pipe(value, ...operations);
132
- }
133
-
134
- // src/function/identity.ts
135
- function identity(value) {
136
- return value;
137
- }
138
-
139
- // src/function/noop.ts
140
- function noop() {
141
- return void 0;
142
- }
143
-
144
- // src/function/once.ts
145
- function once(fn) {
146
- let called = false;
147
- let ret;
148
- return () => {
149
- if (!called) {
150
- ret = fn();
151
- called = true;
152
- }
153
- return ret;
154
- };
155
- }
156
-
157
25
  // src/function/purry.ts
158
26
  function purry(fn, args, lazy) {
159
27
  const diff = fn.length - args.length;
@@ -172,13 +40,6 @@ function purry(fn, args, lazy) {
172
40
  throw new Error("Wrong number of arguments");
173
41
  }
174
42
 
175
- // src/function/sleep.ts
176
- function sleep(timeout) {
177
- return new Promise((resolve) => {
178
- setTimeout(resolve, timeout);
179
- });
180
- }
181
-
182
43
  // src/array/all-pass.ts
183
44
  function allPass(...args) {
184
45
  return purry(_allPass, args);
@@ -209,98 +70,6 @@ function _chunk(array, size) {
209
70
  return ret;
210
71
  }
211
72
 
212
- // src/guard/is-array.ts
213
- function isArray(data) {
214
- return Array.isArray(data);
215
- }
216
-
217
- // src/guard/is-boolean.ts
218
- function isBoolean(data) {
219
- return typeof data === "boolean";
220
- }
221
-
222
- // src/guard/is-date.ts
223
- function isDate(data) {
224
- return data instanceof Date;
225
- }
226
-
227
- // src/guard/is-defined.ts
228
- function isDefined(data) {
229
- return typeof data !== "undefined" && data !== null;
230
- }
231
- ((isDefined2) => {
232
- function strict(data) {
233
- return data !== void 0;
234
- }
235
- isDefined2.strict = strict;
236
- })(isDefined || (isDefined = {}));
237
-
238
- // src/base.ts
239
- function toString(value) {
240
- return Object.prototype.toString.call(value);
241
- }
242
-
243
- // src/guard/is-object.ts
244
- function isObject(data) {
245
- return toString(data) === "[object Object]";
246
- }
247
-
248
- // src/guard/is-string.ts
249
- function isString(data) {
250
- return typeof data === "string";
251
- }
252
-
253
- // src/guard/is-empty.ts
254
- function isEmpty(data) {
255
- if (isArray(data) || isString(data)) {
256
- return data.length === 0;
257
- }
258
- if (isObject(data)) {
259
- for (const _ in data) {
260
- return false;
261
- }
262
- return !(data instanceof RegExp);
263
- }
264
- return false;
265
- }
266
-
267
- // src/guard/is-error.ts
268
- function isError(data) {
269
- return data instanceof Error;
270
- }
271
-
272
- // src/guard/is-function.ts
273
- function isFunction(data) {
274
- return typeof data === "function";
275
- }
276
-
277
- // src/guard/is-nil.ts
278
- function isNil(data) {
279
- return data == null;
280
- }
281
-
282
- // src/guard/is-non-null.ts
283
- function isNonNull(data) {
284
- return data !== null;
285
- }
286
-
287
- // src/guard/is-not.ts
288
- function isNot(predicate) {
289
- return (data) => {
290
- return !predicate(data);
291
- };
292
- }
293
-
294
- // src/guard/is-number.ts
295
- function isNumber(data) {
296
- return typeof data === "number" && !Number.isNaN(data);
297
- }
298
-
299
- // src/guard/is-promise.ts
300
- function isPromise(data) {
301
- return data instanceof Promise;
302
- }
303
-
304
73
  // src/guard/is-truthy.ts
305
74
  function isTruthy(data) {
306
75
  return !!data;
@@ -339,7 +108,7 @@ function countBy(...args) {
339
108
  })(countBy || (countBy = {}));
340
109
 
341
110
  // src/utils/reduce-lazy.ts
342
- function _reduceLazy(array, lazy, indexed) {
111
+ function reduceLazy(array, lazy, indexed) {
343
112
  const newArray = [];
344
113
  for (let index = 0; index < array.length; index++) {
345
114
  const item = array[index];
@@ -359,7 +128,7 @@ function differenceWith(...args) {
359
128
  }
360
129
  function _differenceWith(array, other, isEquals) {
361
130
  const lazy = differenceWith.lazy(other, isEquals);
362
- return _reduceLazy(array, lazy);
131
+ return reduceLazy(array, lazy);
363
132
  }
364
133
  ((differenceWith2) => {
365
134
  function lazy(other, isEquals) {
@@ -386,7 +155,7 @@ function difference(...args) {
386
155
  }
387
156
  function _difference(array, other) {
388
157
  const lazy = difference.lazy(other);
389
- return _reduceLazy(array, lazy);
158
+ return reduceLazy(array, lazy);
390
159
  }
391
160
  ((difference2) => {
392
161
  function lazy(other) {
@@ -425,7 +194,7 @@ function drop(...args) {
425
194
  return purry(_drop, args, drop.lazy);
426
195
  }
427
196
  function _drop(array, n) {
428
- return _reduceLazy(array, drop.lazy(n));
197
+ return reduceLazy(array, drop.lazy(n));
429
198
  }
430
199
  ((drop2) => {
431
200
  function lazy(n) {
@@ -448,26 +217,179 @@ function _drop(array, n) {
448
217
  drop2.lazy = lazy;
449
218
  })(drop || (drop = {}));
450
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
+
451
374
  // src/utils/to-lazy-indexed.ts
452
375
  function toLazyIndexed(fn) {
453
- fn.indexed = true;
454
- return fn;
376
+ return Object.assign(fn, { indexed: true });
455
377
  }
456
378
 
457
379
  // src/array/filter.ts
458
380
  function filter(...args) {
459
- return purry(_filter(false), args, filter.lazy);
381
+ return purry(filter_(false), args, filter.lazy);
460
382
  }
461
- function _filter(indexed) {
383
+ function filter_(indexed) {
462
384
  return (array, fn) => {
463
- return _reduceLazy(
385
+ return reduceLazy(
464
386
  array,
465
387
  indexed ? filter.lazyIndexed(fn) : filter.lazy(fn),
466
388
  indexed
467
389
  );
468
390
  };
469
391
  }
470
- function _lazy(indexed) {
392
+ function lazy_(indexed) {
471
393
  return (fn) => {
472
394
  return (value, index, array) => {
473
395
  const valid = indexed ? fn(value, index, array) : fn(value);
@@ -487,11 +409,11 @@ function _lazy(indexed) {
487
409
  }
488
410
  ((filter2) => {
489
411
  function indexed(...args) {
490
- return purry(_filter(true), args, filter2.lazyIndexed);
412
+ return purry(filter_(true), args, filter2.lazyIndexed);
491
413
  }
492
414
  filter2.indexed = indexed;
493
- filter2.lazy = _lazy(false);
494
- filter2.lazyIndexed = toLazyIndexed(_lazy(true));
415
+ filter2.lazy = lazy_(false);
416
+ filter2.lazyIndexed = toLazyIndexed(lazy_(true));
495
417
  })(filter || (filter = {}));
496
418
 
497
419
  // src/utils/to-single.ts
@@ -512,7 +434,7 @@ function _findIndex(indexed) {
512
434
  return array.findIndex((x) => fn(x));
513
435
  };
514
436
  }
515
- function _lazy2(indexed) {
437
+ function _lazy(indexed) {
516
438
  return (fn) => {
517
439
  let i = 0;
518
440
  return (value, index, array) => {
@@ -537,8 +459,8 @@ function _lazy2(indexed) {
537
459
  return purry(_findIndex(true), args, findIndex2.lazyIndexed);
538
460
  }
539
461
  findIndex2.indexed = indexed;
540
- findIndex2.lazy = toSingle(_lazy2(false));
541
- findIndex2.lazyIndexed = toSingle(toLazyIndexed(_lazy2(true)));
462
+ findIndex2.lazy = toSingle(_lazy(false));
463
+ findIndex2.lazyIndexed = toSingle(toLazyIndexed(_lazy(true)));
542
464
  })(findIndex || (findIndex = {}));
543
465
 
544
466
  // src/array/find-last-index.ts
@@ -573,6 +495,7 @@ function _findLast(indexed) {
573
495
  return array[i];
574
496
  }
575
497
  }
498
+ return void 0;
576
499
  };
577
500
  }
578
501
  ((findLast2) => {
@@ -594,7 +517,7 @@ function _find(indexed) {
594
517
  return array.find((x) => fn(x));
595
518
  };
596
519
  }
597
- function _lazy3(indexed) {
520
+ function _lazy2(indexed) {
598
521
  return (fn) => {
599
522
  return (value, index, array) => {
600
523
  const valid = indexed ? fn(value, index, array) : fn(value);
@@ -611,8 +534,8 @@ function _lazy3(indexed) {
611
534
  return purry(_find(true), args, find2.lazyIndexed);
612
535
  }
613
536
  find2.indexed = indexed;
614
- find2.lazy = toSingle(_lazy3(false));
615
- find2.lazyIndexed = toSingle(toLazyIndexed(_lazy3(true)));
537
+ find2.lazy = toSingle(_lazy2(false));
538
+ find2.lazyIndexed = toSingle(toLazyIndexed(_lazy2(true)));
616
539
  })(find || (find = {}));
617
540
 
618
541
  // src/array/first.ts
@@ -638,6 +561,24 @@ function _first([first2]) {
638
561
  })(lazy = first2.lazy || (first2.lazy = {}));
639
562
  })(first || (first = {}));
640
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
+
641
582
  // src/array/flat-map-to-obj.ts
642
583
  function flatMapToObj(...args) {
643
584
  return purry(_flatMapToObj(false), args);
@@ -665,7 +606,7 @@ function flatten(...args) {
665
606
  return purry(_flatten, args, flatten.lazy);
666
607
  }
667
608
  function _flatten(items) {
668
- return _reduceLazy(items, flatten.lazy());
609
+ return reduceLazy(items, flatten.lazy());
669
610
  }
670
611
  ((flatten2) => {
671
612
  function lazy() {
@@ -673,8 +614,8 @@ function _flatten(items) {
673
614
  if (Array.isArray(next)) {
674
615
  return {
675
616
  done: false,
676
- hasNext: true,
677
617
  hasMany: true,
618
+ hasNext: true,
678
619
  next
679
620
  };
680
621
  }
@@ -702,8 +643,8 @@ function _flatMap(array, fn) {
702
643
  if (Array.isArray(next)) {
703
644
  return {
704
645
  done: false,
705
- hasNext: true,
706
646
  hasMany: true,
647
+ hasNext: true,
707
648
  next
708
649
  };
709
650
  }
@@ -722,7 +663,7 @@ function flattenDeep(...args) {
722
663
  return purry(_flattenDeep, args, flattenDeep.lazy);
723
664
  }
724
665
  function _flattenDeep(items) {
725
- return _reduceLazy(items, flattenDeep.lazy());
666
+ return reduceLazy(items, flattenDeep.lazy());
726
667
  }
727
668
  function _flattenDeepValue(value) {
728
669
  if (!Array.isArray(value)) {
@@ -745,8 +686,8 @@ function _flattenDeepValue(value) {
745
686
  if (Array.isArray(next)) {
746
687
  return {
747
688
  done: false,
748
- hasNext: true,
749
689
  hasMany: true,
690
+ hasNext: true,
750
691
  next
751
692
  };
752
693
  }
@@ -766,14 +707,14 @@ function forEach(...args) {
766
707
  }
767
708
  function _forEach(indexed) {
768
709
  return (array, fn) => {
769
- return _reduceLazy(
710
+ return reduceLazy(
770
711
  array,
771
712
  indexed ? forEach.lazyIndexed(fn) : forEach.lazy(fn),
772
713
  indexed
773
714
  );
774
715
  };
775
716
  }
776
- function _lazy4(indexed) {
717
+ function _lazy3(indexed) {
777
718
  return (fn) => {
778
719
  return (value, index, array) => {
779
720
  if (indexed) {
@@ -794,8 +735,8 @@ function _lazy4(indexed) {
794
735
  return purry(_forEach(true), args, forEach2.lazyIndexed);
795
736
  }
796
737
  forEach2.indexed = indexed;
797
- forEach2.lazy = _lazy4(false);
798
- forEach2.lazyIndexed = toLazyIndexed(_lazy4(true));
738
+ forEach2.lazy = _lazy3(false);
739
+ forEach2.lazyIndexed = toLazyIndexed(_lazy3(true));
799
740
  })(forEach || (forEach = {}));
800
741
 
801
742
  // src/array/group-by.ts
@@ -809,10 +750,12 @@ function _groupBy(indexed) {
809
750
  const key = indexed ? fn(item, index, array) : fn(item);
810
751
  if (key !== void 0) {
811
752
  const actualKey = String(key);
812
- if (!ret[actualKey]) {
813
- ret[actualKey] = [];
753
+ let items = ret[actualKey];
754
+ if (items === void 0) {
755
+ items = [];
756
+ ret[actualKey] = items;
814
757
  }
815
- ret[actualKey].push(item);
758
+ items.push(item);
816
759
  }
817
760
  });
818
761
  return ret;
@@ -853,7 +796,7 @@ function intersection(...args) {
853
796
  }
854
797
  function _intersection(array, other) {
855
798
  const lazy = intersection.lazy(other);
856
- return _reduceLazy(array, lazy);
799
+ return reduceLazy(array, lazy);
857
800
  }
858
801
  ((intersection2) => {
859
802
  function lazy(other) {
@@ -881,7 +824,7 @@ function intersectionWith(...args) {
881
824
  }
882
825
  function _intersectionWith(array, other, comparator) {
883
826
  const lazy = intersectionWith.lazy(other, comparator);
884
- return _reduceLazy(array, lazy);
827
+ return reduceLazy(array, lazy);
885
828
  }
886
829
  ((intersectionWith2) => {
887
830
  function lazy(other, comparator) {
@@ -932,14 +875,14 @@ function map(...args) {
932
875
  }
933
876
  function _map(indexed) {
934
877
  return (array, fn) => {
935
- return _reduceLazy(
878
+ return reduceLazy(
936
879
  array,
937
880
  indexed ? map.lazyIndexed(fn) : map.lazy(fn),
938
881
  indexed
939
882
  );
940
883
  };
941
884
  }
942
- function _lazy5(indexed) {
885
+ function _lazy4(indexed) {
943
886
  return (fn) => {
944
887
  return (value, index, array) => {
945
888
  return {
@@ -955,8 +898,8 @@ function _lazy5(indexed) {
955
898
  return purry(_map(true), args, map2.lazyIndexed);
956
899
  }
957
900
  map2.indexed = indexed;
958
- map2.lazy = _lazy5(false);
959
- map2.lazyIndexed = toLazyIndexed(_lazy5(true));
901
+ map2.lazy = _lazy4(false);
902
+ map2.lazyIndexed = toLazyIndexed(_lazy4(true));
960
903
  map2.strict = map2;
961
904
  })(map || (map = {}));
962
905
 
@@ -966,11 +909,14 @@ function mapToObj(...args) {
966
909
  }
967
910
  function _mapToObj(indexed) {
968
911
  return (array, fn) => {
969
- return array.reduce((result, element, index) => {
970
- const [key, value] = indexed ? fn(element, index, array) : fn(element);
971
- result[key] = value;
972
- return result;
973
- }, {});
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
+ );
974
920
  };
975
921
  }
976
922
  ((mapToObj2) => {
@@ -1058,8 +1004,70 @@ function minBy(...args) {
1058
1004
  minBy2.indexed = indexed;
1059
1005
  })(minBy || (minBy = {}));
1060
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
+
1061
1069
  // src/array/partition.ts
1062
- function partition(...args) {
1070
+ function partition2(...args) {
1063
1071
  return purry(_partition(false), args);
1064
1072
  }
1065
1073
  function _partition(indexed) {
@@ -1072,12 +1080,12 @@ function _partition(indexed) {
1072
1080
  return ret;
1073
1081
  };
1074
1082
  }
1075
- ((partition2) => {
1083
+ ((partition3) => {
1076
1084
  function indexed(...args) {
1077
1085
  return purry(_partition(true), args);
1078
1086
  }
1079
- partition2.indexed = indexed;
1080
- })(partition || (partition = {}));
1087
+ partition3.indexed = indexed;
1088
+ })(partition2 || (partition2 = {}));
1081
1089
 
1082
1090
  // src/array/range.ts
1083
1091
  function range(...args) {
@@ -1091,6 +1099,20 @@ function _range(start, end) {
1091
1099
  return ret;
1092
1100
  }
1093
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
+
1094
1116
  // src/array/reduce.ts
1095
1117
  function reduce(...args) {
1096
1118
  return purry(_reduce(false), args);
@@ -1116,14 +1138,14 @@ function reject(...args) {
1116
1138
  }
1117
1139
  function _reject(indexed) {
1118
1140
  return (array, fn) => {
1119
- return _reduceLazy(
1141
+ return reduceLazy(
1120
1142
  array,
1121
1143
  indexed ? reject.lazyIndexed(fn) : reject.lazy(fn),
1122
1144
  indexed
1123
1145
  );
1124
1146
  };
1125
1147
  }
1126
- function _lazy6(indexed) {
1148
+ function _lazy5(indexed) {
1127
1149
  return (fn) => {
1128
1150
  return (value, index, array) => {
1129
1151
  const valid = indexed ? fn(value, index, array) : fn(value);
@@ -1146,8 +1168,8 @@ function _lazy6(indexed) {
1146
1168
  return purry(_reject(true), args, reject2.lazyIndexed);
1147
1169
  }
1148
1170
  reject2.indexed = indexed;
1149
- reject2.lazy = _lazy6(false);
1150
- reject2.lazyIndexed = toLazyIndexed(_lazy6(true));
1171
+ reject2.lazy = _lazy5(false);
1172
+ reject2.lazyIndexed = toLazyIndexed(_lazy5(true));
1151
1173
  })(reject || (reject = {}));
1152
1174
 
1153
1175
  // src/array/reverse.ts
@@ -1259,6 +1281,16 @@ function comparer(primaryRule, secondaryRule, ...otherRules) {
1259
1281
  sortBy2.strict = sortBy2;
1260
1282
  })(sortBy || (sortBy = {}));
1261
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
+
1262
1294
  // src/array/split-at.ts
1263
1295
  function splitAt(...args) {
1264
1296
  return purry(_splitAt, args);
@@ -1332,185 +1364,606 @@ function _swapString(item, index1, index2) {
1332
1364
  return result.join("");
1333
1365
  }
1334
1366
 
1335
- // src/array/take.ts
1336
- function take(...args) {
1337
- return purry(_take, args, take.lazy);
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";
1847
+ }
1848
+
1849
+ // src/guard/is-date.ts
1850
+ function isDate(data) {
1851
+ return data instanceof Date;
1338
1852
  }
1339
- function _take(array, n) {
1340
- return _reduceLazy(array, take.lazy(n));
1853
+
1854
+ // src/guard/is-defined.ts
1855
+ function isDefined(data) {
1856
+ return typeof data !== "undefined" && data !== null;
1341
1857
  }
1342
- ((take2) => {
1343
- function lazy(n) {
1344
- return (value) => {
1345
- if (n === 0) {
1346
- return {
1347
- done: true,
1348
- hasNext: false
1349
- };
1350
- }
1351
- n--;
1352
- if (n === 0) {
1353
- return {
1354
- done: true,
1355
- hasNext: true,
1356
- next: value
1357
- };
1358
- }
1359
- return {
1360
- done: false,
1361
- hasNext: true,
1362
- next: value
1363
- };
1364
- };
1858
+ ((isDefined2) => {
1859
+ function strict(data) {
1860
+ return data !== void 0;
1365
1861
  }
1366
- take2.lazy = lazy;
1367
- })(take || (take = {}));
1862
+ isDefined2.strict = strict;
1863
+ })(isDefined || (isDefined = {}));
1368
1864
 
1369
- // src/array/take-while.ts
1370
- function takeWhile(...args) {
1371
- return purry(_takeWhile, args);
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;
1372
1872
  }
1373
- function _takeWhile(array, fn) {
1374
- const ret = [];
1375
- for (const item of array) {
1376
- if (!fn(item)) {
1377
- break;
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;
1378
1887
  }
1379
- ret.push(item);
1888
+ return !(data instanceof RegExp);
1380
1889
  }
1381
- return ret;
1890
+ return false;
1382
1891
  }
1383
1892
 
1384
- // src/array/uniq.ts
1385
- function uniq(...args) {
1386
- return purry(_uniq, args, uniq.lazy);
1893
+ // src/guard/is-error.ts
1894
+ function isError(data) {
1895
+ return data instanceof Error;
1387
1896
  }
1388
- function _uniq(array) {
1389
- return _reduceLazy(array, uniq.lazy());
1897
+
1898
+ // src/guard/is-function.ts
1899
+ function isFunction(data) {
1900
+ return typeof data === "function";
1390
1901
  }
1391
- ((uniq2) => {
1392
- function lazy() {
1393
- const set2 = /* @__PURE__ */ new Set();
1394
- return (value) => {
1395
- if (set2.has(value)) {
1396
- return {
1397
- done: false,
1398
- hasNext: false
1399
- };
1400
- }
1401
- set2.add(value);
1402
- return {
1403
- done: false,
1404
- hasNext: true,
1405
- next: value
1406
- };
1407
- };
1408
- }
1409
- uniq2.lazy = lazy;
1410
- })(uniq || (uniq = {}));
1411
1902
 
1412
- // src/array/uniq-by.ts
1413
- function uniqBy(...args) {
1414
- return purry(_uniqBy, args, lazyUniqBy);
1903
+ // src/guard/is-nil.ts
1904
+ function isNil(data) {
1905
+ return data == null;
1415
1906
  }
1416
- function _uniqBy(array, transformer) {
1417
- return _reduceLazy(array, lazyUniqBy(transformer));
1907
+
1908
+ // src/guard/is-non-null.ts
1909
+ function isNonNull(data) {
1910
+ return data !== null;
1418
1911
  }
1419
- function lazyUniqBy(transformer) {
1420
- const set2 = /* @__PURE__ */ new Set();
1421
- return (value) => {
1422
- const appliedItem = transformer(value);
1423
- if (set2.has(appliedItem)) {
1424
- return {
1425
- done: false,
1426
- hasNext: false
1427
- };
1428
- }
1429
- set2.add(appliedItem);
1430
- return {
1431
- done: false,
1432
- hasNext: true,
1433
- next: value
1434
- };
1912
+
1913
+ // src/guard/is-not.ts
1914
+ function isNot(predicate) {
1915
+ return (data) => {
1916
+ return !predicate(data);
1435
1917
  };
1436
1918
  }
1437
1919
 
1438
- // src/array/uniq-with.ts
1439
- function uniqWith(...args) {
1440
- return purry(_uniqWith, args, uniqWith.lazy);
1441
- }
1442
- function _uniqWith(array, isEquals) {
1443
- const lazy = uniqWith.lazy(isEquals);
1444
- return _reduceLazy(array, lazy, true);
1445
- }
1446
- function _lazy7(isEquals) {
1447
- return (value, index, array) => {
1448
- if (array && array.findIndex((otherValue) => isEquals(value, otherValue)) === index) {
1449
- return {
1450
- done: false,
1451
- hasNext: true,
1452
- next: value
1453
- };
1454
- }
1455
- return {
1456
- done: false,
1457
- hasNext: false
1458
- };
1459
- };
1920
+ // src/guard/is-number.ts
1921
+ function isNumber(data) {
1922
+ return typeof data === "number" && !Number.isNaN(data);
1460
1923
  }
1461
- ((uniqWith2) => {
1462
- uniqWith2.lazy = toLazyIndexed(_lazy7);
1463
- })(uniqWith || (uniqWith = {}));
1464
1924
 
1465
- // src/array/zip.ts
1466
- function zip(...args) {
1467
- return purry(_zip, args);
1925
+ // src/guard/is-promise.ts
1926
+ function isPromise(data) {
1927
+ return data instanceof Promise;
1468
1928
  }
1469
- function _zip(first2, second) {
1470
- const resultLength = first2.length > second.length ? second.length : first2.length;
1471
- const result = [];
1472
- for (let i = 0; i < resultLength; i++) {
1473
- result.push([first2[i], second[i]]);
1474
- }
1475
- return result;
1929
+
1930
+ // src/guard/is-symbol.ts
1931
+ function isSymbol(data) {
1932
+ return typeof data === "symbol";
1476
1933
  }
1477
1934
 
1478
- // src/array/zip-obj.ts
1479
- function zipObj(...args) {
1480
- return purry(_zipObj, args);
1935
+ // src/number/add.ts
1936
+ function add(...args) {
1937
+ return purry(_add, args);
1481
1938
  }
1482
- function _zipObj(first2, second) {
1483
- const resultLength = first2.length > second.length ? second.length : first2.length;
1484
- const result = {};
1485
- for (let i = 0; i < resultLength; i++) {
1486
- result[first2[i]] = second[i];
1487
- }
1488
- return result;
1939
+ function _add(value, addend) {
1940
+ return value + addend;
1489
1941
  }
1490
1942
 
1491
- // src/array/zip-with.ts
1492
- function zipWith(...args) {
1493
- if (typeof args[0] === "function" && args.length === 1) {
1494
- return function(f, s) {
1495
- return _zipWith(f, s, args[0]);
1496
- };
1497
- }
1498
- if (typeof args[0] === "function" && args.length === 2) {
1499
- return function(f) {
1500
- return _zipWith(f, args[1], args[0]);
1501
- };
1502
- }
1503
- if (args.length === 3) {
1504
- return _zipWith(args[0], args[1], args[2]);
1505
- }
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
+ };
1506
1962
  }
1507
- function _zipWith(first2, second, fn) {
1508
- const resultLength = first2.length > second.length ? second.length : first2.length;
1509
- const result = [];
1510
- for (let i = 0; i < resultLength; i++) {
1511
- result.push(fn(first2[i], second[i]));
1512
- }
1513
- return result;
1963
+
1964
+ // src/number/ceil.ts
1965
+ function ceil(...args) {
1966
+ return purry(withPrecision(Math.ceil), args);
1514
1967
  }
1515
1968
 
1516
1969
  // src/number/clamp.ts
@@ -1527,6 +1980,40 @@ function _clamp(value, limits) {
1527
1980
  return value;
1528
1981
  }
1529
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
+
1530
2017
  // src/object/add-prop.ts
1531
2018
  function addProp(...args) {
1532
2019
  return purry(_addProp, args);
@@ -1716,32 +2203,36 @@ function keys(source) {
1716
2203
  keys2.strict = keys2;
1717
2204
  })(keys || (keys = {}));
1718
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
+
1719
2214
  // src/object/map-keys.ts
1720
- function mapKeys(arg1, arg2) {
1721
- if (arguments.length === 1) {
1722
- return (data) => _mapKeys(data, arg1);
1723
- }
1724
- return _mapKeys(arg1, arg2);
2215
+ function mapKeys(...args) {
2216
+ return purry(_mapKeys, args);
1725
2217
  }
1726
- function _mapKeys(obj, fn) {
1727
- return Object.keys(obj).reduce((acc, key) => {
1728
- acc[fn(key, obj[key])] = obj[key];
1729
- return acc;
1730
- }, {});
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;
1731
2224
  }
1732
2225
 
1733
2226
  // src/object/map-values.ts
1734
- function mapValues(arg1, arg2) {
1735
- if (arguments.length === 1) {
1736
- return (data) => _mapValues(data, arg1);
1737
- }
1738
- return _mapValues(arg1, arg2);
2227
+ function mapValues(...args) {
2228
+ return purry(_mapValues, args);
1739
2229
  }
1740
- function _mapValues(obj, fn) {
1741
- return Object.keys(obj).reduce((acc, key) => {
1742
- acc[key] = fn(obj[key], key);
1743
- return acc;
1744
- }, {});
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;
1745
2236
  }
1746
2237
 
1747
2238
  // src/object/merge.ts
@@ -1753,49 +2244,40 @@ function _merge(a, b) {
1753
2244
  }
1754
2245
 
1755
2246
  // src/object/merge-deep.ts
1756
- function mergeDeep({
1757
- mergeArray = false,
1758
- original,
1759
- patch
1760
- }) {
1761
- const original_ = original;
1762
- const patch_ = patch;
1763
- if (Array.isArray(patch_)) {
1764
- if (mergeArray && Array.isArray(patch_)) {
1765
- return [...original_, ...patch_];
1766
- } else {
1767
- return [...patch_];
1768
- }
1769
- }
1770
- const output = { ...original_ };
1771
- if (isObject(original_) && isObject(patch_)) {
1772
- Object.keys(patch_).forEach((key) => {
1773
- const areBothObjects = isObject(original_[key]) && isObject(patch_[key]);
1774
- const areBothArrays = Array.isArray(original_[key]) && Array.isArray(patch_[key]);
1775
- if (areBothObjects || areBothArrays) {
1776
- output[key] = mergeDeep({
1777
- mergeArray,
1778
- original: original_[key],
1779
- patch: patch_[key]
1780
- });
1781
- } else {
1782
- Object.assign(output, { [key]: patch_[key] });
1783
- }
1784
- ;
1785
- });
2247
+ function mergeDeep(...args) {
2248
+ return purry(mergeDeepImplementation, args);
2249
+ }
2250
+ function mergeDeepImplementation(destination, source) {
2251
+ const output = { ...destination, ...source };
2252
+ for (const key in source) {
2253
+ if (!(key in destination)) {
2254
+ continue;
2255
+ }
2256
+ const destinationValue = destination[key];
2257
+ if (!isRecord(destinationValue)) {
2258
+ continue;
2259
+ }
2260
+ const sourceValue = source[key];
2261
+ if (!isRecord(sourceValue)) {
2262
+ continue;
2263
+ }
2264
+ output[key] = mergeDeepImplementation(destinationValue, sourceValue);
1786
2265
  }
1787
2266
  return output;
1788
2267
  }
2268
+ function isRecord(object) {
2269
+ return typeof object === "object" && object !== null && Object.getPrototypeOf(object) === Object.prototype;
2270
+ }
1789
2271
 
1790
2272
  // src/object/omit.ts
1791
2273
  function omit(...args) {
1792
2274
  return purry(_omit, args);
1793
2275
  }
1794
2276
  function _omit(data, propNames) {
1795
- if (propNames.length === 0) {
2277
+ if (!hasAtLeast(propNames, 1)) {
1796
2278
  return { ...data };
1797
2279
  }
1798
- if (propNames.length === 1) {
2280
+ if (!hasAtLeast(propNames, 2)) {
1799
2281
  const [propName] = propNames;
1800
2282
  const {
1801
2283
  [propName]: omitted,
@@ -1817,7 +2299,10 @@ function omitBy(...args) {
1817
2299
  return purry(_omitBy, args);
1818
2300
  }
1819
2301
  function _omitBy(object, fn) {
1820
- return Object.keys(object).reduce((acc, key) => {
2302
+ if (object === void 0 || object === null) {
2303
+ return object;
2304
+ }
2305
+ return keys.strict(object).reduce((acc, key) => {
1821
2306
  if (!fn(object[key], key)) {
1822
2307
  acc[key] = object[key];
1823
2308
  }
@@ -1864,7 +2349,7 @@ function _pickBy(object, fn) {
1864
2349
  if (object == null) {
1865
2350
  return {};
1866
2351
  }
1867
- return Object.keys(object).reduce((acc, key) => {
2352
+ return keys.strict(object).reduce((acc, key) => {
1868
2353
  if (fn(object[key], key)) {
1869
2354
  acc[key] = object[key];
1870
2355
  }
@@ -1923,17 +2408,6 @@ function _swapProps(obj, key1, key2) {
1923
2408
  };
1924
2409
  }
1925
2410
 
1926
- // src/object/to-pairs.ts
1927
- function toPairs(object) {
1928
- return Object.entries(object);
1929
- }
1930
- ((toPairs2) => {
1931
- function strict(object) {
1932
- return Object.entries(object);
1933
- }
1934
- toPairs2.strict = strict;
1935
- })(toPairs || (toPairs = {}));
1936
-
1937
2411
  // src/object/values.ts
1938
2412
  function values(source) {
1939
2413
  return Object.values(source);
@@ -1946,18 +2420,18 @@ function isUppercase(char = "") {
1946
2420
  if (RE_NUMBER_CHAR.test(char)) {
1947
2421
  return void 0;
1948
2422
  }
1949
- return char.toUpperCase() === char;
2423
+ return char !== char.toLowerCase();
1950
2424
  }
1951
- function splitByCase(string_, separators) {
2425
+ function splitByCase(str, separators) {
1952
2426
  const splitters = separators ?? STR_SPLITTERS;
1953
2427
  const parts = [];
1954
- if (!string_ || !isString(string_)) {
2428
+ if (!str || !isString(str)) {
1955
2429
  return parts;
1956
2430
  }
1957
2431
  let buff = "";
1958
2432
  let previousUpper;
1959
2433
  let previousSplitter;
1960
- for (const char of string_) {
2434
+ for (const char of str) {
1961
2435
  const isSplitter = splitters.includes(char);
1962
2436
  if (isSplitter === true) {
1963
2437
  parts.push(buff);
@@ -1974,7 +2448,7 @@ function splitByCase(string_, separators) {
1974
2448
  continue;
1975
2449
  }
1976
2450
  if (previousUpper === true && isUpper === false && buff.length > 1) {
1977
- const lastChar = buff[buff.length - 1];
2451
+ const lastChar = buff.at(-1);
1978
2452
  parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
1979
2453
  buff = lastChar + char;
1980
2454
  previousUpper = isUpper;
@@ -1988,23 +2462,33 @@ function splitByCase(string_, separators) {
1988
2462
  parts.push(buff);
1989
2463
  return parts;
1990
2464
  }
1991
- function toUpperFirst(string_) {
1992
- return !string_ ? "" : string_[0].toUpperCase() + string_.slice(1);
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));
1993
2476
  }
1994
- function toLowerFirst(string_) {
1995
- return !string_ ? "" : string_[0].toLowerCase() + string_.slice(1);
2477
+ function toKebabCase(str, joiner) {
2478
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
1996
2479
  }
1997
- function toPascalCase(string_) {
1998
- return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => toUpperFirst(p)).join("");
2480
+ function toSnakeCase(str) {
2481
+ return toKebabCase(str || "", "_");
1999
2482
  }
2000
- function toCamelCase(string_) {
2001
- return toLowerFirst(toPascalCase(string_ || ""));
2483
+ function toFlatCase(str) {
2484
+ return toKebabCase(str || "", "");
2002
2485
  }
2003
- function toKebabCase(string_, joiner) {
2004
- return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => p.toLowerCase()).join(joiner ?? "-");
2486
+ function toTrainCase(str, opts) {
2487
+ return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => toUpperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
2005
2488
  }
2006
- function toSnakeCase(string_) {
2007
- return toKebabCase(string_ || "", "_");
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(" ");
2008
2492
  }
2009
2493
 
2010
2494
  // src/string/human-readable-file-size.ts
@@ -2054,20 +2538,28 @@ var isBrowser = typeof window !== "undefined";
2054
2538
  export {
2055
2539
  KEY_CODES,
2056
2540
  _setPath,
2541
+ add,
2057
2542
  addProp,
2058
2543
  allPass,
2059
2544
  anyPass,
2545
+ ceil,
2060
2546
  chunk,
2061
2547
  clamp,
2062
2548
  clone,
2063
2549
  compact,
2064
2550
  concat,
2551
+ conditional,
2065
2552
  countBy,
2066
2553
  createPipe,
2554
+ debounce,
2067
2555
  difference,
2068
2556
  differenceWith,
2557
+ divide,
2069
2558
  drop,
2559
+ dropFirstBy,
2070
2560
  dropLast,
2561
+ dropLastWhile,
2562
+ dropWhile,
2071
2563
  equals,
2072
2564
  filter,
2073
2565
  find,
@@ -2075,14 +2567,17 @@ export {
2075
2567
  findLast,
2076
2568
  findLastIndex,
2077
2569
  first,
2570
+ firstBy,
2078
2571
  flatMap,
2079
2572
  flatMapToObj,
2080
2573
  flatten,
2081
2574
  flattenDeep,
2575
+ floor,
2082
2576
  forEach,
2083
2577
  forEachObj,
2084
2578
  fromPairs,
2085
2579
  groupBy,
2580
+ hasAtLeast,
2086
2581
  humanReadableFileSize,
2087
2582
  identity,
2088
2583
  indexBy,
@@ -2104,6 +2599,7 @@ export {
2104
2599
  isObject,
2105
2600
  isPromise,
2106
2601
  isString,
2602
+ isSymbol,
2107
2603
  isTruthy,
2108
2604
  isUppercase,
2109
2605
  join,
@@ -2120,11 +2616,14 @@ export {
2120
2616
  mergeAll,
2121
2617
  mergeDeep,
2122
2618
  minBy,
2619
+ multiply,
2123
2620
  noop,
2621
+ nthBy,
2124
2622
  omit,
2125
2623
  omitBy,
2126
2624
  once,
2127
- partition,
2625
+ only,
2626
+ partition2 as partition,
2128
2627
  pathOr,
2129
2628
  pick,
2130
2629
  pickBy,
@@ -2133,9 +2632,11 @@ export {
2133
2632
  purry,
2134
2633
  randomString,
2135
2634
  range,
2635
+ rankBy,
2136
2636
  reduce,
2137
2637
  reject,
2138
2638
  reverse,
2639
+ round,
2139
2640
  sample,
2140
2641
  set,
2141
2642
  setPath,
@@ -2144,21 +2645,27 @@ export {
2144
2645
  slugify,
2145
2646
  sort,
2146
2647
  sortBy,
2648
+ splice,
2147
2649
  splitAt,
2148
2650
  splitByCase,
2149
2651
  splitWhen,
2150
2652
  stringToPath,
2653
+ subtract,
2151
2654
  sumBy,
2152
2655
  swapIndices,
2153
2656
  swapProps,
2154
2657
  take,
2658
+ takeFirstBy,
2155
2659
  takeWhile,
2660
+ titleCase,
2156
2661
  toCamelCase,
2662
+ toFlatCase,
2157
2663
  toKebabCase,
2158
2664
  toLowerFirst,
2159
2665
  toPairs,
2160
2666
  toPascalCase,
2161
2667
  toSnakeCase,
2668
+ toTrainCase,
2162
2669
  toUpperFirst,
2163
2670
  type,
2164
2671
  uniq,