Skip to content

Commit

Permalink
src/helpers.ts: idiomatic tweaks to Outcome<T> scheme
Browse files Browse the repository at this point in the history
Signed-off-by: António Meireles <[email protected]>
  • Loading branch information
AntonioMeireles committed Jan 18, 2022
1 parent 52cfe25 commit 4014f0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ interface Failure {
error: Error
}
type Outcome<T> = Success<T> | Failure
const Abnormal = (result: unknown): result is Failure =>
(result as { error?: Error }).error !== undefined
const Ok = <T>(result: unknown): result is Success<T> => !Abnormal(result)
const Abnormal = (outcome: unknown): outcome is Failure =>
(outcome as { error?: Error }).error !== undefined
const Ok = <T>(outcome: unknown): outcome is Success<T> => !Abnormal(outcome)

export {
Abnormal,
Expand Down

0 comments on commit 4014f0c

Please sign in to comment.