@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.cjs CHANGED
@@ -22,20 +22,28 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  KEY_CODES: () => KEY_CODES,
24
24
  _setPath: () => _setPath,
25
+ add: () => add,
25
26
  addProp: () => addProp,
26
27
  allPass: () => allPass,
27
28
  anyPass: () => anyPass,
29
+ ceil: () => ceil,
28
30
  chunk: () => chunk,
29
31
  clamp: () => clamp,
30
32
  clone: () => clone,
31
33
  compact: () => compact,
32
34
  concat: () => concat,
35
+ conditional: () => conditional,
33
36
  countBy: () => countBy,
34
37
  createPipe: () => createPipe,
38
+ debounce: () => debounce,
35
39
  difference: () => difference,
36
40
  differenceWith: () => differenceWith,
41
+ divide: () => divide,
37
42
  drop: () => drop,
43
+ dropFirstBy: () => dropFirstBy,
38
44
  dropLast: () => dropLast,
45
+ dropLastWhile: () => dropLastWhile,
46
+ dropWhile: () => dropWhile,
39
47
  equals: () => equals,
40
48
  filter: () => filter,
41
49
  find: () => find,
@@ -43,14 +51,17 @@ __export(src_exports, {
43
51
  findLast: () => findLast,
44
52
  findLastIndex: () => findLastIndex,
45
53
  first: () => first,
54
+ firstBy: () => firstBy,
46
55
  flatMap: () => flatMap,
47
56
  flatMapToObj: () => flatMapToObj,
48
57
  flatten: () => flatten,
49
58
  flattenDeep: () => flattenDeep,
59
+ floor: () => floor,
50
60
  forEach: () => forEach,
51
61
  forEachObj: () => forEachObj,
52
62
  fromPairs: () => fromPairs,
53
63
  groupBy: () => groupBy,
64
+ hasAtLeast: () => hasAtLeast,
54
65
  humanReadableFileSize: () => humanReadableFileSize,
55
66
  identity: () => identity,
56
67
  indexBy: () => indexBy,
@@ -72,6 +83,7 @@ __export(src_exports, {
72
83
  isObject: () => isObject,
73
84
  isPromise: () => isPromise,
74
85
  isString: () => isString,
86
+ isSymbol: () => isSymbol,
75
87
  isTruthy: () => isTruthy,
76
88
  isUppercase: () => isUppercase,
77
89
  join: () => join,
@@ -88,11 +100,14 @@ __export(src_exports, {
88
100
  mergeAll: () => mergeAll,
89
101
  mergeDeep: () => mergeDeep,
90
102
  minBy: () => minBy,
103
+ multiply: () => multiply,
91
104
  noop: () => noop,
105
+ nthBy: () => nthBy,
92
106
  omit: () => omit,
93
107
  omitBy: () => omitBy,
94
108
  once: () => once,
95
- partition: () => partition,
109
+ only: () => only,
110
+ partition: () => partition2,
96
111
  pathOr: () => pathOr,
97
112
  pick: () => pick,
98
113
  pickBy: () => pickBy,
@@ -101,9 +116,11 @@ __export(src_exports, {
101
116
  purry: () => purry,
102
117
  randomString: () => randomString,
103
118
  range: () => range,
119
+ rankBy: () => rankBy,
104
120
  reduce: () => reduce,
105
121
  reject: () => reject,
106
122
  reverse: () => reverse,
123
+ round: () => round,
107
124
  sample: () => sample,
108
125
  set: () => set,
109
126
  setPath: () => setPath,
@@ -112,21 +129,27 @@ __export(src_exports, {
112
129
  slugify: () => slugify,
113
130
  sort: () => sort,
114
131
  sortBy: () => sortBy,
132
+ splice: () => splice,
115
133
  splitAt: () => splitAt,
116
134
  splitByCase: () => splitByCase,
117
135
  splitWhen: () => splitWhen,
118
136
  stringToPath: () => stringToPath,
137
+ subtract: () => subtract,
119
138
  sumBy: () => sumBy,
120
139
  swapIndices: () => swapIndices,
121
140
  swapProps: () => swapProps,
122
141
  take: () => take,
142
+ takeFirstBy: () => takeFirstBy,
123
143
  takeWhile: () => takeWhile,
144
+ titleCase: () => titleCase,
124
145
  toCamelCase: () => toCamelCase,
146
+ toFlatCase: () => toFlatCase,
125
147
  toKebabCase: () => toKebabCase,
126
148
  toLowerFirst: () => toLowerFirst,
127
149
  toPairs: () => toPairs,
128
150
  toPascalCase: () => toPascalCase,
129
151
  toSnakeCase: () => toSnakeCase,
152
+ toTrainCase: () => toTrainCase,
130
153
  toUpperFirst: () => toUpperFirst,
131
154
  type: () => type,
132
155
  uniq: () => uniq,
@@ -141,160 +164,28 @@ module.exports = __toCommonJS(src_exports);
141
164
 
142
165
  // src/aria/key-codes.ts
143
166
  var KEY_CODES = {
144
- TAB: "Tab",
167
+ ALT: "Alt",
145
168
  ARROW_DOWN: "ArrowDown",
146
- ARROW_UP: "ArrowUp",
147
169
  ARROW_LEFT: "ArrowLeft",
148
170
  ARROW_RIGHT: "ArrowRight",
171
+ ARROW_UP: "ArrowUp",
172
+ AT: "@",
173
+ BACKSPACE: "Backspace",
174
+ CTRL: "Control",
175
+ DELETE: "Delete",
176
+ END: "End",
149
177
  ENTER: "Enter",
150
178
  ESC: "Escape",
151
- SPACE: "Space",
152
- SHIFT: "Shift",
179
+ HOME: "Home",
153
180
  KEY_F: "KEY_F",
154
- CTRL: "Control",
155
- ALT: "Alt",
156
181
  META: "Meta",
157
- AT: "@",
158
- DELETE: "Delete",
159
- BACKSPACE: "Backspace",
160
- HOME: "Home",
161
- END: "End",
182
+ PAGE_DOWN: "PageDown",
162
183
  PAGE_UP: "PageUp",
163
- PAGE_DOWN: "PageDown"
184
+ SHIFT: "Shift",
185
+ SPACE: "Space",
186
+ TAB: "Tab"
164
187
  };
165
188
 
166
- // src/function/pipe.ts
167
- function pipe(value, ...operations) {
168
- let ret = value;
169
- const lazyOps = operations.map((op) => {
170
- const { lazy, lazyArgs } = op;
171
- if (lazy) {
172
- const fn = lazy(...lazyArgs || []);
173
- fn.indexed = lazy.indexed;
174
- fn.single = lazy.single;
175
- fn.index = 0;
176
- fn.items = [];
177
- return fn;
178
- }
179
- return null;
180
- });
181
- let opIdx = 0;
182
- while (opIdx < operations.length) {
183
- const op = operations[opIdx];
184
- const lazyOp = lazyOps[opIdx];
185
- if (!lazyOp) {
186
- ret = op(ret);
187
- opIdx++;
188
- continue;
189
- }
190
- const lazySeq = [];
191
- for (let j = opIdx; j < operations.length; j++) {
192
- if (lazyOps[j]) {
193
- lazySeq.push(lazyOps[j]);
194
- if (lazyOps[j].single) {
195
- break;
196
- }
197
- } else {
198
- break;
199
- }
200
- }
201
- const acc = [];
202
- for (const item of ret) {
203
- if (_processItem({ item, acc, lazySeq })) {
204
- break;
205
- }
206
- }
207
- const lastLazySeq = lazySeq[lazySeq.length - 1];
208
- if (lastLazySeq.single) {
209
- ret = acc[0];
210
- } else {
211
- ret = acc;
212
- }
213
- opIdx += lazySeq.length;
214
- }
215
- return ret;
216
- }
217
- function _processItem({
218
- item,
219
- lazySeq,
220
- acc
221
- }) {
222
- if (lazySeq.length === 0) {
223
- acc.push(item);
224
- return false;
225
- }
226
- let lazyResult = { done: false, hasNext: false };
227
- let isDone = false;
228
- for (let i = 0; i < lazySeq.length; i++) {
229
- const lazyFn = lazySeq[i];
230
- const indexed = lazyFn.indexed;
231
- const index = lazyFn.index;
232
- const items = lazyFn.items;
233
- items.push(item);
234
- lazyResult = indexed ? lazyFn(item, index, items) : lazyFn(item);
235
- lazyFn.index++;
236
- if (lazyResult.hasNext) {
237
- if (lazyResult.hasMany) {
238
- const nextValues = lazyResult.next;
239
- for (const subItem of nextValues) {
240
- const subResult = _processItem({
241
- item: subItem,
242
- acc,
243
- lazySeq: lazySeq.slice(i + 1)
244
- });
245
- if (subResult) {
246
- return true;
247
- }
248
- }
249
- return false;
250
- } else {
251
- item = lazyResult.next;
252
- }
253
- }
254
- if (!lazyResult.hasNext) {
255
- break;
256
- }
257
- if (lazyResult.done) {
258
- isDone = true;
259
- }
260
- }
261
- if (lazyResult.hasNext) {
262
- acc.push(item);
263
- }
264
- if (isDone) {
265
- return true;
266
- }
267
- return false;
268
- }
269
-
270
- // src/function/create-pipe.ts
271
- function createPipe(...operations) {
272
- return (value) => pipe(value, ...operations);
273
- }
274
-
275
- // src/function/identity.ts
276
- function identity(value) {
277
- return value;
278
- }
279
-
280
- // src/function/noop.ts
281
- function noop() {
282
- return void 0;
283
- }
284
-
285
- // src/function/once.ts
286
- function once(fn) {
287
- let called = false;
288
- let ret;
289
- return () => {
290
- if (!called) {
291
- ret = fn();
292
- called = true;
293
- }
294
- return ret;
295
- };
296
- }
297
-
298
189
  // src/function/purry.ts
299
190
  function purry(fn, args, lazy) {
300
191
  const diff = fn.length - args.length;
@@ -313,13 +204,6 @@ function purry(fn, args, lazy) {
313
204
  throw new Error("Wrong number of arguments");
314
205
  }
315
206
 
316
- // src/function/sleep.ts
317
- function sleep(timeout) {
318
- return new Promise((resolve) => {
319
- setTimeout(resolve, timeout);
320
- });
321
- }
322
-
323
207
  // src/array/all-pass.ts
324
208
  function allPass(...args) {
325
209
  return purry(_allPass, args);
@@ -350,98 +234,6 @@ function _chunk(array, size) {
350
234
  return ret;
351
235
  }
352
236
 
353
- // src/guard/is-array.ts
354
- function isArray(data) {
355
- return Array.isArray(data);
356
- }
357
-
358
- // src/guard/is-boolean.ts
359
- function isBoolean(data) {
360
- return typeof data === "boolean";
361
- }
362
-
363
- // src/guard/is-date.ts
364
- function isDate(data) {
365
- return data instanceof Date;
366
- }
367
-
368
- // src/guard/is-defined.ts
369
- function isDefined(data) {
370
- return typeof data !== "undefined" && data !== null;
371
- }
372
- ((isDefined2) => {
373
- function strict(data) {
374
- return data !== void 0;
375
- }
376
- isDefined2.strict = strict;
377
- })(isDefined || (isDefined = {}));
378
-
379
- // src/base.ts
380
- function toString(value) {
381
- return Object.prototype.toString.call(value);
382
- }
383
-
384
- // src/guard/is-object.ts
385
- function isObject(data) {
386
- return toString(data) === "[object Object]";
387
- }
388
-
389
- // src/guard/is-string.ts
390
- function isString(data) {
391
- return typeof data === "string";
392
- }
393
-
394
- // src/guard/is-empty.ts
395
- function isEmpty(data) {
396
- if (isArray(data) || isString(data)) {
397
- return data.length === 0;
398
- }
399
- if (isObject(data)) {
400
- for (const _ in data) {
401
- return false;
402
- }
403
- return !(data instanceof RegExp);
404
- }
405
- return false;
406
- }
407
-
408
- // src/guard/is-error.ts
409
- function isError(data) {
410
- return data instanceof Error;
411
- }
412
-
413
- // src/guard/is-function.ts
414
- function isFunction(data) {
415
- return typeof data === "function";
416
- }
417
-
418
- // src/guard/is-nil.ts
419
- function isNil(data) {
420
- return data == null;
421
- }
422
-
423
- // src/guard/is-non-null.ts
424
- function isNonNull(data) {
425
- return data !== null;
426
- }
427
-
428
- // src/guard/is-not.ts
429
- function isNot(predicate) {
430
- return (data) => {
431
- return !predicate(data);
432
- };
433
- }
434
-
435
- // src/guard/is-number.ts
436
- function isNumber(data) {
437
- return typeof data === "number" && !Number.isNaN(data);
438
- }
439
-
440
- // src/guard/is-promise.ts
441
- function isPromise(data) {
442
- return data instanceof Promise;
443
- }
444
-
445
237
  // src/guard/is-truthy.ts
446
238
  function isTruthy(data) {
447
239
  return !!data;
@@ -480,7 +272,7 @@ function countBy(...args) {
480
272
  })(countBy || (countBy = {}));
481
273
 
482
274
  // src/utils/reduce-lazy.ts
483
- function _reduceLazy(array, lazy, indexed) {
275
+ function reduceLazy(array, lazy, indexed) {
484
276
  const newArray = [];
485
277
  for (let index = 0; index < array.length; index++) {
486
278
  const item = array[index];
@@ -500,7 +292,7 @@ function differenceWith(...args) {
500
292
  }
501
293
  function _differenceWith(array, other, isEquals) {
502
294
  const lazy = differenceWith.lazy(other, isEquals);
503
- return _reduceLazy(array, lazy);
295
+ return reduceLazy(array, lazy);
504
296
  }
505
297
  ((differenceWith2) => {
506
298
  function lazy(other, isEquals) {
@@ -527,7 +319,7 @@ function difference(...args) {
527
319
  }
528
320
  function _difference(array, other) {
529
321
  const lazy = difference.lazy(other);
530
- return _reduceLazy(array, lazy);
322
+ return reduceLazy(array, lazy);
531
323
  }
532
324
  ((difference2) => {
533
325
  function lazy(other) {
@@ -566,7 +358,7 @@ function drop(...args) {
566
358
  return purry(_drop, args, drop.lazy);
567
359
  }
568
360
  function _drop(array, n) {
569
- return _reduceLazy(array, drop.lazy(n));
361
+ return reduceLazy(array, drop.lazy(n));
570
362
  }
571
363
  ((drop2) => {
572
364
  function lazy(n) {
@@ -589,26 +381,179 @@ function _drop(array, n) {
589
381
  drop2.lazy = lazy;
590
382
  })(drop || (drop = {}));
591
383
 
384
+ // src/array/has-at-least.ts
385
+ function hasAtLeast(...args) {
386
+ return purry(hasAtLeastImplementation, args);
387
+ }
388
+ function hasAtLeastImplementation(data, minimum) {
389
+ return data.length >= minimum;
390
+ }
391
+
392
+ // src/utils/swap-in-place.ts
393
+ function swapInPlace(data, i, j) {
394
+ [data[i], data[j]] = [data[j], data[i]];
395
+ }
396
+
397
+ // src/utils/heap.ts
398
+ function heapify(heap, compareFn) {
399
+ for (let i = Math.floor(heap.length / 2) - 1; i >= 0; i--) {
400
+ heapSiftDown(heap, i, compareFn);
401
+ }
402
+ }
403
+ function heapMaybeInsert(heap, compareFn, item) {
404
+ if (!hasAtLeast(heap, 1)) {
405
+ return;
406
+ }
407
+ const head = heap[0];
408
+ if (compareFn(item, head) >= 0) {
409
+ return;
410
+ }
411
+ heap[0] = item;
412
+ heapSiftDown(heap, 0, compareFn);
413
+ return head;
414
+ }
415
+ function heapSiftDown(heap, index, compareFn) {
416
+ let currentIndex = index;
417
+ while (currentIndex * 2 + 1 < heap.length) {
418
+ const firstChildIndex = currentIndex * 2 + 1;
419
+ let swapIndex = compareFn(heap[currentIndex], heap[firstChildIndex]) < 0 ? firstChildIndex : currentIndex;
420
+ const secondChildIndex = firstChildIndex + 1;
421
+ if (secondChildIndex < heap.length && compareFn(heap[swapIndex], heap[secondChildIndex]) < 0) {
422
+ swapIndex = secondChildIndex;
423
+ }
424
+ if (swapIndex === currentIndex) {
425
+ return;
426
+ }
427
+ swapInPlace(heap, currentIndex, swapIndex);
428
+ currentIndex = swapIndex;
429
+ }
430
+ }
431
+
432
+ // src/utils/purry-order-rules.ts
433
+ var COMPARATORS = {
434
+ asc: (x, y) => x > y,
435
+ desc: (x, y) => x < y
436
+ };
437
+ function purryOrderRules(func, inputArgs) {
438
+ const [dataOrRule, ...rules] = Array.isArray(inputArgs) ? inputArgs : Array.from(inputArgs);
439
+ if (!isOrderRule(dataOrRule)) {
440
+ const compareFn2 = orderRuleComparer(...rules);
441
+ return func(dataOrRule, compareFn2);
442
+ }
443
+ const compareFn = orderRuleComparer(dataOrRule, ...rules);
444
+ return (data) => func(data, compareFn);
445
+ }
446
+ function purryOrderRulesWithArgument(func, inputArgs) {
447
+ const [first2, second, ...rest] = Array.from(inputArgs);
448
+ let arg;
449
+ let argRemoved;
450
+ if (isOrderRule(second)) {
451
+ arg = first2;
452
+ argRemoved = [second, ...rest];
453
+ } else {
454
+ arg = second;
455
+ argRemoved = [first2, ...rest];
456
+ }
457
+ return purryOrderRules((...args) => func(...args, arg), argRemoved);
458
+ }
459
+ function orderRuleComparer(primaryRule, secondaryRule, ...otherRules) {
460
+ const projector = typeof primaryRule === "function" ? primaryRule : primaryRule[0];
461
+ const direction = typeof primaryRule === "function" ? "asc" : primaryRule[1];
462
+ const comparator = COMPARATORS[direction];
463
+ const nextComparer = secondaryRule === void 0 ? void 0 : orderRuleComparer(secondaryRule, ...otherRules);
464
+ return (a, b) => {
465
+ const projectedA = projector(a);
466
+ const projectedB = projector(b);
467
+ if (comparator(projectedA, projectedB)) {
468
+ return 1;
469
+ }
470
+ if (comparator(projectedB, projectedA)) {
471
+ return -1;
472
+ }
473
+ return nextComparer?.(a, b) ?? 0;
474
+ };
475
+ }
476
+ function isOrderRule(x) {
477
+ if (isProjection(x)) {
478
+ return true;
479
+ }
480
+ if (typeof x !== "object" || !Array.isArray(x)) {
481
+ return false;
482
+ }
483
+ const [maybeProjection, maybeDirection, ...rest] = x;
484
+ return isProjection(maybeProjection) && maybeDirection in COMPARATORS && rest.length === 0;
485
+ }
486
+ function isProjection(x) {
487
+ return typeof x === "function" && x.length === 1;
488
+ }
489
+
490
+ // src/array/drop-first-by.ts
491
+ function dropFirstBy(...args) {
492
+ return purryOrderRulesWithArgument(dropFirstByImplementation, args);
493
+ }
494
+ function dropFirstByImplementation(data, compareFn, n) {
495
+ if (n >= data.length) {
496
+ return [];
497
+ }
498
+ if (n <= 0) {
499
+ return [...data];
500
+ }
501
+ const heap = data.slice(0, n);
502
+ heapify(heap, compareFn);
503
+ const out = [];
504
+ const rest = data.slice(n);
505
+ for (const item of rest) {
506
+ const previousHead = heapMaybeInsert(heap, compareFn, item);
507
+ out.push(previousHead ?? item);
508
+ }
509
+ return out;
510
+ }
511
+
512
+ // src/array/drop-last-while.ts
513
+ function dropLastWhile(...args) {
514
+ return purry(_dropLastWhile, args);
515
+ }
516
+ function _dropLastWhile(data, predicate) {
517
+ for (let i = data.length - 1; i >= 0; i--) {
518
+ if (!predicate(data[i])) {
519
+ return data.slice(0, i + 1);
520
+ }
521
+ }
522
+ return [];
523
+ }
524
+
525
+ // src/array/drop-while.ts
526
+ function dropWhile(...args) {
527
+ return purry(_dropWhile, args);
528
+ }
529
+ function _dropWhile(data, predicate) {
530
+ for (let i = 0; i < data.length; i++) {
531
+ if (!predicate(data[i])) {
532
+ return data.slice(i);
533
+ }
534
+ }
535
+ return [];
536
+ }
537
+
592
538
  // src/utils/to-lazy-indexed.ts
593
539
  function toLazyIndexed(fn) {
594
- fn.indexed = true;
595
- return fn;
540
+ return Object.assign(fn, { indexed: true });
596
541
  }
597
542
 
598
543
  // src/array/filter.ts
599
544
  function filter(...args) {
600
- return purry(_filter(false), args, filter.lazy);
545
+ return purry(filter_(false), args, filter.lazy);
601
546
  }
602
- function _filter(indexed) {
547
+ function filter_(indexed) {
603
548
  return (array, fn) => {
604
- return _reduceLazy(
549
+ return reduceLazy(
605
550
  array,
606
551
  indexed ? filter.lazyIndexed(fn) : filter.lazy(fn),
607
552
  indexed
608
553
  );
609
554
  };
610
555
  }
611
- function _lazy(indexed) {
556
+ function lazy_(indexed) {
612
557
  return (fn) => {
613
558
  return (value, index, array) => {
614
559
  const valid = indexed ? fn(value, index, array) : fn(value);
@@ -628,11 +573,11 @@ function _lazy(indexed) {
628
573
  }
629
574
  ((filter2) => {
630
575
  function indexed(...args) {
631
- return purry(_filter(true), args, filter2.lazyIndexed);
576
+ return purry(filter_(true), args, filter2.lazyIndexed);
632
577
  }
633
578
  filter2.indexed = indexed;
634
- filter2.lazy = _lazy(false);
635
- filter2.lazyIndexed = toLazyIndexed(_lazy(true));
579
+ filter2.lazy = lazy_(false);
580
+ filter2.lazyIndexed = toLazyIndexed(lazy_(true));
636
581
  })(filter || (filter = {}));
637
582
 
638
583
  // src/utils/to-single.ts
@@ -653,7 +598,7 @@ function _findIndex(indexed) {
653
598
  return array.findIndex((x) => fn(x));
654
599
  };
655
600
  }
656
- function _lazy2(indexed) {
601
+ function _lazy(indexed) {
657
602
  return (fn) => {
658
603
  let i = 0;
659
604
  return (value, index, array) => {
@@ -678,8 +623,8 @@ function _lazy2(indexed) {
678
623
  return purry(_findIndex(true), args, findIndex2.lazyIndexed);
679
624
  }
680
625
  findIndex2.indexed = indexed;
681
- findIndex2.lazy = toSingle(_lazy2(false));
682
- findIndex2.lazyIndexed = toSingle(toLazyIndexed(_lazy2(true)));
626
+ findIndex2.lazy = toSingle(_lazy(false));
627
+ findIndex2.lazyIndexed = toSingle(toLazyIndexed(_lazy(true)));
683
628
  })(findIndex || (findIndex = {}));
684
629
 
685
630
  // src/array/find-last-index.ts
@@ -714,6 +659,7 @@ function _findLast(indexed) {
714
659
  return array[i];
715
660
  }
716
661
  }
662
+ return void 0;
717
663
  };
718
664
  }
719
665
  ((findLast2) => {
@@ -735,7 +681,7 @@ function _find(indexed) {
735
681
  return array.find((x) => fn(x));
736
682
  };
737
683
  }
738
- function _lazy3(indexed) {
684
+ function _lazy2(indexed) {
739
685
  return (fn) => {
740
686
  return (value, index, array) => {
741
687
  const valid = indexed ? fn(value, index, array) : fn(value);
@@ -752,8 +698,8 @@ function _lazy3(indexed) {
752
698
  return purry(_find(true), args, find2.lazyIndexed);
753
699
  }
754
700
  find2.indexed = indexed;
755
- find2.lazy = toSingle(_lazy3(false));
756
- find2.lazyIndexed = toSingle(toLazyIndexed(_lazy3(true)));
701
+ find2.lazy = toSingle(_lazy2(false));
702
+ find2.lazyIndexed = toSingle(toLazyIndexed(_lazy2(true)));
757
703
  })(find || (find = {}));
758
704
 
759
705
  // src/array/first.ts
@@ -779,6 +725,24 @@ function _first([first2]) {
779
725
  })(lazy = first2.lazy || (first2.lazy = {}));
780
726
  })(first || (first = {}));
781
727
 
728
+ // src/array/first-by.ts
729
+ function firstBy(...args) {
730
+ return purryOrderRules(firstByImplementation, args);
731
+ }
732
+ function firstByImplementation(data, compareFn) {
733
+ if (!hasAtLeast(data, 2)) {
734
+ return data[0];
735
+ }
736
+ let [currentFirst] = data;
737
+ const [, ...rest] = data;
738
+ for (const item of rest) {
739
+ if (compareFn(item, currentFirst) < 0) {
740
+ currentFirst = item;
741
+ }
742
+ }
743
+ return currentFirst;
744
+ }
745
+
782
746
  // src/array/flat-map-to-obj.ts
783
747
  function flatMapToObj(...args) {
784
748
  return purry(_flatMapToObj(false), args);
@@ -806,7 +770,7 @@ function flatten(...args) {
806
770
  return purry(_flatten, args, flatten.lazy);
807
771
  }
808
772
  function _flatten(items) {
809
- return _reduceLazy(items, flatten.lazy());
773
+ return reduceLazy(items, flatten.lazy());
810
774
  }
811
775
  ((flatten2) => {
812
776
  function lazy() {
@@ -814,8 +778,8 @@ function _flatten(items) {
814
778
  if (Array.isArray(next)) {
815
779
  return {
816
780
  done: false,
817
- hasNext: true,
818
781
  hasMany: true,
782
+ hasNext: true,
819
783
  next
820
784
  };
821
785
  }
@@ -843,8 +807,8 @@ function _flatMap(array, fn) {
843
807
  if (Array.isArray(next)) {
844
808
  return {
845
809
  done: false,
846
- hasNext: true,
847
810
  hasMany: true,
811
+ hasNext: true,
848
812
  next
849
813
  };
850
814
  }
@@ -863,7 +827,7 @@ function flattenDeep(...args) {
863
827
  return purry(_flattenDeep, args, flattenDeep.lazy);
864
828
  }
865
829
  function _flattenDeep(items) {
866
- return _reduceLazy(items, flattenDeep.lazy());
830
+ return reduceLazy(items, flattenDeep.lazy());
867
831
  }
868
832
  function _flattenDeepValue(value) {
869
833
  if (!Array.isArray(value)) {
@@ -886,8 +850,8 @@ function _flattenDeepValue(value) {
886
850
  if (Array.isArray(next)) {
887
851
  return {
888
852
  done: false,
889
- hasNext: true,
890
853
  hasMany: true,
854
+ hasNext: true,
891
855
  next
892
856
  };
893
857
  }
@@ -907,14 +871,14 @@ function forEach(...args) {
907
871
  }
908
872
  function _forEach(indexed) {
909
873
  return (array, fn) => {
910
- return _reduceLazy(
874
+ return reduceLazy(
911
875
  array,
912
876
  indexed ? forEach.lazyIndexed(fn) : forEach.lazy(fn),
913
877
  indexed
914
878
  );
915
879
  };
916
880
  }
917
- function _lazy4(indexed) {
881
+ function _lazy3(indexed) {
918
882
  return (fn) => {
919
883
  return (value, index, array) => {
920
884
  if (indexed) {
@@ -935,8 +899,8 @@ function _lazy4(indexed) {
935
899
  return purry(_forEach(true), args, forEach2.lazyIndexed);
936
900
  }
937
901
  forEach2.indexed = indexed;
938
- forEach2.lazy = _lazy4(false);
939
- forEach2.lazyIndexed = toLazyIndexed(_lazy4(true));
902
+ forEach2.lazy = _lazy3(false);
903
+ forEach2.lazyIndexed = toLazyIndexed(_lazy3(true));
940
904
  })(forEach || (forEach = {}));
941
905
 
942
906
  // src/array/group-by.ts
@@ -950,10 +914,12 @@ function _groupBy(indexed) {
950
914
  const key = indexed ? fn(item, index, array) : fn(item);
951
915
  if (key !== void 0) {
952
916
  const actualKey = String(key);
953
- if (!ret[actualKey]) {
954
- ret[actualKey] = [];
917
+ let items = ret[actualKey];
918
+ if (items === void 0) {
919
+ items = [];
920
+ ret[actualKey] = items;
955
921
  }
956
- ret[actualKey].push(item);
922
+ items.push(item);
957
923
  }
958
924
  });
959
925
  return ret;
@@ -994,7 +960,7 @@ function intersection(...args) {
994
960
  }
995
961
  function _intersection(array, other) {
996
962
  const lazy = intersection.lazy(other);
997
- return _reduceLazy(array, lazy);
963
+ return reduceLazy(array, lazy);
998
964
  }
999
965
  ((intersection2) => {
1000
966
  function lazy(other) {
@@ -1022,7 +988,7 @@ function intersectionWith(...args) {
1022
988
  }
1023
989
  function _intersectionWith(array, other, comparator) {
1024
990
  const lazy = intersectionWith.lazy(other, comparator);
1025
- return _reduceLazy(array, lazy);
991
+ return reduceLazy(array, lazy);
1026
992
  }
1027
993
  ((intersectionWith2) => {
1028
994
  function lazy(other, comparator) {
@@ -1073,14 +1039,14 @@ function map(...args) {
1073
1039
  }
1074
1040
  function _map(indexed) {
1075
1041
  return (array, fn) => {
1076
- return _reduceLazy(
1042
+ return reduceLazy(
1077
1043
  array,
1078
1044
  indexed ? map.lazyIndexed(fn) : map.lazy(fn),
1079
1045
  indexed
1080
1046
  );
1081
1047
  };
1082
1048
  }
1083
- function _lazy5(indexed) {
1049
+ function _lazy4(indexed) {
1084
1050
  return (fn) => {
1085
1051
  return (value, index, array) => {
1086
1052
  return {
@@ -1096,8 +1062,8 @@ function _lazy5(indexed) {
1096
1062
  return purry(_map(true), args, map2.lazyIndexed);
1097
1063
  }
1098
1064
  map2.indexed = indexed;
1099
- map2.lazy = _lazy5(false);
1100
- map2.lazyIndexed = toLazyIndexed(_lazy5(true));
1065
+ map2.lazy = _lazy4(false);
1066
+ map2.lazyIndexed = toLazyIndexed(_lazy4(true));
1101
1067
  map2.strict = map2;
1102
1068
  })(map || (map = {}));
1103
1069
 
@@ -1107,11 +1073,14 @@ function mapToObj(...args) {
1107
1073
  }
1108
1074
  function _mapToObj(indexed) {
1109
1075
  return (array, fn) => {
1110
- return array.reduce((result, element, index) => {
1111
- const [key, value] = indexed ? fn(element, index, array) : fn(element);
1112
- result[key] = value;
1113
- return result;
1114
- }, {});
1076
+ return array.reduce(
1077
+ (result, element, index) => {
1078
+ const [key, value] = indexed ? fn(element, index, array) : fn(element);
1079
+ result[key] = value;
1080
+ return result;
1081
+ },
1082
+ {}
1083
+ );
1115
1084
  };
1116
1085
  }
1117
1086
  ((mapToObj2) => {
@@ -1199,8 +1168,70 @@ function minBy(...args) {
1199
1168
  minBy2.indexed = indexed;
1200
1169
  })(minBy || (minBy = {}));
1201
1170
 
1171
+ // src/utils/quick-select.ts
1172
+ function quickSelect(data, index, compareFn) {
1173
+ return index < 0 || index >= data.length ? void 0 : quickSelectImplementation(
1174
+ // We need to clone the array because quickSelect mutates it in-place.
1175
+ [...data],
1176
+ 0,
1177
+ data.length - 1,
1178
+ index,
1179
+ compareFn
1180
+ );
1181
+ }
1182
+ function quickSelectImplementation(data, left, right, index, compareFn) {
1183
+ if (left === right) {
1184
+ return data[left];
1185
+ }
1186
+ const pivotIndex = partition(data, left, right, compareFn);
1187
+ return index === pivotIndex ? data[index] : quickSelectImplementation(
1188
+ data,
1189
+ // We continue by recursing into the partition where index would be
1190
+ index < pivotIndex ? left : pivotIndex + 1,
1191
+ index < pivotIndex ? pivotIndex - 1 : right,
1192
+ index,
1193
+ compareFn
1194
+ );
1195
+ }
1196
+ function partition(data, left, right, compareFn) {
1197
+ const pivot = data[right];
1198
+ let i = left;
1199
+ for (let j = left; j < right; j++) {
1200
+ if (compareFn(data[j], pivot) < 0) {
1201
+ swapInPlace(data, i, j);
1202
+ i++;
1203
+ }
1204
+ }
1205
+ swapInPlace(data, i, right);
1206
+ return i;
1207
+ }
1208
+
1209
+ // src/array/nth-by.ts
1210
+ function nthBy(...args) {
1211
+ return purryOrderRulesWithArgument(nthByImplementation, args);
1212
+ }
1213
+ function nthByImplementation(data, compareFn, index) {
1214
+ return quickSelect(
1215
+ data,
1216
+ // Allow negative indices gracefully
1217
+ index >= 0 ? index : data.length + index,
1218
+ compareFn
1219
+ );
1220
+ }
1221
+
1222
+ // src/array/only.ts
1223
+ function only(...args) {
1224
+ return purry(_only, args);
1225
+ }
1226
+ function _only(array) {
1227
+ if (array.length === 1) {
1228
+ return array[0];
1229
+ }
1230
+ return void 0;
1231
+ }
1232
+
1202
1233
  // src/array/partition.ts
1203
- function partition(...args) {
1234
+ function partition2(...args) {
1204
1235
  return purry(_partition(false), args);
1205
1236
  }
1206
1237
  function _partition(indexed) {
@@ -1213,12 +1244,12 @@ function _partition(indexed) {
1213
1244
  return ret;
1214
1245
  };
1215
1246
  }
1216
- ((partition2) => {
1247
+ ((partition3) => {
1217
1248
  function indexed(...args) {
1218
1249
  return purry(_partition(true), args);
1219
1250
  }
1220
- partition2.indexed = indexed;
1221
- })(partition || (partition = {}));
1251
+ partition3.indexed = indexed;
1252
+ })(partition2 || (partition2 = {}));
1222
1253
 
1223
1254
  // src/array/range.ts
1224
1255
  function range(...args) {
@@ -1232,6 +1263,20 @@ function _range(start, end) {
1232
1263
  return ret;
1233
1264
  }
1234
1265
 
1266
+ // src/array/rank-by.ts
1267
+ function rankBy(...args) {
1268
+ return purryOrderRulesWithArgument(rankByImplementation, args);
1269
+ }
1270
+ function rankByImplementation(data, compareFn, targetItem) {
1271
+ let rank = 0;
1272
+ for (const item of data) {
1273
+ if (compareFn(targetItem, item) > 0) {
1274
+ rank++;
1275
+ }
1276
+ }
1277
+ return rank;
1278
+ }
1279
+
1235
1280
  // src/array/reduce.ts
1236
1281
  function reduce(...args) {
1237
1282
  return purry(_reduce(false), args);
@@ -1257,14 +1302,14 @@ function reject(...args) {
1257
1302
  }
1258
1303
  function _reject(indexed) {
1259
1304
  return (array, fn) => {
1260
- return _reduceLazy(
1305
+ return reduceLazy(
1261
1306
  array,
1262
1307
  indexed ? reject.lazyIndexed(fn) : reject.lazy(fn),
1263
1308
  indexed
1264
1309
  );
1265
1310
  };
1266
1311
  }
1267
- function _lazy6(indexed) {
1312
+ function _lazy5(indexed) {
1268
1313
  return (fn) => {
1269
1314
  return (value, index, array) => {
1270
1315
  const valid = indexed ? fn(value, index, array) : fn(value);
@@ -1287,8 +1332,8 @@ function _lazy6(indexed) {
1287
1332
  return purry(_reject(true), args, reject2.lazyIndexed);
1288
1333
  }
1289
1334
  reject2.indexed = indexed;
1290
- reject2.lazy = _lazy6(false);
1291
- reject2.lazyIndexed = toLazyIndexed(_lazy6(true));
1335
+ reject2.lazy = _lazy5(false);
1336
+ reject2.lazyIndexed = toLazyIndexed(_lazy5(true));
1292
1337
  })(reject || (reject = {}));
1293
1338
 
1294
1339
  // src/array/reverse.ts
@@ -1400,6 +1445,16 @@ function comparer(primaryRule, secondaryRule, ...otherRules) {
1400
1445
  sortBy2.strict = sortBy2;
1401
1446
  })(sortBy || (sortBy = {}));
1402
1447
 
1448
+ // src/array/splice.ts
1449
+ function splice(...args) {
1450
+ return purry(_splice, args);
1451
+ }
1452
+ function _splice(items, start, deleteCount, replacement) {
1453
+ const result = [...items];
1454
+ result.splice(start, deleteCount, ...replacement);
1455
+ return result;
1456
+ }
1457
+
1403
1458
  // src/array/split-at.ts
1404
1459
  function splitAt(...args) {
1405
1460
  return purry(_splitAt, args);
@@ -1473,185 +1528,606 @@ function _swapString(item, index1, index2) {
1473
1528
  return result.join("");
1474
1529
  }
1475
1530
 
1476
- // src/array/take.ts
1477
- function take(...args) {
1478
- return purry(_take, args, take.lazy);
1531
+ // src/array/take.ts
1532
+ function take(...args) {
1533
+ return purry(_take, args, take.lazy);
1534
+ }
1535
+ function _take(array, n) {
1536
+ return reduceLazy(array, take.lazy(n));
1537
+ }
1538
+ ((take2) => {
1539
+ function lazy(n) {
1540
+ return (value) => {
1541
+ if (n === 0) {
1542
+ return {
1543
+ done: true,
1544
+ hasNext: false
1545
+ };
1546
+ }
1547
+ n--;
1548
+ if (n === 0) {
1549
+ return {
1550
+ done: true,
1551
+ hasNext: true,
1552
+ next: value
1553
+ };
1554
+ }
1555
+ return {
1556
+ done: false,
1557
+ hasNext: true,
1558
+ next: value
1559
+ };
1560
+ };
1561
+ }
1562
+ take2.lazy = lazy;
1563
+ })(take || (take = {}));
1564
+
1565
+ // src/array/take-first-by.ts
1566
+ function takeFirstBy(...args) {
1567
+ return purryOrderRulesWithArgument(takeFirstByImplementation, args);
1568
+ }
1569
+ function takeFirstByImplementation(data, compareFn, n) {
1570
+ if (n <= 0) {
1571
+ return [];
1572
+ }
1573
+ if (n >= data.length) {
1574
+ return [...data];
1575
+ }
1576
+ const heap = data.slice(0, n);
1577
+ heapify(heap, compareFn);
1578
+ const rest = data.slice(n);
1579
+ for (const item of rest) {
1580
+ heapMaybeInsert(heap, compareFn, item);
1581
+ }
1582
+ return heap;
1583
+ }
1584
+
1585
+ // src/array/take-while.ts
1586
+ function takeWhile(...args) {
1587
+ return purry(_takeWhile, args);
1588
+ }
1589
+ function _takeWhile(array, fn) {
1590
+ const ret = [];
1591
+ for (const item of array) {
1592
+ if (!fn(item)) {
1593
+ break;
1594
+ }
1595
+ ret.push(item);
1596
+ }
1597
+ return ret;
1598
+ }
1599
+
1600
+ // src/array/uniq.ts
1601
+ function uniq(...args) {
1602
+ return purry(_uniq, args, uniq.lazy);
1603
+ }
1604
+ function _uniq(array) {
1605
+ return reduceLazy(array, uniq.lazy());
1606
+ }
1607
+ ((uniq2) => {
1608
+ function lazy() {
1609
+ const set2 = /* @__PURE__ */ new Set();
1610
+ return (value) => {
1611
+ if (set2.has(value)) {
1612
+ return {
1613
+ done: false,
1614
+ hasNext: false
1615
+ };
1616
+ }
1617
+ set2.add(value);
1618
+ return {
1619
+ done: false,
1620
+ hasNext: true,
1621
+ next: value
1622
+ };
1623
+ };
1624
+ }
1625
+ uniq2.lazy = lazy;
1626
+ })(uniq || (uniq = {}));
1627
+
1628
+ // src/array/uniq-by.ts
1629
+ function uniqBy(...args) {
1630
+ return purry(_uniqBy, args, lazyUniqBy);
1631
+ }
1632
+ function _uniqBy(array, transformer) {
1633
+ return reduceLazy(array, lazyUniqBy(transformer));
1634
+ }
1635
+ function lazyUniqBy(transformer) {
1636
+ const set2 = /* @__PURE__ */ new Set();
1637
+ return (value) => {
1638
+ const appliedItem = transformer(value);
1639
+ if (set2.has(appliedItem)) {
1640
+ return {
1641
+ done: false,
1642
+ hasNext: false
1643
+ };
1644
+ }
1645
+ set2.add(appliedItem);
1646
+ return {
1647
+ done: false,
1648
+ hasNext: true,
1649
+ next: value
1650
+ };
1651
+ };
1652
+ }
1653
+
1654
+ // src/array/uniq-with.ts
1655
+ function uniqWith(...args) {
1656
+ return purry(_uniqWith, args, uniqWith.lazy);
1657
+ }
1658
+ function _uniqWith(array, isEquals) {
1659
+ const lazy = uniqWith.lazy(isEquals);
1660
+ return reduceLazy(array, lazy, true);
1661
+ }
1662
+ function _lazy6(isEquals) {
1663
+ return (value, index, array) => {
1664
+ if (array && array.findIndex((otherValue) => isEquals(value, otherValue)) === index) {
1665
+ return {
1666
+ done: false,
1667
+ hasNext: true,
1668
+ next: value
1669
+ };
1670
+ }
1671
+ return {
1672
+ done: false,
1673
+ hasNext: false
1674
+ };
1675
+ };
1676
+ }
1677
+ ((uniqWith2) => {
1678
+ uniqWith2.lazy = toLazyIndexed(_lazy6);
1679
+ })(uniqWith || (uniqWith = {}));
1680
+
1681
+ // src/array/zip.ts
1682
+ function zip(...args) {
1683
+ return purry(_zip, args);
1684
+ }
1685
+ function _zip(first2, second) {
1686
+ const resultLength = first2.length > second.length ? second.length : first2.length;
1687
+ const result = [];
1688
+ for (let i = 0; i < resultLength; i++) {
1689
+ result.push([first2[i], second[i]]);
1690
+ }
1691
+ return result;
1692
+ }
1693
+ ((zip2) => {
1694
+ zip2.strict = zip2;
1695
+ })(zip || (zip = {}));
1696
+
1697
+ // src/array/zip-obj.ts
1698
+ function zipObj(...args) {
1699
+ return purry(_zipObj, args);
1700
+ }
1701
+ function _zipObj(first2, second) {
1702
+ const resultLength = first2.length > second.length ? second.length : first2.length;
1703
+ const result = {};
1704
+ for (let i = 0; i < resultLength; i++) {
1705
+ result[first2[i]] = second[i];
1706
+ }
1707
+ return result;
1708
+ }
1709
+
1710
+ // src/array/zip-with.ts
1711
+ function zipWith(arg0, arg1, arg2) {
1712
+ if (typeof arg0 === "function") {
1713
+ return arg1 === void 0 ? (f, s) => _zipWith(f, s, arg0) : (f) => _zipWith(f, arg1, arg0);
1714
+ }
1715
+ if (arg1 === void 0 || arg2 === void 0) {
1716
+ throw new Error("zipWith: Missing arguments in dataFirst function call");
1717
+ }
1718
+ return _zipWith(arg0, arg1, arg2);
1719
+ }
1720
+ function _zipWith(first2, second, fn) {
1721
+ const resultLength = first2.length > second.length ? second.length : first2.length;
1722
+ const result = [];
1723
+ for (let i = 0; i < resultLength; i++) {
1724
+ result.push(fn(first2[i], second[i]));
1725
+ }
1726
+ return result;
1727
+ }
1728
+
1729
+ // src/utils/purry-on.ts
1730
+ function purryOn(isArg, implementation, args) {
1731
+ const callArgs = Array.from(args);
1732
+ return isArg(args[0]) ? (data) => implementation(data, ...callArgs) : implementation(...callArgs);
1733
+ }
1734
+
1735
+ // src/function/conditional.ts
1736
+ function conditional(...args) {
1737
+ return purryOn(isCase, conditionalImplementation, args);
1738
+ }
1739
+ function conditionalImplementation(data, ...cases) {
1740
+ for (const [when, then] of cases) {
1741
+ if (when(data)) {
1742
+ return then(data);
1743
+ }
1744
+ }
1745
+ throw new Error("conditional: data failed for all cases");
1746
+ }
1747
+ function isCase(maybeCase) {
1748
+ if (!Array.isArray(maybeCase)) {
1749
+ return false;
1750
+ }
1751
+ const [when, then, ...rest] = maybeCase;
1752
+ return typeof when === "function" && when.length <= 1 && typeof then === "function" && then.length <= 1 && rest.length === 0;
1753
+ }
1754
+ var trivialDefaultCase = () => void 0;
1755
+ ((conditional2) => {
1756
+ function defaultCase(then = trivialDefaultCase) {
1757
+ return [() => true, then];
1758
+ }
1759
+ conditional2.defaultCase = defaultCase;
1760
+ })(conditional || (conditional = {}));
1761
+
1762
+ // src/function/pipe.ts
1763
+ function pipe(input, ...operations) {
1764
+ let output = input;
1765
+ const lazyOperations = operations.map(
1766
+ (op) => "lazy" in op ? toPipedLazy(op) : void 0
1767
+ );
1768
+ let operationIndex = 0;
1769
+ while (operationIndex < operations.length) {
1770
+ const lazyOperation = lazyOperations[operationIndex];
1771
+ if (lazyOperation === void 0 || !isIterable(output)) {
1772
+ const operation = operations[operationIndex];
1773
+ output = operation(output);
1774
+ operationIndex++;
1775
+ continue;
1776
+ }
1777
+ const lazySequence = [];
1778
+ for (let j = operationIndex; j < operations.length; j++) {
1779
+ const lazyOp = lazyOperations[j];
1780
+ if (lazyOp === void 0) {
1781
+ break;
1782
+ }
1783
+ lazySequence.push(lazyOp);
1784
+ if (lazyOp.isSingle) {
1785
+ break;
1786
+ }
1787
+ }
1788
+ const accumulator = [];
1789
+ const iterator = output[Symbol.iterator]();
1790
+ while (true) {
1791
+ const result = iterator.next();
1792
+ if (result.done ?? false) {
1793
+ break;
1794
+ }
1795
+ const shouldExitEarly = processItem_(
1796
+ result.value,
1797
+ accumulator,
1798
+ lazySequence
1799
+ );
1800
+ if (shouldExitEarly) {
1801
+ break;
1802
+ }
1803
+ }
1804
+ const { isSingle } = lazySequence[lazySequence.length - 1];
1805
+ if (isSingle) {
1806
+ output = accumulator[0];
1807
+ } else {
1808
+ output = accumulator;
1809
+ }
1810
+ operationIndex += lazySequence.length;
1811
+ }
1812
+ return output;
1813
+ }
1814
+ function processItem_(item, accumulator, lazySequence) {
1815
+ if (lazySequence.length === 0) {
1816
+ accumulator.push(item);
1817
+ return false;
1818
+ }
1819
+ let lazyResult = { done: false, hasNext: false };
1820
+ let isDone = false;
1821
+ for (let i = 0; i < lazySequence.length; i++) {
1822
+ const lazyFn = lazySequence[i];
1823
+ const { index, isIndexed, items } = lazyFn;
1824
+ items.push(item);
1825
+ lazyResult = isIndexed ? lazyFn(item, index, items) : lazyFn(item);
1826
+ lazyFn.index++;
1827
+ if (lazyResult.hasNext) {
1828
+ if (lazyResult.hasMany) {
1829
+ const nextValues = lazyResult.next;
1830
+ for (const subItem of nextValues) {
1831
+ const subResult = processItem_(
1832
+ subItem,
1833
+ accumulator,
1834
+ lazySequence.slice(i + 1)
1835
+ );
1836
+ if (subResult) {
1837
+ return true;
1838
+ }
1839
+ }
1840
+ return false;
1841
+ } else {
1842
+ item = lazyResult.next;
1843
+ }
1844
+ }
1845
+ if (!lazyResult.hasNext) {
1846
+ break;
1847
+ }
1848
+ if (lazyResult.done) {
1849
+ isDone = true;
1850
+ }
1851
+ }
1852
+ if (lazyResult.hasNext) {
1853
+ accumulator.push(item);
1854
+ }
1855
+ return isDone;
1856
+ }
1857
+ function toPipedLazy(op) {
1858
+ const { lazy, lazyArgs } = op;
1859
+ const fn = lazy(...lazyArgs ?? []);
1860
+ return Object.assign(fn, {
1861
+ index: 0,
1862
+ isIndexed: lazy.indexed,
1863
+ isSingle: lazy.single,
1864
+ items: []
1865
+ });
1866
+ }
1867
+ function isIterable(something) {
1868
+ return typeof something === "string" || typeof something === "object" && something !== null && Symbol.iterator in something;
1869
+ }
1870
+
1871
+ // src/function/create-pipe.ts
1872
+ function createPipe(...operations) {
1873
+ return (value) => pipe(value, ...operations);
1874
+ }
1875
+
1876
+ // src/function/identity.ts
1877
+ function identity(value) {
1878
+ return value;
1879
+ }
1880
+
1881
+ // src/function/noop.ts
1882
+ function noop() {
1883
+ return void 0;
1884
+ }
1885
+
1886
+ // src/function/once.ts
1887
+ function once(fn) {
1888
+ let called = false;
1889
+ let ret;
1890
+ return () => {
1891
+ if (!called) {
1892
+ ret = fn();
1893
+ called = true;
1894
+ }
1895
+ return ret;
1896
+ };
1897
+ }
1898
+
1899
+ // src/function/debounce.ts
1900
+ function debounce(func, {
1901
+ maxWaitMs,
1902
+ timing = "trailing",
1903
+ waitMs
1904
+ }) {
1905
+ if (maxWaitMs !== void 0 && waitMs !== void 0 && maxWaitMs < waitMs) {
1906
+ throw new Error(
1907
+ `debounce: maxWaitMs (${maxWaitMs}) cannot be less than waitMs (${waitMs})`
1908
+ );
1909
+ }
1910
+ let coolDownTimeoutId;
1911
+ let maxWaitTimeoutId;
1912
+ let latestCallArgs;
1913
+ let result;
1914
+ function handleDebouncedCall(args) {
1915
+ latestCallArgs = args;
1916
+ if (maxWaitMs !== void 0 && maxWaitTimeoutId === void 0) {
1917
+ maxWaitTimeoutId = setTimeout(handleInvoke, maxWaitMs);
1918
+ }
1919
+ }
1920
+ function handleInvoke() {
1921
+ if (latestCallArgs === void 0) {
1922
+ return;
1923
+ }
1924
+ if (maxWaitTimeoutId !== void 0) {
1925
+ const timeoutId = maxWaitTimeoutId;
1926
+ maxWaitTimeoutId = void 0;
1927
+ clearTimeout(timeoutId);
1928
+ }
1929
+ const args = latestCallArgs;
1930
+ latestCallArgs = void 0;
1931
+ result = func(...args);
1932
+ }
1933
+ function handleCoolDownEnd() {
1934
+ if (coolDownTimeoutId === void 0) {
1935
+ return;
1936
+ }
1937
+ const timeoutId = coolDownTimeoutId;
1938
+ coolDownTimeoutId = void 0;
1939
+ clearTimeout(timeoutId);
1940
+ if (latestCallArgs !== void 0) {
1941
+ handleInvoke();
1942
+ }
1943
+ }
1944
+ return {
1945
+ get cachedValue() {
1946
+ return result;
1947
+ },
1948
+ call: (...args) => {
1949
+ if (coolDownTimeoutId === void 0) {
1950
+ if (timing === "trailing") {
1951
+ handleDebouncedCall(args);
1952
+ } else {
1953
+ result = func(...args);
1954
+ }
1955
+ } else {
1956
+ if (timing !== "leading") {
1957
+ handleDebouncedCall(args);
1958
+ }
1959
+ const timeoutId = coolDownTimeoutId;
1960
+ coolDownTimeoutId = void 0;
1961
+ clearTimeout(timeoutId);
1962
+ }
1963
+ coolDownTimeoutId = setTimeout(
1964
+ handleCoolDownEnd,
1965
+ // If waitMs is not defined but maxWaitMs *is* it means the user is only
1966
+ // interested in the leaky-bucket nature of the debouncer which is
1967
+ // achieved by setting waitMs === maxWaitMs. If both are not defined we
1968
+ // default to 0 which would wait until the end of the execution frame.
1969
+ waitMs ?? maxWaitMs ?? 0
1970
+ );
1971
+ return result;
1972
+ },
1973
+ cancel: () => {
1974
+ if (coolDownTimeoutId !== void 0) {
1975
+ const timeoutId = coolDownTimeoutId;
1976
+ coolDownTimeoutId = void 0;
1977
+ clearTimeout(timeoutId);
1978
+ }
1979
+ if (maxWaitTimeoutId !== void 0) {
1980
+ const timeoutId = maxWaitTimeoutId;
1981
+ maxWaitTimeoutId = void 0;
1982
+ clearTimeout(timeoutId);
1983
+ }
1984
+ latestCallArgs = void 0;
1985
+ },
1986
+ flush: () => {
1987
+ handleCoolDownEnd();
1988
+ return result;
1989
+ },
1990
+ get isPending() {
1991
+ return coolDownTimeoutId !== void 0;
1992
+ }
1993
+ };
1994
+ }
1995
+
1996
+ // src/function/sleep.ts
1997
+ function sleep(timeout) {
1998
+ return new Promise((resolve) => {
1999
+ setTimeout(resolve, timeout);
2000
+ });
2001
+ }
2002
+
2003
+ // src/guard/is-array.ts
2004
+ function isArray(data) {
2005
+ return Array.isArray(data);
2006
+ }
2007
+
2008
+ // src/guard/is-boolean.ts
2009
+ function isBoolean(data) {
2010
+ return typeof data === "boolean";
2011
+ }
2012
+
2013
+ // src/guard/is-date.ts
2014
+ function isDate(data) {
2015
+ return data instanceof Date;
1479
2016
  }
1480
- function _take(array, n) {
1481
- return _reduceLazy(array, take.lazy(n));
2017
+
2018
+ // src/guard/is-defined.ts
2019
+ function isDefined(data) {
2020
+ return typeof data !== "undefined" && data !== null;
1482
2021
  }
1483
- ((take2) => {
1484
- function lazy(n) {
1485
- return (value) => {
1486
- if (n === 0) {
1487
- return {
1488
- done: true,
1489
- hasNext: false
1490
- };
1491
- }
1492
- n--;
1493
- if (n === 0) {
1494
- return {
1495
- done: true,
1496
- hasNext: true,
1497
- next: value
1498
- };
1499
- }
1500
- return {
1501
- done: false,
1502
- hasNext: true,
1503
- next: value
1504
- };
1505
- };
2022
+ ((isDefined2) => {
2023
+ function strict(data) {
2024
+ return data !== void 0;
1506
2025
  }
1507
- take2.lazy = lazy;
1508
- })(take || (take = {}));
2026
+ isDefined2.strict = strict;
2027
+ })(isDefined || (isDefined = {}));
1509
2028
 
1510
- // src/array/take-while.ts
1511
- function takeWhile(...args) {
1512
- return purry(_takeWhile, args);
2029
+ // src/guard/is-object.ts
2030
+ function isObject(data) {
2031
+ if (typeof data !== "object" || data === null) {
2032
+ return false;
2033
+ }
2034
+ const proto = Object.getPrototypeOf(data);
2035
+ return proto === null || proto === Object.prototype;
1513
2036
  }
1514
- function _takeWhile(array, fn) {
1515
- const ret = [];
1516
- for (const item of array) {
1517
- if (!fn(item)) {
1518
- break;
2037
+
2038
+ // src/guard/is-string.ts
2039
+ function isString(data) {
2040
+ return typeof data === "string";
2041
+ }
2042
+
2043
+ // src/guard/is-empty.ts
2044
+ function isEmpty(data) {
2045
+ if (isArray(data) || isString(data)) {
2046
+ return data.length === 0;
2047
+ }
2048
+ if (isObject(data)) {
2049
+ for (const _ in data) {
2050
+ return false;
1519
2051
  }
1520
- ret.push(item);
2052
+ return !(data instanceof RegExp);
1521
2053
  }
1522
- return ret;
2054
+ return false;
1523
2055
  }
1524
2056
 
1525
- // src/array/uniq.ts
1526
- function uniq(...args) {
1527
- return purry(_uniq, args, uniq.lazy);
2057
+ // src/guard/is-error.ts
2058
+ function isError(data) {
2059
+ return data instanceof Error;
1528
2060
  }
1529
- function _uniq(array) {
1530
- return _reduceLazy(array, uniq.lazy());
2061
+
2062
+ // src/guard/is-function.ts
2063
+ function isFunction(data) {
2064
+ return typeof data === "function";
1531
2065
  }
1532
- ((uniq2) => {
1533
- function lazy() {
1534
- const set2 = /* @__PURE__ */ new Set();
1535
- return (value) => {
1536
- if (set2.has(value)) {
1537
- return {
1538
- done: false,
1539
- hasNext: false
1540
- };
1541
- }
1542
- set2.add(value);
1543
- return {
1544
- done: false,
1545
- hasNext: true,
1546
- next: value
1547
- };
1548
- };
1549
- }
1550
- uniq2.lazy = lazy;
1551
- })(uniq || (uniq = {}));
1552
2066
 
1553
- // src/array/uniq-by.ts
1554
- function uniqBy(...args) {
1555
- return purry(_uniqBy, args, lazyUniqBy);
2067
+ // src/guard/is-nil.ts
2068
+ function isNil(data) {
2069
+ return data == null;
1556
2070
  }
1557
- function _uniqBy(array, transformer) {
1558
- return _reduceLazy(array, lazyUniqBy(transformer));
2071
+
2072
+ // src/guard/is-non-null.ts
2073
+ function isNonNull(data) {
2074
+ return data !== null;
1559
2075
  }
1560
- function lazyUniqBy(transformer) {
1561
- const set2 = /* @__PURE__ */ new Set();
1562
- return (value) => {
1563
- const appliedItem = transformer(value);
1564
- if (set2.has(appliedItem)) {
1565
- return {
1566
- done: false,
1567
- hasNext: false
1568
- };
1569
- }
1570
- set2.add(appliedItem);
1571
- return {
1572
- done: false,
1573
- hasNext: true,
1574
- next: value
1575
- };
2076
+
2077
+ // src/guard/is-not.ts
2078
+ function isNot(predicate) {
2079
+ return (data) => {
2080
+ return !predicate(data);
1576
2081
  };
1577
2082
  }
1578
2083
 
1579
- // src/array/uniq-with.ts
1580
- function uniqWith(...args) {
1581
- return purry(_uniqWith, args, uniqWith.lazy);
1582
- }
1583
- function _uniqWith(array, isEquals) {
1584
- const lazy = uniqWith.lazy(isEquals);
1585
- return _reduceLazy(array, lazy, true);
1586
- }
1587
- function _lazy7(isEquals) {
1588
- return (value, index, array) => {
1589
- if (array && array.findIndex((otherValue) => isEquals(value, otherValue)) === index) {
1590
- return {
1591
- done: false,
1592
- hasNext: true,
1593
- next: value
1594
- };
1595
- }
1596
- return {
1597
- done: false,
1598
- hasNext: false
1599
- };
1600
- };
2084
+ // src/guard/is-number.ts
2085
+ function isNumber(data) {
2086
+ return typeof data === "number" && !Number.isNaN(data);
1601
2087
  }
1602
- ((uniqWith2) => {
1603
- uniqWith2.lazy = toLazyIndexed(_lazy7);
1604
- })(uniqWith || (uniqWith = {}));
1605
2088
 
1606
- // src/array/zip.ts
1607
- function zip(...args) {
1608
- return purry(_zip, args);
2089
+ // src/guard/is-promise.ts
2090
+ function isPromise(data) {
2091
+ return data instanceof Promise;
1609
2092
  }
1610
- function _zip(first2, second) {
1611
- const resultLength = first2.length > second.length ? second.length : first2.length;
1612
- const result = [];
1613
- for (let i = 0; i < resultLength; i++) {
1614
- result.push([first2[i], second[i]]);
1615
- }
1616
- return result;
2093
+
2094
+ // src/guard/is-symbol.ts
2095
+ function isSymbol(data) {
2096
+ return typeof data === "symbol";
1617
2097
  }
1618
2098
 
1619
- // src/array/zip-obj.ts
1620
- function zipObj(...args) {
1621
- return purry(_zipObj, args);
2099
+ // src/number/add.ts
2100
+ function add(...args) {
2101
+ return purry(_add, args);
1622
2102
  }
1623
- function _zipObj(first2, second) {
1624
- const resultLength = first2.length > second.length ? second.length : first2.length;
1625
- const result = {};
1626
- for (let i = 0; i < resultLength; i++) {
1627
- result[first2[i]] = second[i];
1628
- }
1629
- return result;
2103
+ function _add(value, addend) {
2104
+ return value + addend;
1630
2105
  }
1631
2106
 
1632
- // src/array/zip-with.ts
1633
- function zipWith(...args) {
1634
- if (typeof args[0] === "function" && args.length === 1) {
1635
- return function(f, s) {
1636
- return _zipWith(f, s, args[0]);
1637
- };
1638
- }
1639
- if (typeof args[0] === "function" && args.length === 2) {
1640
- return function(f) {
1641
- return _zipWith(f, args[1], args[0]);
1642
- };
1643
- }
1644
- if (args.length === 3) {
1645
- return _zipWith(args[0], args[1], args[2]);
1646
- }
2107
+ // src/utils/with-precision.ts
2108
+ var MAX_PRECISION = 15;
2109
+ function withPrecision(roundingFn) {
2110
+ return (value, precision) => {
2111
+ if (precision === 0) {
2112
+ return roundingFn(value);
2113
+ }
2114
+ if (!Number.isInteger(precision)) {
2115
+ throw new TypeError(`precision must be an integer: ${precision}`);
2116
+ }
2117
+ if (precision > MAX_PRECISION || precision < -MAX_PRECISION) {
2118
+ throw new RangeError(`precision must be between ${-MAX_PRECISION} and ${MAX_PRECISION}`);
2119
+ }
2120
+ if (Number.isNaN(value) || !Number.isFinite(value)) {
2121
+ return roundingFn(value);
2122
+ }
2123
+ const multiplier = 10 ** precision;
2124
+ return roundingFn(value * multiplier) / multiplier;
2125
+ };
1647
2126
  }
1648
- function _zipWith(first2, second, fn) {
1649
- const resultLength = first2.length > second.length ? second.length : first2.length;
1650
- const result = [];
1651
- for (let i = 0; i < resultLength; i++) {
1652
- result.push(fn(first2[i], second[i]));
1653
- }
1654
- return result;
2127
+
2128
+ // src/number/ceil.ts
2129
+ function ceil(...args) {
2130
+ return purry(withPrecision(Math.ceil), args);
1655
2131
  }
1656
2132
 
1657
2133
  // src/number/clamp.ts
@@ -1668,6 +2144,40 @@ function _clamp(value, limits) {
1668
2144
  return value;
1669
2145
  }
1670
2146
 
2147
+ // src/number/divide.ts
2148
+ function divide(...args) {
2149
+ return purry(_divide, args);
2150
+ }
2151
+ function _divide(value, divisor) {
2152
+ return value / divisor;
2153
+ }
2154
+
2155
+ // src/number/floor.ts
2156
+ function floor(...args) {
2157
+ return purry(withPrecision(Math.floor), args);
2158
+ }
2159
+
2160
+ // src/number/multiply.ts
2161
+ function multiply(...args) {
2162
+ return purry(_multiply, args);
2163
+ }
2164
+ function _multiply(value, multiplicand) {
2165
+ return value * multiplicand;
2166
+ }
2167
+
2168
+ // src/number/round.ts
2169
+ function round(...args) {
2170
+ return purry(withPrecision(Math.round), args);
2171
+ }
2172
+
2173
+ // src/number/subtract.ts
2174
+ function subtract(...args) {
2175
+ return purry(_subtract, args);
2176
+ }
2177
+ function _subtract(value, subtrahend) {
2178
+ return value - subtrahend;
2179
+ }
2180
+
1671
2181
  // src/object/add-prop.ts
1672
2182
  function addProp(...args) {
1673
2183
  return purry(_addProp, args);
@@ -1857,32 +2367,36 @@ function keys(source) {
1857
2367
  keys2.strict = keys2;
1858
2368
  })(keys || (keys = {}));
1859
2369
 
2370
+ // src/object/to-pairs.ts
2371
+ function toPairs(...args) {
2372
+ return purry(Object.entries, args);
2373
+ }
2374
+ ((toPairs2) => {
2375
+ toPairs2.strict = toPairs2;
2376
+ })(toPairs || (toPairs = {}));
2377
+
1860
2378
  // src/object/map-keys.ts
1861
- function mapKeys(arg1, arg2) {
1862
- if (arguments.length === 1) {
1863
- return (data) => _mapKeys(data, arg1);
1864
- }
1865
- return _mapKeys(arg1, arg2);
2379
+ function mapKeys(...args) {
2380
+ return purry(_mapKeys, args);
1866
2381
  }
1867
- function _mapKeys(obj, fn) {
1868
- return Object.keys(obj).reduce((acc, key) => {
1869
- acc[fn(key, obj[key])] = obj[key];
1870
- return acc;
1871
- }, {});
2382
+ function _mapKeys(data, fn) {
2383
+ const out = {};
2384
+ for (const [key, value] of toPairs.strict(data)) {
2385
+ out[fn(key, value)] = value;
2386
+ }
2387
+ return out;
1872
2388
  }
1873
2389
 
1874
2390
  // src/object/map-values.ts
1875
- function mapValues(arg1, arg2) {
1876
- if (arguments.length === 1) {
1877
- return (data) => _mapValues(data, arg1);
1878
- }
1879
- return _mapValues(arg1, arg2);
2391
+ function mapValues(...args) {
2392
+ return purry(_mapValues, args);
1880
2393
  }
1881
- function _mapValues(obj, fn) {
1882
- return Object.keys(obj).reduce((acc, key) => {
1883
- acc[key] = fn(obj[key], key);
1884
- return acc;
1885
- }, {});
2394
+ function _mapValues(data, fn) {
2395
+ const out = {};
2396
+ for (const [key, value] of toPairs.strict(data)) {
2397
+ out[key] = fn(value, key);
2398
+ }
2399
+ return out;
1886
2400
  }
1887
2401
 
1888
2402
  // src/object/merge.ts
@@ -1894,49 +2408,40 @@ function _merge(a, b) {
1894
2408
  }
1895
2409
 
1896
2410
  // src/object/merge-deep.ts
1897
- function mergeDeep({
1898
- mergeArray = false,
1899
- original,
1900
- patch
1901
- }) {
1902
- const original_ = original;
1903
- const patch_ = patch;
1904
- if (Array.isArray(patch_)) {
1905
- if (mergeArray && Array.isArray(patch_)) {
1906
- return [...original_, ...patch_];
1907
- } else {
1908
- return [...patch_];
1909
- }
1910
- }
1911
- const output = { ...original_ };
1912
- if (isObject(original_) && isObject(patch_)) {
1913
- Object.keys(patch_).forEach((key) => {
1914
- const areBothObjects = isObject(original_[key]) && isObject(patch_[key]);
1915
- const areBothArrays = Array.isArray(original_[key]) && Array.isArray(patch_[key]);
1916
- if (areBothObjects || areBothArrays) {
1917
- output[key] = mergeDeep({
1918
- mergeArray,
1919
- original: original_[key],
1920
- patch: patch_[key]
1921
- });
1922
- } else {
1923
- Object.assign(output, { [key]: patch_[key] });
1924
- }
1925
- ;
1926
- });
2411
+ function mergeDeep(...args) {
2412
+ return purry(mergeDeepImplementation, args);
2413
+ }
2414
+ function mergeDeepImplementation(destination, source) {
2415
+ const output = { ...destination, ...source };
2416
+ for (const key in source) {
2417
+ if (!(key in destination)) {
2418
+ continue;
2419
+ }
2420
+ const destinationValue = destination[key];
2421
+ if (!isRecord(destinationValue)) {
2422
+ continue;
2423
+ }
2424
+ const sourceValue = source[key];
2425
+ if (!isRecord(sourceValue)) {
2426
+ continue;
2427
+ }
2428
+ output[key] = mergeDeepImplementation(destinationValue, sourceValue);
1927
2429
  }
1928
2430
  return output;
1929
2431
  }
2432
+ function isRecord(object) {
2433
+ return typeof object === "object" && object !== null && Object.getPrototypeOf(object) === Object.prototype;
2434
+ }
1930
2435
 
1931
2436
  // src/object/omit.ts
1932
2437
  function omit(...args) {
1933
2438
  return purry(_omit, args);
1934
2439
  }
1935
2440
  function _omit(data, propNames) {
1936
- if (propNames.length === 0) {
2441
+ if (!hasAtLeast(propNames, 1)) {
1937
2442
  return { ...data };
1938
2443
  }
1939
- if (propNames.length === 1) {
2444
+ if (!hasAtLeast(propNames, 2)) {
1940
2445
  const [propName] = propNames;
1941
2446
  const {
1942
2447
  [propName]: omitted,
@@ -1958,7 +2463,10 @@ function omitBy(...args) {
1958
2463
  return purry(_omitBy, args);
1959
2464
  }
1960
2465
  function _omitBy(object, fn) {
1961
- return Object.keys(object).reduce((acc, key) => {
2466
+ if (object === void 0 || object === null) {
2467
+ return object;
2468
+ }
2469
+ return keys.strict(object).reduce((acc, key) => {
1962
2470
  if (!fn(object[key], key)) {
1963
2471
  acc[key] = object[key];
1964
2472
  }
@@ -2005,7 +2513,7 @@ function _pickBy(object, fn) {
2005
2513
  if (object == null) {
2006
2514
  return {};
2007
2515
  }
2008
- return Object.keys(object).reduce((acc, key) => {
2516
+ return keys.strict(object).reduce((acc, key) => {
2009
2517
  if (fn(object[key], key)) {
2010
2518
  acc[key] = object[key];
2011
2519
  }
@@ -2064,17 +2572,6 @@ function _swapProps(obj, key1, key2) {
2064
2572
  };
2065
2573
  }
2066
2574
 
2067
- // src/object/to-pairs.ts
2068
- function toPairs(object) {
2069
- return Object.entries(object);
2070
- }
2071
- ((toPairs2) => {
2072
- function strict(object) {
2073
- return Object.entries(object);
2074
- }
2075
- toPairs2.strict = strict;
2076
- })(toPairs || (toPairs = {}));
2077
-
2078
2575
  // src/object/values.ts
2079
2576
  function values(source) {
2080
2577
  return Object.values(source);
@@ -2087,18 +2584,18 @@ function isUppercase(char = "") {
2087
2584
  if (RE_NUMBER_CHAR.test(char)) {
2088
2585
  return void 0;
2089
2586
  }
2090
- return char.toUpperCase() === char;
2587
+ return char !== char.toLowerCase();
2091
2588
  }
2092
- function splitByCase(string_, separators) {
2589
+ function splitByCase(str, separators) {
2093
2590
  const splitters = separators ?? STR_SPLITTERS;
2094
2591
  const parts = [];
2095
- if (!string_ || !isString(string_)) {
2592
+ if (!str || !isString(str)) {
2096
2593
  return parts;
2097
2594
  }
2098
2595
  let buff = "";
2099
2596
  let previousUpper;
2100
2597
  let previousSplitter;
2101
- for (const char of string_) {
2598
+ for (const char of str) {
2102
2599
  const isSplitter = splitters.includes(char);
2103
2600
  if (isSplitter === true) {
2104
2601
  parts.push(buff);
@@ -2115,7 +2612,7 @@ function splitByCase(string_, separators) {
2115
2612
  continue;
2116
2613
  }
2117
2614
  if (previousUpper === true && isUpper === false && buff.length > 1) {
2118
- const lastChar = buff[buff.length - 1];
2615
+ const lastChar = buff.at(-1);
2119
2616
  parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
2120
2617
  buff = lastChar + char;
2121
2618
  previousUpper = isUpper;
@@ -2129,23 +2626,33 @@ function splitByCase(string_, separators) {
2129
2626
  parts.push(buff);
2130
2627
  return parts;
2131
2628
  }
2132
- function toUpperFirst(string_) {
2133
- return !string_ ? "" : string_[0].toUpperCase() + string_.slice(1);
2629
+ function toUpperFirst(str) {
2630
+ return str ? str[0].toUpperCase() + str.slice(1) : "";
2631
+ }
2632
+ function toLowerFirst(str) {
2633
+ return str ? str[0].toLowerCase() + str.slice(1) : "";
2634
+ }
2635
+ function toPascalCase(str, opts) {
2636
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => toUpperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
2637
+ }
2638
+ function toCamelCase(str, opts) {
2639
+ return toLowerFirst(toPascalCase(str || "", opts));
2134
2640
  }
2135
- function toLowerFirst(string_) {
2136
- return !string_ ? "" : string_[0].toLowerCase() + string_.slice(1);
2641
+ function toKebabCase(str, joiner) {
2642
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
2137
2643
  }
2138
- function toPascalCase(string_) {
2139
- return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => toUpperFirst(p)).join("");
2644
+ function toSnakeCase(str) {
2645
+ return toKebabCase(str || "", "_");
2140
2646
  }
2141
- function toCamelCase(string_) {
2142
- return toLowerFirst(toPascalCase(string_ || ""));
2647
+ function toFlatCase(str) {
2648
+ return toKebabCase(str || "", "");
2143
2649
  }
2144
- function toKebabCase(string_, joiner) {
2145
- return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => p.toLowerCase()).join(joiner ?? "-");
2650
+ function toTrainCase(str, opts) {
2651
+ return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => toUpperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
2146
2652
  }
2147
- function toSnakeCase(string_) {
2148
- return toKebabCase(string_ || "", "_");
2653
+ var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
2654
+ function titleCase(str, opts) {
2655
+ return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => titleCaseExceptions.test(p) ? p.toLowerCase() : toUpperFirst(opts?.normalize ? p.toLowerCase() : p)).join(" ");
2149
2656
  }
2150
2657
 
2151
2658
  // src/string/human-readable-file-size.ts
@@ -2196,20 +2703,28 @@ var isBrowser = typeof window !== "undefined";
2196
2703
  0 && (module.exports = {
2197
2704
  KEY_CODES,
2198
2705
  _setPath,
2706
+ add,
2199
2707
  addProp,
2200
2708
  allPass,
2201
2709
  anyPass,
2710
+ ceil,
2202
2711
  chunk,
2203
2712
  clamp,
2204
2713
  clone,
2205
2714
  compact,
2206
2715
  concat,
2716
+ conditional,
2207
2717
  countBy,
2208
2718
  createPipe,
2719
+ debounce,
2209
2720
  difference,
2210
2721
  differenceWith,
2722
+ divide,
2211
2723
  drop,
2724
+ dropFirstBy,
2212
2725
  dropLast,
2726
+ dropLastWhile,
2727
+ dropWhile,
2213
2728
  equals,
2214
2729
  filter,
2215
2730
  find,
@@ -2217,14 +2732,17 @@ var isBrowser = typeof window !== "undefined";
2217
2732
  findLast,
2218
2733
  findLastIndex,
2219
2734
  first,
2735
+ firstBy,
2220
2736
  flatMap,
2221
2737
  flatMapToObj,
2222
2738
  flatten,
2223
2739
  flattenDeep,
2740
+ floor,
2224
2741
  forEach,
2225
2742
  forEachObj,
2226
2743
  fromPairs,
2227
2744
  groupBy,
2745
+ hasAtLeast,
2228
2746
  humanReadableFileSize,
2229
2747
  identity,
2230
2748
  indexBy,
@@ -2246,6 +2764,7 @@ var isBrowser = typeof window !== "undefined";
2246
2764
  isObject,
2247
2765
  isPromise,
2248
2766
  isString,
2767
+ isSymbol,
2249
2768
  isTruthy,
2250
2769
  isUppercase,
2251
2770
  join,
@@ -2262,10 +2781,13 @@ var isBrowser = typeof window !== "undefined";
2262
2781
  mergeAll,
2263
2782
  mergeDeep,
2264
2783
  minBy,
2784
+ multiply,
2265
2785
  noop,
2786
+ nthBy,
2266
2787
  omit,
2267
2788
  omitBy,
2268
2789
  once,
2790
+ only,
2269
2791
  partition,
2270
2792
  pathOr,
2271
2793
  pick,
@@ -2275,9 +2797,11 @@ var isBrowser = typeof window !== "undefined";
2275
2797
  purry,
2276
2798
  randomString,
2277
2799
  range,
2800
+ rankBy,
2278
2801
  reduce,
2279
2802
  reject,
2280
2803
  reverse,
2804
+ round,
2281
2805
  sample,
2282
2806
  set,
2283
2807
  setPath,
@@ -2286,21 +2810,27 @@ var isBrowser = typeof window !== "undefined";
2286
2810
  slugify,
2287
2811
  sort,
2288
2812
  sortBy,
2813
+ splice,
2289
2814
  splitAt,
2290
2815
  splitByCase,
2291
2816
  splitWhen,
2292
2817
  stringToPath,
2818
+ subtract,
2293
2819
  sumBy,
2294
2820
  swapIndices,
2295
2821
  swapProps,
2296
2822
  take,
2823
+ takeFirstBy,
2297
2824
  takeWhile,
2825
+ titleCase,
2298
2826
  toCamelCase,
2827
+ toFlatCase,
2299
2828
  toKebabCase,
2300
2829
  toLowerFirst,
2301
2830
  toPairs,
2302
2831
  toPascalCase,
2303
2832
  toSnakeCase,
2833
+ toTrainCase,
2304
2834
  toUpperFirst,
2305
2835
  type,
2306
2836
  uniq,