Skip to content

Commit

Permalink
refactor: update generics in trySync and tryAsync functions; remove s…
Browse files Browse the repository at this point in the history
…ervices.ts
  • Loading branch information
braden-w committed Dec 24, 2024
1 parent 344f3d5 commit 8e705c7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export function trySync<T, E>({
mapErr,
}: {
try: () => T;
mapErr: (error: unknown) => E;
mapErr: (error: unknown) => Err<E>;
}): Result<T, E> {
try {
const data = operation();
return Ok(data);
} catch (error) {
return Err(mapErr(error));
return mapErr(error);
}
}

Expand All @@ -36,12 +36,12 @@ export async function tryAsync<T, E>({
mapErr,
}: {
try: () => Promise<T>;
mapErr: (error: unknown) => E;
mapErr: (error: unknown) => Err<E>;
}): Promise<Result<T, E>> {
try {
const data = await operation();
return Ok(data);
} catch (error) {
return Err(mapErr(error));
return mapErr(error);
}
}

0 comments on commit 8e705c7

Please sign in to comment.