Skip to content

Commit

Permalink
feat: add helper for emptyOk and emptyErr
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenKube committed Sep 3, 2019
1 parent 05e43a6 commit d617bae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ console.log(result.xor(result2)); // => Some(42)
export const ok = <T, E>(value: T): Result<T, E> => new Ok(value);
export const err = <T, E>(error: E): Result<T, E> => new Err(error);

export const emptyOk = <E>(): Result<void, E> => new Ok(undefined);
export const emptyErr = <T>(): Result<T, void> => new Err(undefined);

export const some = <T>(value: T): Option<T> => new Some(value);
export const none = <T>(): Option<T> => new None();
```
Expand Down
3 changes: 3 additions & 0 deletions src/result.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {Option, some, none} from "./option";

export const emptyOk = <E>(): Result<void, E> => new Ok(undefined);
export const emptyErr = <T>(): Result<T, void> => new Err(undefined);

export const ok = <T, E>(value: T): Result<T, E> => new Ok(value);
export const err = <T, E>(error: E): Result<T, E> => new Err(error);

Expand Down

0 comments on commit d617bae

Please sign in to comment.