true-myth
Version:
A library for safe functional programming in JavaScript, with first-class support for TypeScript
22 lines (21 loc) • 473 B
JavaScript
/**
Helpers to make it easier to test `Maybe` and `Result`.
@module
*/
import { isInstance as isMaybe } from './maybe.js';
export function unwrap(wrapped) {
if (isMaybe(wrapped)) {
return wrapped.value;
}
else {
return wrapped.value;
}
}
/**
Unwrap the contained {@linkcode Err} error. Throws if `result` is {@linkcode
Ok}.
*/
export function unwrapErr(result) {
return result.error;
}
//# sourceMappingURL=test-support.js.map