The type of the input Promise.
The Promise to convert.
A Promise that resolves to Result<UnwrapPromise<P>, unknown>
.
const successPromise = Result.fromPromise(Promise.resolve('ok'));
const failurePromise = Result.fromPromise(Promise.reject(new Error('fail')));
const resolved = await successPromise;
const rejected = await failurePromise;
assert.deepStrictEqual(resolved, Result.ok('ok'));
assert.ok(Result.isErr(rejected));
Converts a Promise into a Promise that resolves to a
Result
. If the input Promise resolves, theResult
will beOk
with the resolved value. If the input Promise rejects, theResult
will beErr
with the rejection reason.