@nlozgachev/pipelined 0.31.0 → 0.32.0

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.
@@ -1,57 +1,5 @@
1
1
  import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.mjs';
2
2
 
3
- declare const _deferred: unique symbol;
4
- /**
5
- * A nominally typed, one-shot async value that supports `await` but enforces infallibility.
6
- *
7
- * Two design choices work together to make the guarantee structural rather than documentary:
8
- *
9
- * - The phantom `[_deferred]` symbol makes the type **nominal**: only values produced by
10
- * `Deferred.fromPromise` satisfy it. A plain object `{ then: ... }` does not.
11
- * - The single-parameter `.then()` **excludes rejection handlers** by construction. There is
12
- * no second argument to pass, so chaining and `.catch()` are impossible.
13
- *
14
- * This makes `Deferred<A>` the natural return type for `Task<A>`, which is guaranteed to
15
- * never reject.
16
- *
17
- * @example
18
- * ```ts
19
- * const value = await Deferred.fromPromise(Promise.resolve(42));
20
- * // value === 42
21
- * ```
22
- */
23
- type Deferred<A> = {
24
- readonly [_deferred]: A;
25
- readonly then: (onfulfilled: (value: A) => unknown) => void;
26
- };
27
- declare namespace Deferred {
28
- /**
29
- * Wraps a `Promise` into a `Deferred`, structurally excluding rejection handlers,
30
- * `.catch()`, `.finally()`, and chainable `.then()`.
31
- *
32
- * **Precondition**: `p` must never reject. If `p` rejects, the returned `Deferred` will
33
- * never resolve — `await`-ing it will hang indefinitely. Use `TaskResult.tryCatch` to
34
- * handle operations that may fail before converting to a `Deferred`.
35
- *
36
- * @example
37
- * ```ts
38
- * const d = Deferred.fromPromise(Promise.resolve("hello"));
39
- * const value = await d; // "hello"
40
- * ```
41
- */
42
- const fromPromise: <A>(p: Promise<A>) => Deferred<A>;
43
- /**
44
- * Converts a `Deferred` back into a `Promise`.
45
- *
46
- * @example
47
- * ```ts
48
- * const p = Deferred.toPromise(Deferred.fromPromise(Promise.resolve(42)));
49
- * // p is Promise<42>
50
- * ```
51
- */
52
- const toPromise: <A>(d: Deferred<A>) => Promise<A>;
53
- }
54
-
55
3
  type WithKind<K extends string> = {
56
4
  readonly kind: K;
57
5
  };
@@ -536,6 +484,223 @@ declare namespace Maybe {
536
484
  const ap: <A>(arg: Maybe<A>) => <B>(data: Maybe<(a: A) => B>) => Maybe<B>;
537
485
  }
538
486
 
487
+ declare const _deferred: unique symbol;
488
+ /**
489
+ * A nominally typed, one-shot async value that supports `await` but enforces infallibility.
490
+ *
491
+ * Two design choices work together to make the guarantee structural rather than documentary:
492
+ *
493
+ * - The phantom `[_deferred]` symbol makes the type **nominal**: only values produced by
494
+ * `Deferred.fromPromise` satisfy it. A plain object `{ then: ... }` does not.
495
+ * - The single-parameter `.then()` **excludes rejection handlers** by construction. There is
496
+ * no second argument to pass, so chaining and `.catch()` are impossible.
497
+ *
498
+ * This makes `Deferred<A>` the natural return type for `Task<A>`, which is guaranteed to
499
+ * never reject.
500
+ *
501
+ * @example
502
+ * ```ts
503
+ * const value = await Deferred.fromPromise(Promise.resolve(42));
504
+ * // value === 42
505
+ * ```
506
+ */
507
+ type Deferred<A> = {
508
+ readonly [_deferred]: A;
509
+ readonly then: (onfulfilled: (value: A) => unknown) => void;
510
+ };
511
+ declare namespace Deferred {
512
+ /**
513
+ * Wraps a `Promise` into a `Deferred`, structurally excluding rejection handlers,
514
+ * `.catch()`, `.finally()`, and chainable `.then()`.
515
+ *
516
+ * **Precondition**: `p` must never reject. If `p` rejects, the returned `Deferred` will
517
+ * never resolve — `await`-ing it will hang indefinitely. Use `TaskResult.tryCatch` to
518
+ * handle operations that may fail before converting to a `Deferred`.
519
+ *
520
+ * @example
521
+ * ```ts
522
+ * const d = Deferred.fromPromise(Promise.resolve("hello"));
523
+ * const value = await d; // "hello"
524
+ * ```
525
+ */
526
+ const fromPromise: <A>(p: Promise<A>) => Deferred<A>;
527
+ /**
528
+ * Converts a `Deferred` back into a `Promise`.
529
+ *
530
+ * @example
531
+ * ```ts
532
+ * const p = Deferred.toPromise(Deferred.fromPromise(Promise.resolve(42)));
533
+ * // p is Promise<42>
534
+ * ```
535
+ */
536
+ const toPromise: <A>(d: Deferred<A>) => Promise<A>;
537
+ }
538
+
539
+ /**
540
+ * A function that checks whether two values of type `A` are equal.
541
+ * Use built-in instances (`Equality.string`, `Equality.number`, etc.) as starting points,
542
+ * then adapt them with `Equality.by` and combine them with `Equality.and`.
543
+ *
544
+ * @example
545
+ * ```ts
546
+ * type User = { id: string; name: string };
547
+ * const byId = pipe(Equality.string, Equality.by((u: User) => u.id));
548
+ *
549
+ * pipe(users, Arr.uniqWith(byId));
550
+ * ```
551
+ */
552
+ type Equality<A> = (a: A, b: A) => boolean;
553
+ declare namespace Equality {
554
+ /**
555
+ * Equality for strings. Case-sensitive.
556
+ *
557
+ * @example
558
+ * ```ts
559
+ * Equality.string("hello", "hello"); // true
560
+ * Equality.string("hello", "Hello"); // false
561
+ * ```
562
+ */
563
+ const string: Equality<string>;
564
+ /**
565
+ * Equality for numbers. Uses strict equality.
566
+ *
567
+ * @example
568
+ * ```ts
569
+ * Equality.number(42, 42); // true
570
+ * ```
571
+ */
572
+ const number: Equality<number>;
573
+ /**
574
+ * Equality for booleans.
575
+ *
576
+ * @example
577
+ * ```ts
578
+ * Equality.boolean(true, true); // true
579
+ * ```
580
+ */
581
+ const boolean: Equality<boolean>;
582
+ /**
583
+ * Equality for `Date` values. Compares by numeric time value.
584
+ *
585
+ * @example
586
+ * ```ts
587
+ * Equality.date(new Date("2024-01-01"), new Date("2024-01-01")); // true
588
+ * ```
589
+ */
590
+ const date: Equality<Date>;
591
+ /**
592
+ * Lifts an element equality into an array equality. Two arrays are equal if they have the
593
+ * same length and every element pair is equal under `eq`.
594
+ *
595
+ * @example
596
+ * ```ts
597
+ * Equality.array(Equality.number)([1, 2, 3], [1, 2, 3]); // true
598
+ * ```
599
+ */
600
+ const array: <A>(eq: Equality<A>) => Equality<readonly A[]>;
601
+ /**
602
+ * Adapts an equality for type `A` into an equality for type `B` by extracting a field.
603
+ * Read as "equality by this field": `pipe(Equality.string, Equality.by(u => u.name))`.
604
+ *
605
+ * @example
606
+ * ```ts
607
+ * type Product = { id: string; price: number };
608
+ * const byId = pipe(Equality.string, Equality.by((p: Product) => p.id));
609
+ * byId({ id: "p1", price: 9 }, { id: "p1", price: 12 }); // true
610
+ * ```
611
+ */
612
+ const by: <A, B>(f: (b: B) => A) => (eq: Equality<A>) => Equality<B>;
613
+ /**
614
+ * Combines two equalities with logical AND. Both must pass for two values to be considered equal.
615
+ * Data-last: the first equality is the data being piped.
616
+ *
617
+ * @example
618
+ * ```ts
619
+ * const exact = pipe(byName, Equality.and(byRole));
620
+ * exact(userA, userB); // true only if name AND role match
621
+ * ```
622
+ */
623
+ const and: <A>(eq2: Equality<A>) => (eq1: Equality<A>) => Equality<A>;
624
+ }
625
+
626
+ /**
627
+ * A function that orders two values of type `A`. Returns a negative number when `a` comes before
628
+ * `b`, a positive number when `a` comes after `b`, and `0` when they are equal.
629
+ *
630
+ * Compatible with `Array.prototype.sort` and `Arr.sortWith`.
631
+ *
632
+ * @example
633
+ * ```ts
634
+ * type Employee = { name: string; salary: number };
635
+ *
636
+ * const byName = pipe(Ordering.string, Ordering.by((e: Employee) => e.name));
637
+ * const bySalary = pipe(Ordering.number, Ordering.by((e: Employee) => e.salary));
638
+ *
639
+ * pipe(employees, Arr.sortWith(pipe(byName, Ordering.thenBy(bySalary))));
640
+ * ```
641
+ */
642
+ type Ordering<A> = (a: A, b: A) => number;
643
+ declare namespace Ordering {
644
+ /**
645
+ * Alphabetical ordering for strings.
646
+ *
647
+ * @example
648
+ * ```ts
649
+ * Ordering.string("apple", "banana"); // negative
650
+ * ```
651
+ */
652
+ const string: Ordering<string>;
653
+ /**
654
+ * Numeric ordering. Equivalent to `(a, b) => a - b`.
655
+ *
656
+ * @example
657
+ * ```ts
658
+ * pipe([3, 1, 2], Arr.sortWith(Ordering.number)); // [1, 2, 3]
659
+ * ```
660
+ */
661
+ const number: Ordering<number>;
662
+ /**
663
+ * Ordering for `Date` values by numeric time value.
664
+ *
665
+ * @example
666
+ * ```ts
667
+ * pipe(dates, Arr.sortWith(Ordering.date)); // earliest first
668
+ * ```
669
+ */
670
+ const date: Ordering<Date>;
671
+ /**
672
+ * Flips the direction of an ordering.
673
+ *
674
+ * @example
675
+ * ```ts
676
+ * pipe([3, 1, 2], Arr.sortWith(Ordering.reverse(Ordering.number))); // [3, 2, 1]
677
+ * ```
678
+ */
679
+ const reverse: <A>(ord: Ordering<A>) => Ordering<A>;
680
+ /**
681
+ * Chains two orderings: the second is used only when the first returns `0`.
682
+ * Data-last: the first ordering is the data being piped.
683
+ *
684
+ * @example
685
+ * ```ts
686
+ * const byDeptThenSalary = pipe(byDept, Ordering.thenBy(bySalary));
687
+ * ```
688
+ */
689
+ const thenBy: <A>(ord2: Ordering<A>) => (ord1: Ordering<A>) => Ordering<A>;
690
+ /**
691
+ * Adapts an ordering for type `A` into an ordering for type `B` by extracting a field.
692
+ * Read as "ordering by this field": `pipe(Ordering.number, Ordering.by(p => p.price))`.
693
+ *
694
+ * @example
695
+ * ```ts
696
+ * type Product = { name: string; price: number };
697
+ * const byPrice = pipe(Ordering.number, Ordering.by((p: Product) => p.price));
698
+ * pipe(products, Arr.sortWith(byPrice));
699
+ * ```
700
+ */
701
+ const by: <A, B>(f: (b: B) => A) => (ord: Ordering<A>) => Ordering<B>;
702
+ }
703
+
539
704
  /**
540
705
  * A lazy async computation that always resolves.
541
706
  *
@@ -812,4 +977,4 @@ declare namespace Task {
812
977
  const run: (signal?: AbortSignal) => <A>(task: Task<A>) => Promise<A>;
813
978
  }
814
979
 
815
- export { Deferred as D, type Error as E, Maybe as M, type None as N, type Ok as O, Result as R, type Some as S, Task as T, type WithValue as W, type WithLog as a, type WithKind as b, type WithError as c, type RetryOptions as d, type TimeoutOptions as e, type WithTimeout as f, type WithMinInterval as g, type WithCooldown as h, type WithConcurrency as i, type WithSize as j, type WithMs as k, type WithN as l, type WithErrors as m, type WithFirst as n, type WithSecond as o };
980
+ export { Deferred as D, Equality as E, Maybe as M, type None as N, type Ok as O, Result as R, type Some as S, Task as T, type WithValue as W, type Error as a, Ordering as b, type WithLog as c, type WithKind as d, type WithError as e, type RetryOptions as f, type TimeoutOptions as g, type WithTimeout as h, type WithMinInterval as i, type WithCooldown as j, type WithConcurrency as k, type WithSize as l, type WithMs as m, type WithN as n, type WithErrors as o, type WithFirst as p, type WithSecond as q };
@@ -1,57 +1,5 @@
1
1
  import { N as NonEmptyList } from './NonEmptyList-BlGFjor5.js';
2
2
 
3
- declare const _deferred: unique symbol;
4
- /**
5
- * A nominally typed, one-shot async value that supports `await` but enforces infallibility.
6
- *
7
- * Two design choices work together to make the guarantee structural rather than documentary:
8
- *
9
- * - The phantom `[_deferred]` symbol makes the type **nominal**: only values produced by
10
- * `Deferred.fromPromise` satisfy it. A plain object `{ then: ... }` does not.
11
- * - The single-parameter `.then()` **excludes rejection handlers** by construction. There is
12
- * no second argument to pass, so chaining and `.catch()` are impossible.
13
- *
14
- * This makes `Deferred<A>` the natural return type for `Task<A>`, which is guaranteed to
15
- * never reject.
16
- *
17
- * @example
18
- * ```ts
19
- * const value = await Deferred.fromPromise(Promise.resolve(42));
20
- * // value === 42
21
- * ```
22
- */
23
- type Deferred<A> = {
24
- readonly [_deferred]: A;
25
- readonly then: (onfulfilled: (value: A) => unknown) => void;
26
- };
27
- declare namespace Deferred {
28
- /**
29
- * Wraps a `Promise` into a `Deferred`, structurally excluding rejection handlers,
30
- * `.catch()`, `.finally()`, and chainable `.then()`.
31
- *
32
- * **Precondition**: `p` must never reject. If `p` rejects, the returned `Deferred` will
33
- * never resolve — `await`-ing it will hang indefinitely. Use `TaskResult.tryCatch` to
34
- * handle operations that may fail before converting to a `Deferred`.
35
- *
36
- * @example
37
- * ```ts
38
- * const d = Deferred.fromPromise(Promise.resolve("hello"));
39
- * const value = await d; // "hello"
40
- * ```
41
- */
42
- const fromPromise: <A>(p: Promise<A>) => Deferred<A>;
43
- /**
44
- * Converts a `Deferred` back into a `Promise`.
45
- *
46
- * @example
47
- * ```ts
48
- * const p = Deferred.toPromise(Deferred.fromPromise(Promise.resolve(42)));
49
- * // p is Promise<42>
50
- * ```
51
- */
52
- const toPromise: <A>(d: Deferred<A>) => Promise<A>;
53
- }
54
-
55
3
  type WithKind<K extends string> = {
56
4
  readonly kind: K;
57
5
  };
@@ -536,6 +484,223 @@ declare namespace Maybe {
536
484
  const ap: <A>(arg: Maybe<A>) => <B>(data: Maybe<(a: A) => B>) => Maybe<B>;
537
485
  }
538
486
 
487
+ declare const _deferred: unique symbol;
488
+ /**
489
+ * A nominally typed, one-shot async value that supports `await` but enforces infallibility.
490
+ *
491
+ * Two design choices work together to make the guarantee structural rather than documentary:
492
+ *
493
+ * - The phantom `[_deferred]` symbol makes the type **nominal**: only values produced by
494
+ * `Deferred.fromPromise` satisfy it. A plain object `{ then: ... }` does not.
495
+ * - The single-parameter `.then()` **excludes rejection handlers** by construction. There is
496
+ * no second argument to pass, so chaining and `.catch()` are impossible.
497
+ *
498
+ * This makes `Deferred<A>` the natural return type for `Task<A>`, which is guaranteed to
499
+ * never reject.
500
+ *
501
+ * @example
502
+ * ```ts
503
+ * const value = await Deferred.fromPromise(Promise.resolve(42));
504
+ * // value === 42
505
+ * ```
506
+ */
507
+ type Deferred<A> = {
508
+ readonly [_deferred]: A;
509
+ readonly then: (onfulfilled: (value: A) => unknown) => void;
510
+ };
511
+ declare namespace Deferred {
512
+ /**
513
+ * Wraps a `Promise` into a `Deferred`, structurally excluding rejection handlers,
514
+ * `.catch()`, `.finally()`, and chainable `.then()`.
515
+ *
516
+ * **Precondition**: `p` must never reject. If `p` rejects, the returned `Deferred` will
517
+ * never resolve — `await`-ing it will hang indefinitely. Use `TaskResult.tryCatch` to
518
+ * handle operations that may fail before converting to a `Deferred`.
519
+ *
520
+ * @example
521
+ * ```ts
522
+ * const d = Deferred.fromPromise(Promise.resolve("hello"));
523
+ * const value = await d; // "hello"
524
+ * ```
525
+ */
526
+ const fromPromise: <A>(p: Promise<A>) => Deferred<A>;
527
+ /**
528
+ * Converts a `Deferred` back into a `Promise`.
529
+ *
530
+ * @example
531
+ * ```ts
532
+ * const p = Deferred.toPromise(Deferred.fromPromise(Promise.resolve(42)));
533
+ * // p is Promise<42>
534
+ * ```
535
+ */
536
+ const toPromise: <A>(d: Deferred<A>) => Promise<A>;
537
+ }
538
+
539
+ /**
540
+ * A function that checks whether two values of type `A` are equal.
541
+ * Use built-in instances (`Equality.string`, `Equality.number`, etc.) as starting points,
542
+ * then adapt them with `Equality.by` and combine them with `Equality.and`.
543
+ *
544
+ * @example
545
+ * ```ts
546
+ * type User = { id: string; name: string };
547
+ * const byId = pipe(Equality.string, Equality.by((u: User) => u.id));
548
+ *
549
+ * pipe(users, Arr.uniqWith(byId));
550
+ * ```
551
+ */
552
+ type Equality<A> = (a: A, b: A) => boolean;
553
+ declare namespace Equality {
554
+ /**
555
+ * Equality for strings. Case-sensitive.
556
+ *
557
+ * @example
558
+ * ```ts
559
+ * Equality.string("hello", "hello"); // true
560
+ * Equality.string("hello", "Hello"); // false
561
+ * ```
562
+ */
563
+ const string: Equality<string>;
564
+ /**
565
+ * Equality for numbers. Uses strict equality.
566
+ *
567
+ * @example
568
+ * ```ts
569
+ * Equality.number(42, 42); // true
570
+ * ```
571
+ */
572
+ const number: Equality<number>;
573
+ /**
574
+ * Equality for booleans.
575
+ *
576
+ * @example
577
+ * ```ts
578
+ * Equality.boolean(true, true); // true
579
+ * ```
580
+ */
581
+ const boolean: Equality<boolean>;
582
+ /**
583
+ * Equality for `Date` values. Compares by numeric time value.
584
+ *
585
+ * @example
586
+ * ```ts
587
+ * Equality.date(new Date("2024-01-01"), new Date("2024-01-01")); // true
588
+ * ```
589
+ */
590
+ const date: Equality<Date>;
591
+ /**
592
+ * Lifts an element equality into an array equality. Two arrays are equal if they have the
593
+ * same length and every element pair is equal under `eq`.
594
+ *
595
+ * @example
596
+ * ```ts
597
+ * Equality.array(Equality.number)([1, 2, 3], [1, 2, 3]); // true
598
+ * ```
599
+ */
600
+ const array: <A>(eq: Equality<A>) => Equality<readonly A[]>;
601
+ /**
602
+ * Adapts an equality for type `A` into an equality for type `B` by extracting a field.
603
+ * Read as "equality by this field": `pipe(Equality.string, Equality.by(u => u.name))`.
604
+ *
605
+ * @example
606
+ * ```ts
607
+ * type Product = { id: string; price: number };
608
+ * const byId = pipe(Equality.string, Equality.by((p: Product) => p.id));
609
+ * byId({ id: "p1", price: 9 }, { id: "p1", price: 12 }); // true
610
+ * ```
611
+ */
612
+ const by: <A, B>(f: (b: B) => A) => (eq: Equality<A>) => Equality<B>;
613
+ /**
614
+ * Combines two equalities with logical AND. Both must pass for two values to be considered equal.
615
+ * Data-last: the first equality is the data being piped.
616
+ *
617
+ * @example
618
+ * ```ts
619
+ * const exact = pipe(byName, Equality.and(byRole));
620
+ * exact(userA, userB); // true only if name AND role match
621
+ * ```
622
+ */
623
+ const and: <A>(eq2: Equality<A>) => (eq1: Equality<A>) => Equality<A>;
624
+ }
625
+
626
+ /**
627
+ * A function that orders two values of type `A`. Returns a negative number when `a` comes before
628
+ * `b`, a positive number when `a` comes after `b`, and `0` when they are equal.
629
+ *
630
+ * Compatible with `Array.prototype.sort` and `Arr.sortWith`.
631
+ *
632
+ * @example
633
+ * ```ts
634
+ * type Employee = { name: string; salary: number };
635
+ *
636
+ * const byName = pipe(Ordering.string, Ordering.by((e: Employee) => e.name));
637
+ * const bySalary = pipe(Ordering.number, Ordering.by((e: Employee) => e.salary));
638
+ *
639
+ * pipe(employees, Arr.sortWith(pipe(byName, Ordering.thenBy(bySalary))));
640
+ * ```
641
+ */
642
+ type Ordering<A> = (a: A, b: A) => number;
643
+ declare namespace Ordering {
644
+ /**
645
+ * Alphabetical ordering for strings.
646
+ *
647
+ * @example
648
+ * ```ts
649
+ * Ordering.string("apple", "banana"); // negative
650
+ * ```
651
+ */
652
+ const string: Ordering<string>;
653
+ /**
654
+ * Numeric ordering. Equivalent to `(a, b) => a - b`.
655
+ *
656
+ * @example
657
+ * ```ts
658
+ * pipe([3, 1, 2], Arr.sortWith(Ordering.number)); // [1, 2, 3]
659
+ * ```
660
+ */
661
+ const number: Ordering<number>;
662
+ /**
663
+ * Ordering for `Date` values by numeric time value.
664
+ *
665
+ * @example
666
+ * ```ts
667
+ * pipe(dates, Arr.sortWith(Ordering.date)); // earliest first
668
+ * ```
669
+ */
670
+ const date: Ordering<Date>;
671
+ /**
672
+ * Flips the direction of an ordering.
673
+ *
674
+ * @example
675
+ * ```ts
676
+ * pipe([3, 1, 2], Arr.sortWith(Ordering.reverse(Ordering.number))); // [3, 2, 1]
677
+ * ```
678
+ */
679
+ const reverse: <A>(ord: Ordering<A>) => Ordering<A>;
680
+ /**
681
+ * Chains two orderings: the second is used only when the first returns `0`.
682
+ * Data-last: the first ordering is the data being piped.
683
+ *
684
+ * @example
685
+ * ```ts
686
+ * const byDeptThenSalary = pipe(byDept, Ordering.thenBy(bySalary));
687
+ * ```
688
+ */
689
+ const thenBy: <A>(ord2: Ordering<A>) => (ord1: Ordering<A>) => Ordering<A>;
690
+ /**
691
+ * Adapts an ordering for type `A` into an ordering for type `B` by extracting a field.
692
+ * Read as "ordering by this field": `pipe(Ordering.number, Ordering.by(p => p.price))`.
693
+ *
694
+ * @example
695
+ * ```ts
696
+ * type Product = { name: string; price: number };
697
+ * const byPrice = pipe(Ordering.number, Ordering.by((p: Product) => p.price));
698
+ * pipe(products, Arr.sortWith(byPrice));
699
+ * ```
700
+ */
701
+ const by: <A, B>(f: (b: B) => A) => (ord: Ordering<A>) => Ordering<B>;
702
+ }
703
+
539
704
  /**
540
705
  * A lazy async computation that always resolves.
541
706
  *
@@ -812,4 +977,4 @@ declare namespace Task {
812
977
  const run: (signal?: AbortSignal) => <A>(task: Task<A>) => Promise<A>;
813
978
  }
814
979
 
815
- export { Deferred as D, type Error as E, Maybe as M, type None as N, type Ok as O, Result as R, type Some as S, Task as T, type WithValue as W, type WithLog as a, type WithKind as b, type WithError as c, type RetryOptions as d, type TimeoutOptions as e, type WithTimeout as f, type WithMinInterval as g, type WithCooldown as h, type WithConcurrency as i, type WithSize as j, type WithMs as k, type WithN as l, type WithErrors as m, type WithFirst as n, type WithSecond as o };
980
+ export { Deferred as D, Equality as E, Maybe as M, type None as N, type Ok as O, Result as R, type Some as S, Task as T, type WithValue as W, type Error as a, Ordering as b, type WithLog as c, type WithKind as d, type WithError as e, type RetryOptions as f, type TimeoutOptions as g, type WithTimeout as h, type WithMinInterval as i, type WithCooldown as j, type WithConcurrency as k, type WithSize as l, type WithMs as m, type WithN as n, type WithErrors as o, type WithFirst as p, type WithSecond as q };
@@ -3,7 +3,7 @@ import {
3
3
  Maybe,
4
4
  Result,
5
5
  Task
6
- } from "./chunk-SDGDJ7CU.mjs";
6
+ } from "./chunk-TK5ZCGP2.mjs";
7
7
  import {
8
8
  isNonEmptyList
9
9
  } from "./chunk-DBIC62UV.mjs";
@@ -89,11 +89,25 @@ var Arr;
89
89
  }
90
90
  return result;
91
91
  };
92
+ Arr2.uniqWith = (eq) => (data) => {
93
+ const result = [];
94
+ for (const a of data) {
95
+ if (!result.some((x) => eq(x, a))) {
96
+ result.push(a);
97
+ }
98
+ }
99
+ return result;
100
+ };
92
101
  Arr2.sortBy = (compare) => (data) => {
93
102
  const arr = data;
94
103
  if (typeof arr.toSorted === "function") return arr.toSorted(compare);
95
104
  return [...data].sort(compare);
96
105
  };
106
+ Arr2.sortWith = (ord) => (data) => {
107
+ const arr = data;
108
+ if (typeof arr.toSorted === "function") return arr.toSorted(ord);
109
+ return [...data].sort(ord);
110
+ };
97
111
  Arr2.zip = (other) => (data) => {
98
112
  const len = Math.min(data.length, other.length);
99
113
  const result = new Array(len);
@@ -126,7 +140,23 @@ var Arr;
126
140
  }
127
141
  return result;
128
142
  };
129
- Arr2.flatten = (data) => [].concat(...data);
143
+ Arr2.flatten = (data) => {
144
+ let totalLen = 0;
145
+ const outerLen = data.length;
146
+ for (let i = 0; i < outerLen; i++) {
147
+ totalLen += data[i].length;
148
+ }
149
+ const result = new Array(totalLen);
150
+ let idx = 0;
151
+ for (let i = 0; i < outerLen; i++) {
152
+ const chunk = data[i];
153
+ const innerLen = chunk.length;
154
+ for (let j = 0; j < innerLen; j++) {
155
+ result[idx++] = chunk[j];
156
+ }
157
+ }
158
+ return result;
159
+ };
130
160
  Arr2.flatMap = (f) => (data) => {
131
161
  const n = data.length;
132
162
  const result = [];
@@ -365,8 +395,8 @@ var Num;
365
395
  }
366
396
  return result;
367
397
  };
368
- Num2.clamp = (min, max) => (n) => Math.min(Math.max(n, min), max);
369
- Num2.between = (min, max) => (n) => n >= min && n <= max;
398
+ Num2.clamp = (min2, max2) => (n) => Math.min(Math.max(n, min2), max2);
399
+ Num2.between = (min2, max2) => (n) => n >= min2 && n <= max2;
370
400
  Num2.parse = (s) => {
371
401
  if (s.trim() === "") return Maybe.none();
372
402
  const n = Number(s);
@@ -382,6 +412,28 @@ var Num;
382
412
  Num2.floor = (n) => Math.floor(n);
383
413
  Num2.ceil = (n) => Math.ceil(n);
384
414
  Num2.remainder = (divisor) => (n) => divisor === 0 ? Maybe.none() : Maybe.some(n % divisor);
415
+ Num2.sum = (ns) => {
416
+ let result = 0;
417
+ for (let i = 0; i < ns.length; i++) result += ns[i];
418
+ return result;
419
+ };
420
+ Num2.mean = (ns) => ns.length === 0 ? Maybe.none() : Maybe.some((0, Num2.sum)(ns) / ns.length);
421
+ Num2.min = (ns) => {
422
+ if (ns.length === 0) return Maybe.none();
423
+ let [result] = ns;
424
+ for (let i = 1; i < ns.length; i++) {
425
+ if (ns[i] < result) result = ns[i];
426
+ }
427
+ return Maybe.some(result);
428
+ };
429
+ Num2.max = (ns) => {
430
+ if (ns.length === 0) return Maybe.none();
431
+ let [result] = ns;
432
+ for (let i = 1; i < ns.length; i++) {
433
+ if (ns[i] > result) result = ns[i];
434
+ }
435
+ return Maybe.some(result);
436
+ };
385
437
  })(Num || (Num = {}));
386
438
 
387
439
  // src/Utils/Rec.ts
@@ -505,6 +557,7 @@ var Str;
505
557
  Str2.endsWith = (suffix) => (s) => s.endsWith(suffix);
506
558
  Str2.toUpperCase = (s) => s.toUpperCase();
507
559
  Str2.toLowerCase = (s) => s.toLowerCase();
560
+ Str2.capitalize = (s) => s.length === 0 ? "" : s.charAt(0).toUpperCase() + s.slice(1);
508
561
  Str2.lines = (s) => s.split(/\r?\n|\r/);
509
562
  Str2.words = (s) => s.trim().split(/\s+/).filter(Boolean);
510
563
  Str2.isEmpty = (s) => s.length === 0;