From 2ae2ebc8aa7c4600f499ab7d2264dcb1d16db4ae Mon Sep 17 00:00:00 2001 From: Elizabeth Date: Mon, 2 Jun 2025 19:27:15 -0700 Subject: Fixes when getStdout would throw early --- u/fn/either.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'u/fn/either.ts') diff --git a/u/fn/either.ts b/u/fn/either.ts index 54f9fc2..ffe8033 100644 --- a/u/fn/either.ts +++ b/u/fn/either.ts @@ -32,7 +32,7 @@ export class Either implements IEither { private readonly self: Left | Right; private constructor( - init: { err?: E, ok?: T }, + init: { err?: E; ok?: T }, public readonly _tag: IEitherTag = iEitherTag, ) { this.self = | Right>{ @@ -85,11 +85,11 @@ export class Either implements IEither { } static left(e: E): IEither { - return new Either({ err: e}); + return new Either({ err: e }); } static right(t: T): IEither { - return new Either({ok: t}); + return new Either({ ok: t }); } static fromFailable(s: Supplier): IEither { @@ -100,12 +100,12 @@ export class Either implements IEither { } } - static async fromFailableAsync(s: Promise): Promise> { - try { - return Either.right(await s); - } catch (e) { - return Either.left(e as E); - } + static async fromFailableAsync( + s: Supplier>, + ): Promise> { + return await s() + .then((t: T) => Either.right(t)) + .catch((e: E) => Either.left(e)); } } -- cgit v1.2.3-70-g09d2