functype 0.4.2 → 0.8.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.
Files changed (160) hide show
  1. package/README.md +3 -3
  2. package/dist/chunk-2I2NKDFN.mjs +1 -0
  3. package/dist/chunk-6GSI27WU.js +1 -0
  4. package/dist/chunk-AB3QRD66.js +1 -0
  5. package/dist/chunk-BSQMHA7A.js +1 -0
  6. package/dist/chunk-E6RS47F7.js +1 -0
  7. package/dist/chunk-I7TGEFK5.mjs +1 -0
  8. package/dist/chunk-JQ7HMWOT.mjs +1 -0
  9. package/dist/chunk-N3GTVYCO.js +1 -0
  10. package/dist/chunk-O7DO2OKU.mjs +1 -0
  11. package/dist/chunk-OWW7KOUW.mjs +1 -0
  12. package/dist/chunk-OXLZ6UIZ.js +1 -0
  13. package/dist/chunk-PJIXAQSQ.mjs +1 -0
  14. package/dist/chunk-Q65ZRGZH.js +1 -0
  15. package/dist/chunk-VK5GL6NM.mjs +1 -0
  16. package/dist/collections/index.d.mts +2 -2
  17. package/dist/collections/index.d.ts +2 -2
  18. package/dist/either/Either.d.mts +2 -2
  19. package/dist/either/Either.d.ts +2 -2
  20. package/dist/either/Either.js +1 -1
  21. package/dist/either/Either.mjs +1 -1
  22. package/dist/error/ParseError.d.mts +6 -2
  23. package/dist/error/ParseError.d.ts +6 -2
  24. package/dist/error/ParseError.js +1 -1
  25. package/dist/error/ParseError.mjs +1 -1
  26. package/dist/functor/index.d.mts +11 -11
  27. package/dist/functor/index.d.ts +11 -11
  28. package/dist/index-5xp8zYMn.d.mts +183 -0
  29. package/dist/index-8YakfACG.d.ts +183 -0
  30. package/dist/index.d.mts +4 -4
  31. package/dist/index.d.ts +4 -4
  32. package/dist/index.js +1 -1
  33. package/dist/index.mjs +1 -1
  34. package/dist/iterable/Seq.d.mts +2 -2
  35. package/dist/iterable/Seq.d.ts +2 -2
  36. package/dist/iterable/Seq.js +1 -1
  37. package/dist/iterable/Seq.mjs +1 -1
  38. package/dist/iterable/index.d.mts +2 -2
  39. package/dist/iterable/index.d.ts +2 -2
  40. package/dist/iterable/index.js +1 -1
  41. package/dist/iterable/index.mjs +1 -1
  42. package/dist/list/List.d.mts +2 -2
  43. package/dist/list/List.d.ts +2 -2
  44. package/dist/list/List.js +1 -1
  45. package/dist/list/List.mjs +1 -1
  46. package/dist/map/Map.d.mts +2 -2
  47. package/dist/map/Map.d.ts +2 -2
  48. package/dist/map/Map.js +1 -1
  49. package/dist/map/Map.mjs +1 -1
  50. package/dist/map/shim.js +1 -1
  51. package/dist/map/shim.mjs +1 -1
  52. package/dist/option/Option.d.mts +2 -2
  53. package/dist/option/Option.d.ts +2 -2
  54. package/dist/option/Option.js +1 -1
  55. package/dist/option/Option.mjs +1 -1
  56. package/dist/set/Set.d.mts +2 -2
  57. package/dist/set/Set.d.ts +2 -2
  58. package/dist/set/Set.js +1 -1
  59. package/dist/set/Set.mjs +1 -1
  60. package/dist/set/shim.js +1 -1
  61. package/dist/set/shim.mjs +1 -1
  62. package/dist/try/Try.d.mts +2 -2
  63. package/dist/try/Try.d.ts +2 -2
  64. package/dist/try/Try.js +1 -1
  65. package/dist/try/Try.mjs +1 -1
  66. package/dist/tuple/Tuple.d.mts +7 -15
  67. package/dist/tuple/Tuple.d.ts +7 -15
  68. package/dist/tuple/Tuple.js +1 -1
  69. package/dist/tuple/Tuple.mjs +1 -1
  70. package/dist/typeable/Typeable.d.mts +6 -0
  71. package/dist/typeable/Typeable.d.ts +6 -0
  72. package/dist/{chunk-ZTL76QDL.js → typeable/Typeable.js} +1 -1
  73. package/dist/typeable/Typeable.mjs +1 -0
  74. package/dist/util/index.d.mts +2 -2
  75. package/dist/util/index.d.ts +2 -2
  76. package/dist/util/index.js +1 -1
  77. package/dist/util/index.mjs +1 -1
  78. package/dist/util/isIterable.d.mts +1 -1
  79. package/dist/util/isIterable.d.ts +1 -1
  80. package/dist/util/isIterable.js +1 -1
  81. package/dist/util/isIterable.mjs +1 -1
  82. package/lib/collections/index.d.ts +6 -6
  83. package/lib/either/Either.d.ts +25 -29
  84. package/lib/either/index.d.ts +1 -1
  85. package/lib/error/ParseError.d.ts +6 -2
  86. package/lib/functor/index.d.ts +10 -10
  87. package/lib/index.d.ts +9 -9
  88. package/lib/iterable/Seq.d.ts +27 -24
  89. package/lib/iterable/index.d.ts +7 -7
  90. package/lib/list/List.d.ts +20 -22
  91. package/lib/list/index.d.ts +4 -3
  92. package/lib/map/Map.d.ts +15 -35
  93. package/lib/map/index.d.ts +1 -1
  94. package/lib/option/Option.d.ts +25 -40
  95. package/lib/option/index.d.ts +6 -5
  96. package/lib/set/Set.d.ts +15 -18
  97. package/lib/set/index.d.ts +1 -1
  98. package/lib/try/Try.d.ts +21 -19
  99. package/lib/try/index.d.ts +1 -1
  100. package/lib/tuple/Tuple.d.ts +6 -13
  101. package/lib/tuple/index.d.ts +5 -1
  102. package/lib/typeable/Typeable.d.ts +4 -0
  103. package/lib/util/index.d.ts +1 -1
  104. package/lib/util/isIterable.d.ts +1 -1
  105. package/package.json +9 -9
  106. package/dist/chunk-2XH6TPQK.mjs +0 -1
  107. package/dist/chunk-35UIDXTO.js +0 -1
  108. package/dist/chunk-3APFKSCC.js +0 -1
  109. package/dist/chunk-3EH27NX2.js +0 -1
  110. package/dist/chunk-3OHJLCSR.mjs +0 -0
  111. package/dist/chunk-6BEXQNLZ.js +0 -1
  112. package/dist/chunk-74TKYQJS.mjs +0 -0
  113. package/dist/chunk-BYDMB2VV.js +0 -1
  114. package/dist/chunk-CFYIJKWF.mjs +0 -1
  115. package/dist/chunk-GTO34VMN.mjs +0 -1
  116. package/dist/chunk-HC3O3O2B.mjs +0 -1
  117. package/dist/chunk-HOO2EPER.mjs +0 -1
  118. package/dist/chunk-IC6AOOR5.mjs +0 -1
  119. package/dist/chunk-JR557W27.mjs +0 -1
  120. package/dist/chunk-KY3WKBLM.mjs +0 -1
  121. package/dist/chunk-O2XFH626.js +0 -1
  122. package/dist/chunk-Q4H3PCBH.mjs +0 -0
  123. package/dist/chunk-QQAQYRPV.js +0 -1
  124. package/dist/chunk-RM3O3IPT.js +0 -1
  125. package/dist/chunk-SKJIJETA.js +0 -1
  126. package/dist/chunk-T7AA7TJX.mjs +0 -1
  127. package/dist/chunk-TYHKMGLC.mjs +0 -1
  128. package/dist/chunk-V5UFW2E4.js +0 -1
  129. package/dist/chunk-XVHCBGUW.js +0 -1
  130. package/dist/chunk-ZOH672YH.js +0 -1
  131. package/dist/either/index.d.mts +0 -4
  132. package/dist/either/index.d.ts +0 -4
  133. package/dist/either/index.js +0 -1
  134. package/dist/either/index.mjs +0 -1
  135. package/dist/index-Dbjb4MUT.d.ts +0 -232
  136. package/dist/index-UMWeD2QH.d.mts +0 -232
  137. package/dist/list/index.d.mts +0 -4
  138. package/dist/list/index.d.ts +0 -4
  139. package/dist/list/index.js +0 -1
  140. package/dist/list/index.mjs +0 -1
  141. package/dist/map/index.d.mts +0 -4
  142. package/dist/map/index.d.ts +0 -4
  143. package/dist/map/index.js +0 -1
  144. package/dist/map/index.mjs +0 -1
  145. package/dist/option/index.d.mts +0 -4
  146. package/dist/option/index.d.ts +0 -4
  147. package/dist/option/index.js +0 -1
  148. package/dist/option/index.mjs +0 -1
  149. package/dist/set/index.d.mts +0 -4
  150. package/dist/set/index.d.ts +0 -4
  151. package/dist/set/index.js +0 -1
  152. package/dist/set/index.mjs +0 -1
  153. package/dist/try/index.d.mts +0 -4
  154. package/dist/try/index.d.ts +0 -4
  155. package/dist/try/index.js +0 -1
  156. package/dist/try/index.mjs +0 -1
  157. package/dist/tuple/index.d.mts +0 -8
  158. package/dist/tuple/index.d.ts +0 -8
  159. package/dist/tuple/index.js +0 -1
  160. package/dist/tuple/index.mjs +0 -1
@@ -1,23 +1,21 @@
1
+ import { Collection } from "../collections";
1
2
  import { _Iterable_ } from "../iterable";
2
- import { Seq } from "../iterable";
3
- import { _Collection } from "../collections";
4
- import { Set } from "../set";
5
- import { _Option_ } from "../option";
6
- export interface _List_<T> extends _Iterable_<T>, ArrayLike<T> {
7
- add(item: T): _List_<T>;
8
- }
9
- export declare class List<A> extends Seq<A> implements _List_<A>, _Collection<A> {
10
- constructor(values?: Iterable<A> | _Iterable_<A>);
11
- readonly [n: number]: A;
12
- map<B>(f: (a: A) => B): List<B>;
13
- flatMap<B>(f: (a: A) => _Iterable_<B>): List<B>;
14
- remove(value: A): List<A>;
15
- contains(value: A): boolean;
16
- add(item: A): List<A>;
17
- removeAt(index: number): List<A>;
18
- get(index: number): _Option_<A>;
19
- concat(other: List<A>): List<A>;
20
- toList(): _List_<A>;
21
- toSet(): Set<A>;
22
- toString(): string;
23
- }
3
+ import { Option } from "../option/Option";
4
+ import { Set } from "../set/Set";
5
+ export type List<A> = {
6
+ add: (item: A) => List<A>;
7
+ map: <B>(f: (a: A) => B) => List<B>;
8
+ flatMap: <B>(f: (a: A) => _Iterable_<B>) => List<B>;
9
+ remove: (value: A) => List<A>;
10
+ contains: (value: A) => boolean;
11
+ removeAt: (index: number) => List<A>;
12
+ get: (index: number) => Option<A>;
13
+ concat: (other: List<A>) => List<A>;
14
+ toList: () => List<A>;
15
+ toSet: () => Set<A>;
16
+ toString: () => string;
17
+ valueOf: () => {
18
+ values: A[];
19
+ };
20
+ } & ArrayLike<A> & _Iterable_<A> & Collection<A>;
21
+ export declare const List: <A>(values?: Iterable<A> | _Iterable_<A>) => List<A>;
@@ -1,3 +1,4 @@
1
- import { List, _List_ } from "./List";
2
- declare const list: <T extends unknown>(items: T[] | undefined) => List<T>;
3
- export { list, List, _List_ };
1
+ import { Type } from "../functor";
2
+ import { List } from "./List";
3
+ declare const list: <T extends Type>(items: T[] | undefined) => List<T>;
4
+ export { list, List };
package/lib/map/Map.d.ts CHANGED
@@ -1,37 +1,17 @@
1
- import { _Tuple_, Tuple } from "../tuple";
2
- import { _Set_ } from "../set";
3
- import { _Option_ } from "../option";
4
- import { _List_ } from "../list";
5
- import { _Traversable_ } from "../index";
6
- import { _Collection } from "../collections";
7
- type SafeTraversable<K, V> = Omit<_Traversable_<_Tuple_<[K, V]>>, "map" | "flatMap">;
8
- export type _Map_<K, V> = {
9
- map<U>(f: (value: any) => U): _Map_<K, U>;
10
- flatMap<U>(f: (value: any) => _Map_<K, U>): _Map_<K, U>;
11
- get(key: K): _Option_<V>;
1
+ import { Collection } from "../collections";
2
+ import { Traversable } from "../index";
3
+ import { _Iterable_ } from "../iterable";
4
+ import { Option } from "../option/Option";
5
+ import { Tuple } from "../tuple/Tuple";
6
+ type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap">;
7
+ export type Map<K, V> = {
8
+ add(item: Tuple<[K, V]>): Map<K, V>;
9
+ remove(value: K): Map<K, V>;
10
+ map<U>(f: (value: V) => U): Map<K, U>;
11
+ flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => _Iterable_<[K2, V2]>): Map<K2, V2>;
12
+ get(key: K): Option<V>;
12
13
  getOrElse(key: K, defaultValue: V): V;
13
- orElse(key: K, alternative: _Option_<V>): _Option_<V>;
14
- } & SafeTraversable<K, V> & _Collection<_Tuple_<[K, V]>>;
15
- export declare class Map<K, V> implements _Map_<K, V> {
16
- private values;
17
- private get entries();
18
- constructor(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null);
19
- add(item: _Tuple_<[K, V]>): Map<K, V>;
20
- remove(value: _Tuple_<[K, V]>): Map<K, V>;
21
- contains(value: _Tuple_<[K, V]>): boolean;
22
- get size(): number;
23
- map<U>(f: (value: V) => U): _Map_<K, U>;
24
- flatMap<U>(f: (value: V) => _Map_<K, U>): _Map_<K, U>;
25
- reduce(f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]>;
26
- reduceRight(f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]>;
27
- foldLeft<B>(z: B): (op: (b: B, a: _Tuple_<[K, V]>) => B) => B;
28
- foldRight<B>(z: B): (op: (a: _Tuple_<[K, V]>, b: B) => B) => B;
29
- get(key: K): _Option_<V>;
30
- getOrElse(key: K, defaultValue: V): V;
31
- get isEmpty(): boolean;
32
- orElse(key: K, alternative: _Option_<V>): _Option_<V>;
33
- toList(): _List_<Tuple<[K, V]>>;
34
- toSet(): _Set_<Tuple<[K, V]>>;
35
- toString(): string;
36
- }
14
+ orElse(key: K, alternative: Option<V>): Option<V>;
15
+ } & SafeTraversable<K, V> & Collection<Tuple<[K, V]>>;
16
+ export declare const Map: <K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null) => Map<K, V>;
37
17
  export {};
@@ -1 +1 @@
1
- export { Map, _Map_ } from "./Map";
1
+ export { Map } from "./Map";
@@ -1,44 +1,29 @@
1
- import { _Functor_, Type } from "../functor";
2
- import { _Traversable_ } from "../index";
1
+ import { Functor, Type } from "../functor";
2
+ import { Traversable } from "../index";
3
3
  import { _Iterable_ } from "../iterable";
4
- export type _Option_<T extends Type> = {
4
+ import { Typeable } from "../typeable/Typeable";
5
+ export type Option<T extends Type> = {
6
+ readonly _tag: "Some" | "None";
7
+ readonly value: T | undefined;
8
+ isEmpty: boolean;
5
9
  get(): T;
6
10
  getOrElse(defaultValue: T): T;
7
- orElse(alternative: _Option_<T>): _Option_<T>;
8
- map<U extends Type>(f: (value: T) => U): _Option_<U>;
9
- flatMap<U extends Type>(f: (value: T) => _Option_<U>): _Option_<U>;
11
+ orElse(alternative: Option<T>): Option<T>;
12
+ map<U extends Type>(f: (value: T) => U): Option<U>;
13
+ flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
14
+ reduce<U>(f: (acc: U, value: T) => U): U;
15
+ reduceRight<U>(f: (acc: U, value: T) => U): U;
16
+ foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B;
17
+ foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
10
18
  toList(): _Iterable_<T>;
11
- valueOf(): Object;
12
- } & _Traversable_<T> & _Functor_<T>;
13
- export declare class Some<A extends Type> implements _Option_<A> {
14
- private value;
15
- constructor(value: A);
16
- get isEmpty(): boolean;
17
- get(): A;
18
- getOrElse(defaultValue: A): A;
19
- orElse(alternative: _Option_<A>): _Option_<A>;
20
- map<U extends Type>(f: (value: A) => U): _Option_<U>;
21
- flatMap<U extends Type>(f: (value: A) => _Option_<U>): _Option_<U>;
22
- reduce<U>(f: (acc: U, value: A) => U): U;
23
- reduceRight<U>(f: (acc: U, value: A) => U): U;
24
- foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
25
- foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
26
- toList(): _Iterable_<A>;
27
- contains(value: A): boolean;
28
- get size(): number;
29
- }
30
- export declare class None<A extends Type> implements _Option_<A> {
31
- get isEmpty(): boolean;
32
- get(): A;
33
- getOrElse(defaultValue: A): A;
34
- orElse(alternative: _Option_<A>): _Option_<A>;
35
- map<U extends Type>(f: (value: A) => U): _Option_<U>;
36
- flatMap<U extends Type>(f: (value: A) => _Option_<U>): _Option_<U>;
37
- reduce(f: (acc: A, value: A) => A): A;
38
- reduceRight(f: (b: A, a: A) => A): A;
39
- foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
40
- foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
41
- toList(): _Iterable_<A>;
42
- contains(value: A): boolean;
43
- get size(): number;
44
- }
19
+ contains(value: T): boolean;
20
+ size: number;
21
+ valueOf(): {
22
+ _tag: "Some" | "None";
23
+ value?: T;
24
+ };
25
+ toString(): string;
26
+ } & Traversable<T> & Functor<T> & Typeable<"Some" | "None">;
27
+ export declare const Some: <T extends Type>(value: T) => Option<T>;
28
+ export declare const None: <T extends Type>() => Option<T>;
29
+ export declare const Option: <T extends Type>(value: T | null | undefined) => Option<T>;
@@ -1,5 +1,6 @@
1
- import { None, _Option_, Some } from "./Option";
2
- export declare const option: <T extends unknown>(value?: T) => _Option_<T>;
3
- export declare const some: <T extends unknown>(value: T) => _Option_<T>;
4
- export declare const none: <T extends unknown>() => _Option_<T>;
5
- export { _Option_, Some, None };
1
+ import { Type } from "../functor";
2
+ import { None, Option, Some } from "./Option";
3
+ export declare const option: <T extends Type>(value?: T) => Option<T>;
4
+ export declare const some: <T extends Type>(value: T) => Option<T>;
5
+ export declare const none: <T extends Type>() => Option<T>;
6
+ export { None, Option, Some };
package/lib/set/Set.d.ts CHANGED
@@ -1,18 +1,15 @@
1
- import { _Iterable_, Seq } from "../iterable";
2
- import { _List_ } from "../list";
3
- import { _Collection } from "../collections";
4
- export type _Set_<T> = {
5
- has(value: T): boolean;
6
- } & _Iterable_<T> & _Collection<T>;
7
- export declare class Set<A> extends Seq<A> implements _Set_<A> {
8
- constructor(iterable?: Iterable<A> | _Iterable_<A>);
9
- add(value: A): Set<A>;
10
- remove(value: A): Set<A>;
11
- contains(value: A): boolean;
12
- has(value: A): boolean;
13
- map<B>(f: (a: A) => B): Set<B>;
14
- flatMap<B>(f: (a: A) => _Iterable_<B>): Set<B>;
15
- toList(): _List_<A>;
16
- toSet(): _Set_<A>;
17
- toString(): string;
18
- }
1
+ import { Collection } from "../collections";
2
+ import { _Iterable_ } from "../iterable";
3
+ import { List } from "../list/List";
4
+ export type Set<A> = {
5
+ add: (value: A) => Set<A>;
6
+ remove: (value: A) => Set<A>;
7
+ contains: (value: A) => boolean;
8
+ has: (value: A) => boolean;
9
+ map: <B>(f: (a: A) => B) => Set<B>;
10
+ flatMap: <B>(f: (a: A) => _Iterable_<B>) => Set<B>;
11
+ toList: () => List<A>;
12
+ toSet: () => Set<A>;
13
+ toString: () => string;
14
+ } & _Iterable_<A> & Collection<A>;
15
+ export declare const Set: <A>(iterable?: Iterable<A> | _Iterable_<A>) => Set<A>;
@@ -1 +1 @@
1
- export { Set, _Set_ } from "./Set";
1
+ export { Set } from "./Set";
package/lib/try/Try.d.ts CHANGED
@@ -1,19 +1,21 @@
1
- import { Either } from "../either";
2
- export type _Try_<T> = {
3
- isSuccess(): boolean;
4
- isFailure(): boolean;
5
- getOrElse(defaultValue: T): T;
6
- orElse(alternative: _Try_<T>): _Try_<T>;
7
- toEither(): Either<Error, T>;
8
- };
9
- export declare class Try<T> implements _Try_<T> {
10
- private readonly value;
11
- private readonly error;
12
- private constructor();
13
- static of<T>(f: () => T): _Try_<T>;
14
- isSuccess(): boolean;
15
- isFailure(): boolean;
16
- getOrElse(defaultValue: T): T;
17
- orElse(alternative: _Try_<T>): _Try_<T>;
18
- toEither(): Either<Error, T>;
19
- }
1
+ import { Either } from "../either/Either";
2
+ import { Typeable } from "../typeable/Typeable";
3
+ export type Try<T> = {
4
+ readonly _tag: "Success" | "Failure";
5
+ readonly value: T | undefined;
6
+ readonly error: Error | undefined;
7
+ isSuccess: () => boolean;
8
+ isFailure: () => boolean;
9
+ getOrElse: (defaultValue: T) => T;
10
+ orElse: (alternative: Try<T>) => Try<T>;
11
+ toEither: () => Either<Error, T>;
12
+ map: <U>(f: (value: T) => U) => Try<U>;
13
+ flatMap: <U>(f: (value: T) => Try<U>) => Try<U>;
14
+ valueOf: () => {
15
+ _tag: "Success" | "Failure";
16
+ value?: T;
17
+ error?: Error;
18
+ };
19
+ toString: () => string;
20
+ } & Typeable<"Success" | "Failure">;
21
+ export declare const Try: <T>(f: () => T) => Try<T>;
@@ -1 +1 @@
1
- export { _Try_, Try } from "./Try";
1
+ export { Try } from "./Try";
@@ -1,16 +1,9 @@
1
- import { ArrayType, _ArrayFunctor_ } from "../functor";
2
- export type _Tuple_<T extends ArrayType> = _ArrayFunctor_<T> & {
3
- get(index: number): T[number];
4
- getAs<U>(index: number, f?: (item: T) => boolean): U;
5
- map<U extends any[]>(f: (value: T) => U): _Tuple_<U>;
6
- flatMap<U extends any[]>(f: (value: T) => _Tuple_<U>): _Tuple_<U>;
7
- };
8
- export declare class Tuple<T extends ArrayType> implements _Tuple_<T> {
9
- private readonly values;
10
- constructor(values: T);
1
+ import { ArrayFunctor, ArrayType } from "../functor";
2
+ export type Tuple<T extends ArrayType> = {
3
+ get<K extends number>(index: K): T[K];
11
4
  map<U extends ArrayType>(f: (value: T) => U): Tuple<U>;
12
5
  flatMap<U extends ArrayType>(f: (value: T) => Tuple<U>): Tuple<U>;
13
- get(index: number): T[number];
14
- getAs<U>(index: number, f?: (item: T) => boolean): U;
15
6
  toArray(): T;
16
- }
7
+ [Symbol.iterator](): Iterator<T[number]>;
8
+ } & ArrayFunctor<T>;
9
+ export declare const Tuple: <T extends ArrayType>(values: T) => Tuple<T>;
@@ -1 +1,5 @@
1
- export { Tuple, _Tuple_ } from "./Tuple";
1
+ import { ArrayType } from "../functor";
2
+ import { Tuple } from "./Tuple";
3
+ export { Tuple } from "./Tuple";
4
+ export declare const t: <T extends ArrayType>(values: T) => Tuple<T>;
5
+ export declare const tuple: <T extends ArrayType>(values: T) => Tuple<T>;
@@ -0,0 +1,4 @@
1
+ export declare function Typeable<T extends string>(type: T): {
2
+ readonly _tag: T;
3
+ };
4
+ export type Typeable<T extends string> = ReturnType<typeof Typeable<T>>;
@@ -1,3 +1,3 @@
1
+ import { Either } from "../either/Either";
1
2
  import { ParseError } from "../error/ParseError";
2
- import { Either } from "../either";
3
3
  export declare const parseNumber: (input: string) => Either<ParseError, number>;
@@ -1 +1 @@
1
- export declare const isIterable: <T>(value: any) => value is Iterable<T>;
1
+ export declare const isIterable: <T>(value: unknown) => value is Iterable<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.4.2",
3
+ "version": "0.8.1",
4
4
  "description": "A smallish functional library for TypeScript",
5
5
  "author": "jordan.burke@gmail.com",
6
6
  "license": "MIT",
@@ -9,20 +9,20 @@
9
9
  "@types/node": "^20.14.15",
10
10
  "@typescript-eslint/eslint-plugin": "^7.5.0",
11
11
  "@typescript-eslint/parser": "^7.5.0",
12
- "@types/jest": "29.5.12",
12
+ "@types/jest": "29.5.13",
13
13
  "cross-env": "^7.0.3",
14
- "eslint": "^9.9.0",
14
+ "eslint": "^8.57.0",
15
15
  "eslint-config-prettier": "^9.1.0",
16
- "eslint-plugin-import": "^2.29.1",
16
+ "eslint-plugin-import": "^2.30.0",
17
17
  "eslint-plugin-prettier": "^5.2.1",
18
18
  "eslint-plugin-simple-import-sort": "^12.1.1",
19
19
  "jest": "^29.7.0",
20
20
  "prettier": "^3.3.3",
21
21
  "rimraf": "^6.0.1",
22
22
  "tsup": "^8.2.4",
23
- "ts-jest": "^29.2.4",
23
+ "ts-jest": "^29.2.5",
24
24
  "ts-node": "^10.9.2",
25
- "typescript": "^5.5.4"
25
+ "typescript": "^5.6.2"
26
26
  },
27
27
  "main": "./dist/index.js",
28
28
  "module": "./dist/index.mjs",
@@ -47,8 +47,8 @@
47
47
  "lint:fix": "eslint ./src --ext .ts,.tsx --quiet --fix --ignore-path ./.gitignore",
48
48
  "lint:format": "prettier --loglevel warn --write \"./**/*.{ts,tsx,css,md,json}\" ",
49
49
  "lint": "pnpm lint:format && pnpm lint:fix ",
50
- "test": "jest",
51
- "test:watch": "jest --watch",
52
- "test:cov": "jest --coverage"
50
+ "test": "tsc && jest",
51
+ "test:watch": "tsc && jest --watch",
52
+ "test:cov": "tsc && jest --coverage"
53
53
  }
54
54
  }
@@ -1 +0,0 @@
1
- var a=class u{constructor(e){this.values=e}map(e){let r=e(this.values);return new u(r)}flatMap(e){return e(this.values)}get(e){return this.values[e]}getAs(e,r){let t=this.values[e];if(r){if(r(this.values))return t;throw new Error("Cannot cast tuple value")}else return t}toArray(){return this.values}};export{a};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkV5UFW2E4js = require('./chunk-V5UFW2E4.js');var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunkRM3O3IPTjs = require('./chunk-RM3O3IPT.js');var _chunk3APFKSCCjs = require('./chunk-3APFKSCC.js');var _chunkO2XFH626js = require('./chunk-O2XFH626.js');var i=class r{constructor(e){_chunkO2XFH626js.a.call(void 0, this,"values");this.values=new (0, _chunk5VTXJIR3js.a)(e)}get entries(){return Array.from(this.values.entries()).map(([e,t])=>new (0, _chunkV5UFW2E4js.a)([e,t]))}add(e){return new r(this.values.set(e.toArray()[0],e.toArray()[1]).entries())}remove(e){let t=new r([...this.values.entries()]);return t.values.delete(e[0])?t:this}contains(e){return this.values.get(e[0])===e[1]}get size(){return this.values.size}map(e){return new r(Array.from(this.values.entries()).map(t=>[t[0],e(t[1])]))}flatMap(e){let t=[];for(let[a,V]of this.values.entries()){let l=e(V);if(l instanceof r)for(let[f,m]of l.values.entries())t.push([f,m])}return new r(t)}reduce(e){return new (0, _chunk3APFKSCCjs.f)(this.entries).reduce(e)}reduceRight(e){return new (0, _chunk3APFKSCCjs.f)(this.entries).reduceRight(e)}foldLeft(e){let t=new (0, _chunk3APFKSCCjs.f)(this.entries);return a=>t.foldLeft(e)(a)}foldRight(e){let t=new (0, _chunk3APFKSCCjs.f)(this.entries);return a=>t.foldRight(e)(a)}get(e){return _chunk3APFKSCCjs.c.call(void 0, this.values.get(e))}getOrElse(e,t){return _chunk3APFKSCCjs.c.call(void 0, this.values.get(e)).getOrElse(t)}get isEmpty(){return this.values.size===0}orElse(e,t){let a=_chunk3APFKSCCjs.c.call(void 0, this.values.get(e));return t}toList(){return new (0, _chunkRM3O3IPTjs.b)(this.entries)}toSet(){return new (0, _chunkRM3O3IPTjs.a)(this.entries)}toString(){return`Map(${this.entries.toString()})`}},U=new i([["a",1],["b",2],["c",3]]);exports.a = i;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBNNK42JCjs = require('./chunk-BNNK42JC.js');var _chunkO2XFH626js = require('./chunk-O2XFH626.js');var s=t=>t?_(t):l(),_= exports.d =t=>new o(t),l= exports.e =()=>new i;var n=class t{constructor(e){_chunkO2XFH626js.a.call(void 0, this,"values");_chunkBNNK42JCjs.a.call(void 0, e)?this.values=e:e instanceof t?this.values=e.toArray():e||(this.values=[])}get length(){return this.toArray().length}map(e){return new t(this.toArray().map(e))}flatMap(e){let r=[];for(let u of this.values){let a=e(u);a instanceof t&&r.push(...a.values)}return new t(r)}forEach(e){this.toArray().forEach(e)}count(e){return 0}exists(e){return!this.find(e).isEmpty}filter(e){return new t(this.toArray().filter(e))}filterNot(e){return new t(this.toArray().filter(r=>!e(r)))}find(e){let r=this.toArray().find(e);return s(r)}get head(){return this.values[0]}get headOption(){return this.isEmpty?s(this.head):l()}get isEmpty(){return this.toArray().length===0}get size(){return 0}toArray(){return Array.from(this.values)}reduce(e){return this.toArray().reduce(e)}reduceRight(e){return this.toArray().reduceRight(e)}foldLeft(e){return r=>this.toArray().reduce(r,e)}foldRight(e){return r=>this.toArray().reduceRight((u,a)=>r(a,u),e)}};var o=class t{constructor(e){this.value=e}get isEmpty(){return!1}get(){return this.value}getOrElse(e){return this.value}orElse(e){return this}map(e){return new t(e(this.value))}flatMap(e){return e(this.value)}reduce(e){return e(void 0,this.value)}reduceRight(e){return e(void 0,this.value)}foldLeft(e){return r=>r(e,this.value)}foldRight(e){return r=>r(this.value,e)}toList(){return new n([this.value])}contains(e){return!1}get size(){return 0}},i= exports.b =class t{get isEmpty(){return!0}get(){throw new Error("Cannot call get() on a None")}getOrElse(e){return e}orElse(e){return e}map(e){return new t}flatMap(e){return new t}reduce(e){return e(void 0,void 0)}reduceRight(e){return e(void 0,void 0)}foldLeft(e){return r=>e}foldRight(e){return r=>e}toList(){return new n}contains(e){return!1}get size(){return 0}};exports.a = o; exports.b = i; exports.c = s; exports.d = _; exports.e = l; exports.f = n;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkRM3O3IPTjs = require('./chunk-RM3O3IPT.js');var _chunk3APFKSCCjs = require('./chunk-3APFKSCC.js');var u=class e{constructor(t){this.value=t}isLeft(){return!1}isRight(){return!0}map(t){return new e(t(this.value))}flatMap(t){return t(this.value)}toOption(){return _chunk3APFKSCCjs.d.call(void 0, this.value)}toList(){return new (0, _chunkRM3O3IPTjs.b)([this.value])}},n= exports.b =class e{constructor(t){this.value=t}isLeft(){return!0}isRight(){return!1}map(t){return new e(this.value)}flatMap(t){return new e(this.value)}toOption(){return _chunk3APFKSCCjs.e.call(void 0, )}toList(){return new _chunkRM3O3IPTjs.b}};exports.a = u; exports.b = n;
File without changes
@@ -1 +0,0 @@
1
- "use strict";
File without changes
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3EH27NX2js = require('./chunk-3EH27NX2.js');var o=t=>new (0, _chunk3EH27NX2js.b)(t),i= exports.b =t=>new (0, _chunk3EH27NX2js.a)(t);exports.a = o; exports.b = i;
@@ -1 +0,0 @@
1
- var e=class extends Error{};export{e as a};
@@ -1 +0,0 @@
1
- import{b as i}from"./chunk-KY3WKBLM.mjs";import{d as r,e as s}from"./chunk-TYHKMGLC.mjs";var u=class e{constructor(t){this.value=t}isLeft(){return!1}isRight(){return!0}map(t){return new e(t(this.value))}flatMap(t){return t(this.value)}toOption(){return r(this.value)}toList(){return new i([this.value])}},n=class e{constructor(t){this.value=t}isLeft(){return!0}isRight(){return!1}map(t){return new e(this.value)}flatMap(t){return new e(this.value)}toOption(){return s()}toList(){return new i}};export{u as a,n as b};
@@ -1 +0,0 @@
1
- import{a as e,b as r}from"./chunk-GTO34VMN.mjs";var o=t=>new r(t),i=t=>new e(t);export{o as a,i as b};
@@ -1 +0,0 @@
1
- import{a as e}from"./chunk-2XH6TPQK.mjs";var t=r=>new e(r),o=r=>new e(r);export{t as a,o as b};
@@ -1 +0,0 @@
1
- import{a as K}from"./chunk-2XH6TPQK.mjs";import{a as _}from"./chunk-377WQNCB.mjs";import{a as u,b as o}from"./chunk-KY3WKBLM.mjs";import{c as s,f as n}from"./chunk-TYHKMGLC.mjs";import{a as p}from"./chunk-JR557W27.mjs";var i=class r{constructor(e){p(this,"values");this.values=new _(e)}get entries(){return Array.from(this.values.entries()).map(([e,t])=>new K([e,t]))}add(e){return new r(this.values.set(e.toArray()[0],e.toArray()[1]).entries())}remove(e){let t=new r([...this.values.entries()]);return t.values.delete(e[0])?t:this}contains(e){return this.values.get(e[0])===e[1]}get size(){return this.values.size}map(e){return new r(Array.from(this.values.entries()).map(t=>[t[0],e(t[1])]))}flatMap(e){let t=[];for(let[a,V]of this.values.entries()){let l=e(V);if(l instanceof r)for(let[f,m]of l.values.entries())t.push([f,m])}return new r(t)}reduce(e){return new n(this.entries).reduce(e)}reduceRight(e){return new n(this.entries).reduceRight(e)}foldLeft(e){let t=new n(this.entries);return a=>t.foldLeft(e)(a)}foldRight(e){let t=new n(this.entries);return a=>t.foldRight(e)(a)}get(e){return s(this.values.get(e))}getOrElse(e,t){return s(this.values.get(e)).getOrElse(t)}get isEmpty(){return this.values.size===0}orElse(e,t){let a=s(this.values.get(e));return t}toList(){return new o(this.entries)}toSet(){return new u(this.entries)}toString(){return`Map(${this.entries.toString()})`}},U=new i([["a",1],["b",2],["c",3]]);export{i as a};
@@ -1 +0,0 @@
1
- var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var f=(b,a,c)=>e(b,typeof a!="symbol"?a+"":a,c);export{f as a};
@@ -1 +0,0 @@
1
- import{c as A,f as s}from"./chunk-TYHKMGLC.mjs";import{a as m}from"./chunk-RRAIFS3D.mjs";import{a}from"./chunk-HA5XD5KC.mjs";var o=class e extends s{constructor(t){super(t)}map(t){return new e(super.map(t))}flatMap(t){return new e(super.flatMap(t))}remove(t){let i=new e().toArray().indexOf(t);return this.removeAt(i)}contains(t){return this.toArray().indexOf(t)!==-1}add(t){let i=[...this.toArray(),t];return new e(i)}removeAt(t){if(t<0||t>=this.toArray().length)return this;let r=[...this.toArray().slice(0,t),...this.toArray().slice(t+1)];return new e(r)}get(t){return A(this.toArray()[t])}concat(t){return new e([...this.toArray(),...t.toArray()])}toList(){return this}toSet(){return new n(this.toArray())}toString(){return`List(${this.toArray().toString()})`}};var w=e=>new o(e);var n=class e extends s{constructor(t){m(t)?super(new a(t)):super(t?.toArray())}add(t){return new e([...this.values,t])}remove(t){let r=new a;return r.delete(t)?new e(r):this}contains(t){return this.has(t)}has(t){return this.values.has(t)}map(t){return new e(super.map(t))}flatMap(t){return new e(super.flatMap(t))}toList(){return new o(this)}toSet(){return this}toString(){return`Set(${this.toArray().toString()})`}};export{n as a,o as b,w as c};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var f=(b,a,c)=>e(b,typeof a!="symbol"?a+"":a,c);exports.a = f;
File without changes
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3EH27NX2js = require('./chunk-3EH27NX2.js');var i=class t{constructor(r,e){this.value=r;this.error=e}static of(r){try{return new t(r(),null)}catch(e){return new t(null,e instanceof Error?e:new Error(String(e)))}}isSuccess(){return this.error===null}isFailure(){return this.error!==null}getOrElse(r){return this.isSuccess()?this.value:r}orElse(r){return this.isSuccess()?this:r}toEither(){return this.isSuccess()?new (0, _chunk3EH27NX2js.a)(this.value):new (0, _chunk3EH27NX2js.b)(this.error)}};exports.a = i;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk3APFKSCCjs = require('./chunk-3APFKSCC.js');var _chunkBNNK42JCjs = require('./chunk-BNNK42JC.js');var _chunk3VJERXBPjs = require('./chunk-3VJERXBP.js');var o=class e extends _chunk3APFKSCCjs.f{constructor(t){super(t)}map(t){return new e(super.map(t))}flatMap(t){return new e(super.flatMap(t))}remove(t){let i=new e().toArray().indexOf(t);return this.removeAt(i)}contains(t){return this.toArray().indexOf(t)!==-1}add(t){let i=[...this.toArray(),t];return new e(i)}removeAt(t){if(t<0||t>=this.toArray().length)return this;let r=[...this.toArray().slice(0,t),...this.toArray().slice(t+1)];return new e(r)}get(t){return _chunk3APFKSCCjs.c.call(void 0, this.toArray()[t])}concat(t){return new e([...this.toArray(),...t.toArray()])}toList(){return this}toSet(){return new n(this.toArray())}toString(){return`List(${this.toArray().toString()})`}};var w=e=>new o(e);var n=class e extends _chunk3APFKSCCjs.f{constructor(t){_chunkBNNK42JCjs.a.call(void 0, t)?super(new (0, _chunk3VJERXBPjs.a)(t)):super(_optionalChain([t, 'optionalAccess', _ => _.toArray, 'call', _2 => _2()]))}add(t){return new e([...this.values,t])}remove(t){let r=new _chunk3VJERXBPjs.a;return r.delete(t)?new e(r):this}contains(t){return this.has(t)}has(t){return this.values.has(t)}map(t){return new e(super.map(t))}flatMap(t){return new e(super.flatMap(t))}toList(){return new o(this)}toSet(){return this}toString(){return`Set(${this.toArray().toString()})`}};exports.a = n; exports.b = o; exports.c = w;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkV5UFW2E4js = require('./chunk-V5UFW2E4.js');var t=r=>new (0, _chunkV5UFW2E4js.a)(r),o= exports.b =r=>new (0, _chunkV5UFW2E4js.a)(r);exports.a = t; exports.b = o;
@@ -1 +0,0 @@
1
- import{a as s,b as o}from"./chunk-GTO34VMN.mjs";var i=class t{constructor(r,e){this.value=r;this.error=e}static of(r){try{return new t(r(),null)}catch(e){return new t(null,e instanceof Error?e:new Error(String(e)))}}isSuccess(){return this.error===null}isFailure(){return this.error!==null}getOrElse(r){return this.isSuccess()?this.value:r}orElse(r){return this.isSuccess()?this:r}toEither(){return this.isSuccess()?new s(this.value):new o(this.error)}};export{i as a};
@@ -1 +0,0 @@
1
- import{a as A}from"./chunk-RRAIFS3D.mjs";import{a as p}from"./chunk-JR557W27.mjs";var s=t=>t?_(t):l(),_=t=>new o(t),l=()=>new i;var n=class t{constructor(e){p(this,"values");A(e)?this.values=e:e instanceof t?this.values=e.toArray():e||(this.values=[])}get length(){return this.toArray().length}map(e){return new t(this.toArray().map(e))}flatMap(e){let r=[];for(let u of this.values){let a=e(u);a instanceof t&&r.push(...a.values)}return new t(r)}forEach(e){this.toArray().forEach(e)}count(e){return 0}exists(e){return!this.find(e).isEmpty}filter(e){return new t(this.toArray().filter(e))}filterNot(e){return new t(this.toArray().filter(r=>!e(r)))}find(e){let r=this.toArray().find(e);return s(r)}get head(){return this.values[0]}get headOption(){return this.isEmpty?s(this.head):l()}get isEmpty(){return this.toArray().length===0}get size(){return 0}toArray(){return Array.from(this.values)}reduce(e){return this.toArray().reduce(e)}reduceRight(e){return this.toArray().reduceRight(e)}foldLeft(e){return r=>this.toArray().reduce(r,e)}foldRight(e){return r=>this.toArray().reduceRight((u,a)=>r(a,u),e)}};var o=class t{constructor(e){this.value=e}get isEmpty(){return!1}get(){return this.value}getOrElse(e){return this.value}orElse(e){return this}map(e){return new t(e(this.value))}flatMap(e){return e(this.value)}reduce(e){return e(void 0,this.value)}reduceRight(e){return e(void 0,this.value)}foldLeft(e){return r=>r(e,this.value)}foldRight(e){return r=>r(this.value,e)}toList(){return new n([this.value])}contains(e){return!1}get size(){return 0}},i=class t{get isEmpty(){return!0}get(){throw new Error("Cannot call get() on a None")}getOrElse(e){return e}orElse(e){return e}map(e){return new t}flatMap(e){return new t}reduce(e){return e(void 0,void 0)}reduceRight(e){return e(void 0,void 0)}foldLeft(e){return r=>e}foldRight(e){return r=>e}toList(){return new n}contains(e){return!1}get size(){return 0}};export{o as a,i as b,s as c,_ as d,l as e,n as f};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var a=class u{constructor(e){this.values=e}map(e){let r=e(this.values);return new u(r)}flatMap(e){return e(this.values)}get(e){return this.values[e]}getAs(e,r){let t=this.values[e];if(r){if(r(this.values))return t;throw new Error("Cannot cast tuple value")}else return t}toArray(){return this.values}};exports.a = a;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,4 +0,0 @@
1
- export { E as Either, h as Left, R as Right, i as left, r as right } from '../index-UMWeD2QH.mjs';
2
- import '../functor/index.mjs';
3
- import '../tuple/Tuple.mjs';
4
- import '../tuple/index.mjs';
@@ -1,4 +0,0 @@
1
- export { E as Either, h as Left, R as Right, i as left, r as right } from '../index-Dbjb4MUT.js';
2
- import '../functor/index.js';
3
- import '../tuple/Tuple.js';
4
- import '../tuple/index.js';
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBYDMB2VVjs = require('../chunk-BYDMB2VV.js');var _chunk3EH27NX2js = require('../chunk-3EH27NX2.js');require('../chunk-RM3O3IPT.js');require('../chunk-XVHCBGUW.js');require('../chunk-3APFKSCC.js');require('../chunk-BNNK42JC.js');require('../chunk-3VJERXBP.js');require('../chunk-O2XFH626.js');exports.Left = _chunk3EH27NX2js.b; exports.Right = _chunk3EH27NX2js.a; exports.left = _chunkBYDMB2VVjs.a; exports.right = _chunkBYDMB2VVjs.b;
@@ -1 +0,0 @@
1
- import{a as c,b as d}from"../chunk-HC3O3O2B.mjs";import{a,b}from"../chunk-GTO34VMN.mjs";import"../chunk-KY3WKBLM.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-TYHKMGLC.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-JR557W27.mjs";export{b as Left,a as Right,c as left,d as right};