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) 227 B
import { isNotNull } from '../core/nullable.js'; /** * Return _b_ if _a_ is not `null`. * Otherwise, return _a_. */ export function andForNullable(a, b) { if (isNotNull(a)) { return b; } return null; }