Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 658 Bytes

resultAsync.md

File metadata and controls

27 lines (18 loc) · 658 Bytes

ResultAsync

Success/Failure/From

const successfulResult = ResultAsync.success('apple');

console.log(await successfulResult.getValueOrThrow()); // 'apple'

const failedResult = ResultAsync.failure('no fruit');

console.log(await failedResult.getErrorOrThrow()); // 'no fruit'
const result = Result.success('apple');
const resultAsync = ResultAsync.from(result);

console.log(await resultAsync.getValueOrThrow()); // 'apple'
const result = Result.failure('no fruit');
const resultAsync = ResultAsync.from(Promise.resolve(result));

console.log(await resultAsync.getErrorOrThrow()); // 'no fruit'