Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/optio/operators/transform.ts>zip

Minimum option type port of Rust
Latest
function zip
import { zip } from "https://deno.land/x/optio@1.0.0/operators/transform.ts";

Zips option with another Option.

If option is Some<T> and other is Some<U>, returns Some<[T, | U]>; Otherwise None.

Examples

Example 1

import { None, Some } from "https://deno.land/x/optio/spec.ts";
import { zip } from "https://deno.land/x/optio/operators/transform.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(zip(Some(0), Some(1)), Some<[0, 1]>([0, 1]));
assertEquals(zip(Some(0), None), None);

Parameters

option: Option<T>
other: Option<U>