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>`.

12 lines (11 loc) 321 B
/** * Return _input_ as `T` if the passed _input_ is not `null` and `undefined`. * Otherwise, return the result of _recoverer_. */ export function orElseForMaybe(input, recoverer) { if (input !== undefined && input !== null) { return input; } const fallback = recoverer(); return fallback; }