Skip to content

Commit

Permalink
Merge pull request #6 from faergeek/fix-result-comments
Browse files Browse the repository at this point in the history
fix: improve Result jsdoc comments
  • Loading branch information
faergeek authored Feb 8, 2024
2 parents b6b5928 + 7df606e commit 6e4d926
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 6e4d926

Please sign in to comment.