Skip to content

Commit

Permalink
fix: improve Result jsdoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
faergeek committed Feb 8, 2024
1 parent b6b5928 commit 7df606e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,24 @@ export class Result<T, E> {
}

/**
* Represents a failure
* Create a box representing failure
*/
static Err<const E>(err: E) {
return new Result<never, E>({ isOk: false, err });
}

/**
* Represents a success
* Create a box representing success
*/
static Ok<T>(value: T) {
return new Result<T, never>({ isOk: true, value });
}

/**
* Combine record of boxes and return either record with their unboxed values
* if all boxes represent a success or the first box representing failure
* otherwise
*/
static all<T extends Readonly<Record<string, Result<unknown, unknown>>>>(
xs: T,
): Result<
Expand Down

0 comments on commit 7df606e

Please sign in to comment.