UNPKG

option-t

Version:

A toolkit of Nullable/Option/Result type implementation in ECMAScript. Their APIs are inspired by Rust's `Option<T>` and `Result<T, E>`.

15 lines (14 loc) 372 B
import { isNotNullOrUndefined, isNullOrUndefined } from '../core/maybe.js'; /** * Return _b_ if _a_ is not `null` and `undefined`. * Otherwise, return _a_. */ export function andForMaybe(a, b) { if (isNullOrUndefined(a)) { return a; } if (isNotNullOrUndefined(a)) { return b; } throw new EvalError('here should be unreachable'); }