ts-results
Advanced tools
Comparing version 1.0.5 to 1.1.0-beta.1
@@ -9,7 +9,22 @@ interface BaseResult<T, E> { | ||
*/ | ||
else(val: T): T; | ||
else<T2>(val: T2): T | T2; | ||
unwrap(): T; | ||
expect(msg: string): T; | ||
asErr(): Result<never, E>; | ||
asOk(): Result<T, never>; | ||
/** | ||
* This value doesn't exist at runtime! It's only used so that we can extract the type E given Result<T, E> | ||
*/ | ||
_e: E; | ||
/** | ||
* This value doesn't exist at runtime! It's only used so that we can extract the type T given Result<T, E> | ||
*/ | ||
_t: T; | ||
} | ||
export interface Ok<T, E> extends BaseResult<T, E> { | ||
export interface Ok<T = any, E = never> extends BaseResult<T, E> { | ||
readonly ok: true; | ||
readonly err: false; | ||
readonly val: T; | ||
} | ||
export interface Err<T = never, E = any> extends BaseResult<T, E> { | ||
readonly ok: false; | ||
@@ -19,10 +34,5 @@ readonly err: true; | ||
} | ||
export interface Err<T, E> extends BaseResult<T, E> { | ||
readonly ok: true; | ||
readonly err: false; | ||
readonly val: T; | ||
} | ||
export declare type Result<T, E> = Ok<T, E> | Err<T, E>; | ||
export declare function Ok<T, E>(val: T): Result<T, E>; | ||
export declare function Err<T, E>(val: E): Result<T, E>; | ||
export declare function Ok<T, E = never>(val: T): Result<T, E>; | ||
export declare function Err<T = never, E = any>(val: E): Result<T, E>; | ||
export declare function Results<T1, E1, T2, E2>(result1: Result<T1, E1>, result2: Result<T2, E2>): Result<[T1, T2], E1 | E2>; | ||
@@ -29,0 +39,0 @@ export declare function Results<T1, E1, T2, E2, T3, E3>(result1: Result<T1, E1>, result2: Result<T2, E2>, result3: Result<T3, E3>): Result<[T1, T2, T3], E1 | E2 | E3>; |
@@ -50,3 +50,3 @@ class ResultImpl { | ||
} | ||
asError() { | ||
asErr() { | ||
return this; | ||
@@ -53,0 +53,0 @@ } |
{ | ||
"name": "ts-results", | ||
"version": "1.0.5", | ||
"version": "1.1.0-beta.1", | ||
"description": "A typescript implementation of Rust's Result object.", | ||
@@ -14,3 +14,6 @@ "main": "index.js", | ||
}, | ||
"peerDependencies": { | ||
"rxjs": "^6.1.0" | ||
}, | ||
"readme": "README.md" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15692
9
212
1
2