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) • 417 B
JavaScript
import { isNotUndefined } from '../core/undefinable.js';
/**
* Zips _self_ with another `Undefinable<T>`.
* If _self_ is `T` and _other_ is `U`, this method returns `[NotUndefined<T>, NotUndefined<U>]`.
* Otherwise, `undefined` is returned.
*/
export function zipForUndefinable(self, other) {
if (isNotUndefined(self) && isNotUndefined(other)) {
return [self, other];
}
return undefined;
}