happy-rusty 1.0.5 → 1.0.7
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/main.cjs +4 -1
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +4 -1
- package/dist/main.mjs.map +1 -1
- package/dist/types.d.ts +18 -13
- package/package.json +2 -1
- package/src/enum/option.ts +6 -6
- package/src/enum/result.ts +9 -7
- package/src/mod.ts +9 -0
package/dist/main.cjs
CHANGED
package/dist/main.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.cjs","sources":["../src/enum/option.ts","../src/enum/result.ts"],"sourcesContent":["/**\n * @fileoverview
|
|
1
|
+
{"version":3,"file":"main.cjs","sources":["../src/enum/option.ts","../src/enum/result.ts"],"sourcesContent":["/**\n * @fileoverview A Rust-inspired [Option](https://doc.rust-lang.org/core/option/index.html) enum, used as an alternative to the use of null and undefined.\n */\n\n/**\n * option::Some type\n */\ninterface Some<T> {\n readonly kind: 'Some';\n readonly isSome: (this: Option<T>) => this is Some<T>;\n readonly isNone: (this: Option<T>) => this is None;\n readonly unwrap: () => T;\n}\n\n/**\n * option::None type\n */\ninterface None {\n readonly kind: 'None';\n readonly isSome: <T>(this: Option<T>) => this is Some<T>;\n readonly isNone: <T>(this: Option<T>) => this is None;\n readonly unwrap: () => never;\n}\n\n/**\n * option::Option type\n */\nexport type Option<T> = Some<T> | None;\n\n/**\n * Create a `Some` object.\n *\n * # Examples\n *\n * ```\n * const v = Some(10);\n * console.assert(v.unwrap() === 10);\n * ```\n *\n * @param value The wrapped value which can not be null or undefined.\n * @returns {Some}\n */\nexport function Some<T>(value: NonNullable<T>): Option<T> {\n if (value == null) {\n throw new TypeError('Some value can not be null or undefined');\n }\n\n return {\n kind: 'Some',\n isSome: () => true,\n isNone: () => false,\n unwrap: () => value,\n } as const;\n}\n\n/**\n * `None` value is freeze.\n *\n * @constant {None}\n */\nexport const None: None = {\n kind: 'None',\n isSome: () => false,\n isNone: () => true,\n unwrap: () => {\n throw new TypeError('None can not unwrap');\n },\n} as const;","/**\n * @fileoverview A Rust-inspired [Result](https://doc.rust-lang.org/core/result/index.html) enum, used for better error handling.\n */\n\n/**\n * result::Ok type\n */\ninterface Ok<T, E> {\n readonly kind: 'Ok';\n readonly isOk: (this: Result<T, E>) => this is Ok<T, E>;\n readonly isErr: (this: Result<T, E>) => this is Err<T, E>;\n readonly unwrap: () => T;\n readonly err: () => never;\n}\n\n/**\n * result::Err type\n */\ninterface Err<T, E> {\n readonly kind: 'Err';\n readonly isOk: (this: Result<T, E>) => this is Ok<T, E>;\n readonly isErr: (this: Result<T, E>) => this is Err<T, E>;\n readonly unwrap: () => never;\n readonly err: () => E;\n}\n\n/**\n * result::Result type\n */\nexport type Result<T, E> = Ok<T, E> | Err<T, E>;\n\n/**\n * Create an `Ok` object.\n *\n * # Examples\n *\n * ```\n * const v = Ok(10);\n * console.assert(v.unwrap() === 10);\n *\nfunction judge(n: number): Option<Promise<Result<number, Error>>> {\n if (n < 0 || n >= 1) {\n return None;\n }\n\n return Some(new Promise(resolve => {\n const r = Math.random();\n resolve(r > n ? Ok(r) : Err(new Error('lose')));\n }));\n}\n\nconst res = judge(0.8);\nif (res.isNone()) {\n console.error('invalid number');\n} else {\n const result = await res.unwrap();\n if (result.isErr()) {\n console.assert(result.err().message === 'lose');\n } else {\n console.log(result.unwrap()); // must greater than 0.8\n }\n}\n *\n * ```\n *\n * @param value The wrapped value.\n * @returns {Ok}\n */\nexport function Ok<T, E>(value: T): Result<T, E> {\n return {\n kind: 'Ok',\n isOk: () => true,\n isErr: () => false,\n unwrap: () => value,\n err: () => {\n throw new TypeError('Ok is not Err');\n },\n } as const;\n}\n\n/**\n * Create an `Err` object.\n *\n * # Examples\n *\n * ```\n * const e = Err(new Error('unknown error'));\n * console.assert(e.err().message === 'unknown error');\n * ```\n *\n * @param error The wrapped error value.\n * @returns {Err}\n */\nexport function Err<T, E>(error: E): Result<T, E> {\n return {\n kind: 'Err',\n isOk: () => false,\n isErr: () => true,\n unwrap: () => {\n throw error;\n },\n err: () => error,\n } as const;\n}"],"names":[],"mappings":";;AA0CO,SAAS,KAAQ,KAAkC,EAAA;AACtD,EAAA,IAAI,SAAS,IAAM,EAAA;AACf,IAAM,MAAA,IAAI,UAAU,yCAAyC,CAAA,CAAA;AAAA,GACjE;AAEA,EAAO,OAAA;AAAA,IACH,IAAM,EAAA,MAAA;AAAA,IACN,QAAQ,MAAM,IAAA;AAAA,IACd,QAAQ,MAAM,KAAA;AAAA,IACd,QAAQ,MAAM,KAAA;AAAA,GAClB,CAAA;AACJ,CAAA;AAOO,MAAM,IAAa,GAAA;AAAA,EACtB,IAAM,EAAA,MAAA;AAAA,EACN,QAAQ,MAAM,KAAA;AAAA,EACd,QAAQ,MAAM,IAAA;AAAA,EACd,QAAQ,MAAM;AACV,IAAM,MAAA,IAAI,UAAU,qBAAqB,CAAA,CAAA;AAAA,GAC7C;AACJ;;ACCO,SAAS,GAAS,KAAwB,EAAA;AAC7C,EAAO,OAAA;AAAA,IACH,IAAM,EAAA,IAAA;AAAA,IACN,MAAM,MAAM,IAAA;AAAA,IACZ,OAAO,MAAM,KAAA;AAAA,IACb,QAAQ,MAAM,KAAA;AAAA,IACd,KAAK,MAAM;AACP,MAAM,MAAA,IAAI,UAAU,eAAe,CAAA,CAAA;AAAA,KACvC;AAAA,GACJ,CAAA;AACJ,CAAA;AAeO,SAAS,IAAU,KAAwB,EAAA;AAC9C,EAAO,OAAA;AAAA,IACH,IAAM,EAAA,KAAA;AAAA,IACN,MAAM,MAAM,KAAA;AAAA,IACZ,OAAO,MAAM,IAAA;AAAA,IACb,QAAQ,MAAM;AACV,MAAM,MAAA,KAAA,CAAA;AAAA,KACV;AAAA,IACA,KAAK,MAAM,KAAA;AAAA,GACf,CAAA;AACJ;;;;;;;"}
|
package/dist/main.mjs
CHANGED
package/dist/main.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.mjs","sources":["../src/enum/option.ts","../src/enum/result.ts"],"sourcesContent":["/**\n * @fileoverview
|
|
1
|
+
{"version":3,"file":"main.mjs","sources":["../src/enum/option.ts","../src/enum/result.ts"],"sourcesContent":["/**\n * @fileoverview A Rust-inspired [Option](https://doc.rust-lang.org/core/option/index.html) enum, used as an alternative to the use of null and undefined.\n */\n\n/**\n * option::Some type\n */\ninterface Some<T> {\n readonly kind: 'Some';\n readonly isSome: (this: Option<T>) => this is Some<T>;\n readonly isNone: (this: Option<T>) => this is None;\n readonly unwrap: () => T;\n}\n\n/**\n * option::None type\n */\ninterface None {\n readonly kind: 'None';\n readonly isSome: <T>(this: Option<T>) => this is Some<T>;\n readonly isNone: <T>(this: Option<T>) => this is None;\n readonly unwrap: () => never;\n}\n\n/**\n * option::Option type\n */\nexport type Option<T> = Some<T> | None;\n\n/**\n * Create a `Some` object.\n *\n * # Examples\n *\n * ```\n * const v = Some(10);\n * console.assert(v.unwrap() === 10);\n * ```\n *\n * @param value The wrapped value which can not be null or undefined.\n * @returns {Some}\n */\nexport function Some<T>(value: NonNullable<T>): Option<T> {\n if (value == null) {\n throw new TypeError('Some value can not be null or undefined');\n }\n\n return {\n kind: 'Some',\n isSome: () => true,\n isNone: () => false,\n unwrap: () => value,\n } as const;\n}\n\n/**\n * `None` value is freeze.\n *\n * @constant {None}\n */\nexport const None: None = {\n kind: 'None',\n isSome: () => false,\n isNone: () => true,\n unwrap: () => {\n throw new TypeError('None can not unwrap');\n },\n} as const;","/**\n * @fileoverview A Rust-inspired [Result](https://doc.rust-lang.org/core/result/index.html) enum, used for better error handling.\n */\n\n/**\n * result::Ok type\n */\ninterface Ok<T, E> {\n readonly kind: 'Ok';\n readonly isOk: (this: Result<T, E>) => this is Ok<T, E>;\n readonly isErr: (this: Result<T, E>) => this is Err<T, E>;\n readonly unwrap: () => T;\n readonly err: () => never;\n}\n\n/**\n * result::Err type\n */\ninterface Err<T, E> {\n readonly kind: 'Err';\n readonly isOk: (this: Result<T, E>) => this is Ok<T, E>;\n readonly isErr: (this: Result<T, E>) => this is Err<T, E>;\n readonly unwrap: () => never;\n readonly err: () => E;\n}\n\n/**\n * result::Result type\n */\nexport type Result<T, E> = Ok<T, E> | Err<T, E>;\n\n/**\n * Create an `Ok` object.\n *\n * # Examples\n *\n * ```\n * const v = Ok(10);\n * console.assert(v.unwrap() === 10);\n *\nfunction judge(n: number): Option<Promise<Result<number, Error>>> {\n if (n < 0 || n >= 1) {\n return None;\n }\n\n return Some(new Promise(resolve => {\n const r = Math.random();\n resolve(r > n ? Ok(r) : Err(new Error('lose')));\n }));\n}\n\nconst res = judge(0.8);\nif (res.isNone()) {\n console.error('invalid number');\n} else {\n const result = await res.unwrap();\n if (result.isErr()) {\n console.assert(result.err().message === 'lose');\n } else {\n console.log(result.unwrap()); // must greater than 0.8\n }\n}\n *\n * ```\n *\n * @param value The wrapped value.\n * @returns {Ok}\n */\nexport function Ok<T, E>(value: T): Result<T, E> {\n return {\n kind: 'Ok',\n isOk: () => true,\n isErr: () => false,\n unwrap: () => value,\n err: () => {\n throw new TypeError('Ok is not Err');\n },\n } as const;\n}\n\n/**\n * Create an `Err` object.\n *\n * # Examples\n *\n * ```\n * const e = Err(new Error('unknown error'));\n * console.assert(e.err().message === 'unknown error');\n * ```\n *\n * @param error The wrapped error value.\n * @returns {Err}\n */\nexport function Err<T, E>(error: E): Result<T, E> {\n return {\n kind: 'Err',\n isOk: () => false,\n isErr: () => true,\n unwrap: () => {\n throw error;\n },\n err: () => error,\n } as const;\n}"],"names":[],"mappings":"AA0CO,SAAS,KAAQ,KAAkC,EAAA;AACtD,EAAA,IAAI,SAAS,IAAM,EAAA;AACf,IAAM,MAAA,IAAI,UAAU,yCAAyC,CAAA,CAAA;AAAA,GACjE;AAEA,EAAO,OAAA;AAAA,IACH,IAAM,EAAA,MAAA;AAAA,IACN,QAAQ,MAAM,IAAA;AAAA,IACd,QAAQ,MAAM,KAAA;AAAA,IACd,QAAQ,MAAM,KAAA;AAAA,GAClB,CAAA;AACJ,CAAA;AAOO,MAAM,IAAa,GAAA;AAAA,EACtB,IAAM,EAAA,MAAA;AAAA,EACN,QAAQ,MAAM,KAAA;AAAA,EACd,QAAQ,MAAM,IAAA;AAAA,EACd,QAAQ,MAAM;AACV,IAAM,MAAA,IAAI,UAAU,qBAAqB,CAAA,CAAA;AAAA,GAC7C;AACJ;;ACCO,SAAS,GAAS,KAAwB,EAAA;AAC7C,EAAO,OAAA;AAAA,IACH,IAAM,EAAA,IAAA;AAAA,IACN,MAAM,MAAM,IAAA;AAAA,IACZ,OAAO,MAAM,KAAA;AAAA,IACb,QAAQ,MAAM,KAAA;AAAA,IACd,KAAK,MAAM;AACP,MAAM,MAAA,IAAI,UAAU,eAAe,CAAA,CAAA;AAAA,KACvC;AAAA,GACJ,CAAA;AACJ,CAAA;AAeO,SAAS,IAAU,KAAwB,EAAA;AAC9C,EAAO,OAAA;AAAA,IACH,IAAM,EAAA,KAAA;AAAA,IACN,MAAM,MAAM,KAAA;AAAA,IACZ,OAAO,MAAM,IAAA;AAAA,IACb,QAAQ,MAAM;AACV,MAAM,MAAA,KAAA,CAAA;AAAA,KACV;AAAA,IACA,KAAK,MAAM,KAAA;AAAA,GACf,CAAA;AACJ;;;;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
type Option<T> = Some<T> | None;
|
|
5
5
|
/**
|
|
6
|
-
* @fileoverview
|
|
7
|
-
* 用于替代null和undefined的使用。
|
|
6
|
+
* @fileoverview A Rust-inspired [Option](https://doc.rust-lang.org/core/option/index.html) enum, used as an alternative to the use of null and undefined.
|
|
8
7
|
*/
|
|
9
8
|
/**
|
|
10
9
|
* option::Some type
|
|
@@ -16,7 +15,7 @@ interface Some<T> {
|
|
|
16
15
|
readonly unwrap: () => T;
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
18
|
+
* Create a `Some` object.
|
|
20
19
|
*
|
|
21
20
|
* # Examples
|
|
22
21
|
*
|
|
@@ -25,10 +24,10 @@ interface Some<T> {
|
|
|
25
24
|
* console.assert(v.unwrap() === 10);
|
|
26
25
|
* ```
|
|
27
26
|
*
|
|
28
|
-
* @param value
|
|
27
|
+
* @param value The wrapped value which can not be null or undefined.
|
|
29
28
|
* @returns {Some}
|
|
30
29
|
*/
|
|
31
|
-
declare function Some<T>(value: T): Option<T>;
|
|
30
|
+
declare function Some<T>(value: NonNullable<T>): Option<T>;
|
|
32
31
|
/**
|
|
33
32
|
* option::None type
|
|
34
33
|
*/
|
|
@@ -39,7 +38,8 @@ interface None {
|
|
|
39
38
|
readonly unwrap: () => never;
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
42
|
-
* `None
|
|
41
|
+
* `None` value is freeze.
|
|
42
|
+
*
|
|
43
43
|
* @constant {None}
|
|
44
44
|
*/
|
|
45
45
|
declare const None: None;
|
|
@@ -49,8 +49,7 @@ declare const None: None;
|
|
|
49
49
|
*/
|
|
50
50
|
type Result<T, E> = Ok<T, E> | Err<T, E>;
|
|
51
51
|
/**
|
|
52
|
-
* @fileoverview
|
|
53
|
-
* 用于错误处理。
|
|
52
|
+
* @fileoverview A Rust-inspired [Result](https://doc.rust-lang.org/core/result/index.html) enum, used for better error handling.
|
|
54
53
|
*/
|
|
55
54
|
/**
|
|
56
55
|
* result::Ok type
|
|
@@ -60,9 +59,10 @@ interface Ok<T, E> {
|
|
|
60
59
|
readonly isOk: (this: Result<T, E>) => this is Ok<T, E>;
|
|
61
60
|
readonly isErr: (this: Result<T, E>) => this is Err<T, E>;
|
|
62
61
|
readonly unwrap: () => T;
|
|
62
|
+
readonly err: () => never;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Create an `Ok` object.
|
|
66
66
|
*
|
|
67
67
|
* # Examples
|
|
68
68
|
*
|
|
@@ -95,7 +95,7 @@ if (res.isNone()) {
|
|
|
95
95
|
*
|
|
96
96
|
* ```
|
|
97
97
|
*
|
|
98
|
-
* @param value
|
|
98
|
+
* @param value The wrapped value.
|
|
99
99
|
* @returns {Ok}
|
|
100
100
|
*/
|
|
101
101
|
declare function Ok<T, E>(value: T): Result<T, E>;
|
|
@@ -110,7 +110,7 @@ interface Err<T, E> {
|
|
|
110
110
|
readonly err: () => E;
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* Create an `Err` object.
|
|
114
114
|
*
|
|
115
115
|
* # Examples
|
|
116
116
|
*
|
|
@@ -119,10 +119,15 @@ interface Err<T, E> {
|
|
|
119
119
|
* console.assert(e.err().message === 'unknown error');
|
|
120
120
|
* ```
|
|
121
121
|
*
|
|
122
|
-
* @param error
|
|
122
|
+
* @param error The wrapped error value.
|
|
123
123
|
* @returns {Err}
|
|
124
124
|
*/
|
|
125
125
|
declare function Err<T, E>(error: E): Result<T, E>;
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
type AsyncOption<T> = Promise<Option<T>>;
|
|
128
|
+
type AsyncResult<T, E> = Promise<Result<T, E>>;
|
|
129
|
+
type IOResult<T> = Result<T, Error>;
|
|
130
|
+
type AsyncIOResult<T> = Promise<IOResult<T>>;
|
|
131
|
+
|
|
132
|
+
export { type AsyncIOResult, type AsyncOption, type AsyncResult, Err, type IOResult, None, Ok, type Option, type Result, Some };
|
|
128
133
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
"description": "Porting some excellent design implementations from Rust to JavaScript.",
|
|
4
4
|
"author": "jiang115jie@gmail.com",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.7",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"source": "./src/mod.ts",
|
|
8
9
|
"main": "./dist/main.cjs",
|
|
9
10
|
"module": "./dist/main.mjs",
|
package/src/enum/option.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
* 用于替代null和undefined的使用。
|
|
2
|
+
* @fileoverview A Rust-inspired [Option](https://doc.rust-lang.org/core/option/index.html) enum, used as an alternative to the use of null and undefined.
|
|
4
3
|
*/
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -29,7 +28,7 @@ interface None {
|
|
|
29
28
|
export type Option<T> = Some<T> | None;
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
|
-
*
|
|
31
|
+
* Create a `Some` object.
|
|
33
32
|
*
|
|
34
33
|
* # Examples
|
|
35
34
|
*
|
|
@@ -38,10 +37,10 @@ export type Option<T> = Some<T> | None;
|
|
|
38
37
|
* console.assert(v.unwrap() === 10);
|
|
39
38
|
* ```
|
|
40
39
|
*
|
|
41
|
-
* @param value
|
|
40
|
+
* @param value The wrapped value which can not be null or undefined.
|
|
42
41
|
* @returns {Some}
|
|
43
42
|
*/
|
|
44
|
-
export function Some<T>(value: T): Option<T> {
|
|
43
|
+
export function Some<T>(value: NonNullable<T>): Option<T> {
|
|
45
44
|
if (value == null) {
|
|
46
45
|
throw new TypeError('Some value can not be null or undefined');
|
|
47
46
|
}
|
|
@@ -55,7 +54,8 @@ export function Some<T>(value: T): Option<T> {
|
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
|
-
* `None
|
|
57
|
+
* `None` value is freeze.
|
|
58
|
+
*
|
|
59
59
|
* @constant {None}
|
|
60
60
|
*/
|
|
61
61
|
export const None: None = {
|
package/src/enum/result.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
* 用于错误处理。
|
|
2
|
+
* @fileoverview A Rust-inspired [Result](https://doc.rust-lang.org/core/result/index.html) enum, used for better error handling.
|
|
4
3
|
*/
|
|
5
4
|
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* result::Ok type
|
|
9
7
|
*/
|
|
@@ -12,6 +10,7 @@ interface Ok<T, E> {
|
|
|
12
10
|
readonly isOk: (this: Result<T, E>) => this is Ok<T, E>;
|
|
13
11
|
readonly isErr: (this: Result<T, E>) => this is Err<T, E>;
|
|
14
12
|
readonly unwrap: () => T;
|
|
13
|
+
readonly err: () => never;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -31,7 +30,7 @@ interface Err<T, E> {
|
|
|
31
30
|
export type Result<T, E> = Ok<T, E> | Err<T, E>;
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
33
|
+
* Create an `Ok` object.
|
|
35
34
|
*
|
|
36
35
|
* # Examples
|
|
37
36
|
*
|
|
@@ -64,7 +63,7 @@ if (res.isNone()) {
|
|
|
64
63
|
*
|
|
65
64
|
* ```
|
|
66
65
|
*
|
|
67
|
-
* @param value
|
|
66
|
+
* @param value The wrapped value.
|
|
68
67
|
* @returns {Ok}
|
|
69
68
|
*/
|
|
70
69
|
export function Ok<T, E>(value: T): Result<T, E> {
|
|
@@ -73,11 +72,14 @@ export function Ok<T, E>(value: T): Result<T, E> {
|
|
|
73
72
|
isOk: () => true,
|
|
74
73
|
isErr: () => false,
|
|
75
74
|
unwrap: () => value,
|
|
75
|
+
err: () => {
|
|
76
|
+
throw new TypeError('Ok is not Err');
|
|
77
|
+
},
|
|
76
78
|
} as const;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
/**
|
|
80
|
-
*
|
|
82
|
+
* Create an `Err` object.
|
|
81
83
|
*
|
|
82
84
|
* # Examples
|
|
83
85
|
*
|
|
@@ -86,7 +88,7 @@ export function Ok<T, E>(value: T): Result<T, E> {
|
|
|
86
88
|
* console.assert(e.err().message === 'unknown error');
|
|
87
89
|
* ```
|
|
88
90
|
*
|
|
89
|
-
* @param error
|
|
91
|
+
* @param error The wrapped error value.
|
|
90
92
|
* @returns {Err}
|
|
91
93
|
*/
|
|
92
94
|
export function Err<T, E>(error: E): Result<T, E> {
|
package/src/mod.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
import type { Option } from './enum/option.ts';
|
|
2
|
+
import type { Result } from './enum/result.ts';
|
|
3
|
+
|
|
1
4
|
export { None, Some, type Option } from './enum/option.ts';
|
|
2
5
|
export { Err, Ok, type Result } from './enum/result.ts';
|
|
6
|
+
|
|
7
|
+
// export some commonly used types
|
|
8
|
+
export type AsyncOption<T> = Promise<Option<T>>;
|
|
9
|
+
export type AsyncResult<T, E> = Promise<Result<T, E>>;
|
|
10
|
+
export type IOResult<T> = Result<T, Error>;
|
|
11
|
+
export type AsyncIOResult<T> = Promise<IOResult<T>>;
|