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) 294 B
/** * Unwraps a result _input_, returns the content of an `Some(T)`. * If the value is an `None` then return _defaultValue_. */ export function unwrapOrForOption(input, defaultValue) { if (input.ok) { const val = input.val; return val; } return defaultValue; }