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

13 lines (12 loc) 373 B
import { isNotNull } from '../core/nullable.js'; /** * Zips _self_ with another `Nullable<T>`. * If _self_ is `T` and _other_ is `U`, this method returns `[NotNull<T>, NotNull<U>]`. * Otherwise, `null` is returned. */ export function zipForNullable(self, other) { if (isNotNull(self) && isNotNull(other)) { return [self, other]; } return null; }