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) 423 B
import { isNotNullOrUndefined } from './maybe.js'; /** * Zips _self_ with another `Maybe<T>`. * If _self_ is `T` and _other_ is `U`, this method returns `[NotNullOrUndefined<T>, NotNullOrUndefined<U>]`. * Otherwise, `undefined` is returned. */ export function zipForMaybe(self, other) { if (isNotNullOrUndefined(self) && isNotNullOrUndefined(other)) { return [self, other]; } return undefined; }