const errValue = TernaryResult.err('boom');
const mappedErr = TernaryResult.mapErr(errValue, (error) =>
error.toUpperCase(),
);
const warnPassthrough = TernaryResult.mapErr(
TernaryResult.warn(2, 'slow'),
(error: string) => `${error}!`,
);
assert.deepStrictEqual(mappedErr, TernaryResult.err('BOOM'));
assert.deepStrictEqual(warnPassthrough, TernaryResult.warn(2, 'slow'));
Maps the Err variant while leaving Ok/Warn untouched.
const errValue = TernaryResult.err('boom');
const mappedErr = TernaryResult.mapErr(errValue, (error) =>
error.toUpperCase(),
);
const warnPassthrough = TernaryResult.mapErr(
TernaryResult.warn(2, 'slow'),
(error: string) => `${error}!`,
);
assert.deepStrictEqual(mappedErr, TernaryResult.err('BOOM'));
assert.deepStrictEqual(warnPassthrough, TernaryResult.warn(2, 'slow'));
Maps the Err variant while leaving Ok/Warn untouched.