The input UnknownResult type.
The first Result if Ok, otherwise the alternative.
const primary = Result.ok('primary');
const fallback = Result.ok('fallback');
const failure = Result.err('failure');
assert.deepStrictEqual(Result.orElse(primary, fallback), primary);
assert.deepStrictEqual(Result.orElse(failure, fallback), fallback);
const orElseFallback = Result.orElse(Result.ok('default'));
assert.deepStrictEqual(
orElseFallback(Result.err('missing')),
Result.ok('default'),
);
assert.deepStrictEqual(orElseFallback(Result.ok('value')), Result.ok('value'));
Returns the Result if it is Ok, otherwise returns the alternative.
The first Result if Ok, otherwise the alternative.
const primary = Result.ok('primary');
const fallback = Result.ok('fallback');
const failure = Result.err('failure');
assert.deepStrictEqual(Result.orElse(primary, fallback), primary);
assert.deepStrictEqual(Result.orElse(failure, fallback), fallback);
const orElseFallback = Result.orElse(Result.ok('default'));
assert.deepStrictEqual(
orElseFallback(Result.err('missing')),
Result.ok('default'),
);
assert.deepStrictEqual(orElseFallback(Result.ok('value')), Result.ok('value'));
Returns the
Resultif it isOk, otherwise returns the alternative.