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) 273 B
import { mapOrForOption } from './map_or.js'; /** * Return `T` if _input_ is `Some(T)`. * Otherwise, return `null`. */ export function toNullableFromOption(input) { const rv = mapOrForOption(input, null, (inner) => { return inner; }); return rv; }