Converts a Promise into a Promise that resolves to a TernaryResult.
TernaryResult
const resolved = await TernaryResult.fromPromise(Promise.resolve('ok'));const rejected = await TernaryResult.fromPromise( Promise.reject(new Error('fail')),);assert.deepStrictEqual(resolved, TernaryResult.ok('ok'));assert.isTrue(TernaryResult.isErr(rejected)); Copy
const resolved = await TernaryResult.fromPromise(Promise.resolve('ok'));const rejected = await TernaryResult.fromPromise( Promise.reject(new Error('fail')),);assert.deepStrictEqual(resolved, TernaryResult.ok('ok'));assert.isTrue(TernaryResult.isErr(rejected));
Converts a Promise into a Promise that resolves to a
TernaryResult.