ts-results
Advanced tools
Comparing version 2.0.0 to 2.0.1
export declare class Err<E> { | ||
readonly val: E; | ||
static readonly EMPTY: Err<void>; | ||
readonly ok = false; | ||
@@ -18,2 +19,3 @@ readonly err = true; | ||
readonly val: T; | ||
static readonly EMPTY: Ok<void>; | ||
readonly ok = true; | ||
@@ -20,0 +22,0 @@ readonly err = false; |
@@ -43,2 +43,3 @@ export class Err { | ||
} | ||
Err.EMPTY = new Err(undefined); | ||
export class Ok { | ||
@@ -70,2 +71,3 @@ constructor(val) { | ||
} | ||
Ok.EMPTY = new Ok(undefined); | ||
export function Results(...results) { | ||
@@ -72,0 +74,0 @@ const okResult = []; |
{ | ||
"name": "ts-results", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "A typescript implementation of Rust's Result object.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,2 +16,3 @@ # ts-results | ||
* [Else](#else) | ||
* [Empty](#empty) | ||
* [Combining Results](#combining-results) | ||
@@ -152,2 +153,13 @@ * [Usage with rxjs](#usage-with-rxjs) | ||
#### Empty | ||
```typescript | ||
function checkIsValid(isValid: boolean): Result<void, Error> { | ||
if (isValid) { | ||
return Ok.EMPTY; | ||
} else { | ||
return new Err(new Error("Not valid")) | ||
} | ||
} | ||
``` | ||
#### Combining Results | ||
@@ -154,0 +166,0 @@ There may be some cases where we have two or more separate `Result` objects and we want to do something with both values. |
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
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
24903
233
341