• Zips two optionals into one with fn.

    Type Parameters

    • T

    • U

    • R

    Parameters

    • fn: ((t, u) => R)

      The zipping operation about T and U.

        • (t, u): R
        • Parameters

          • t: T
          • u: U

          Returns R

    Returns ((optA) => ((optB) => Option<R>))

    The zipped optional of tuple.

    Examples

    import { some, none, zipWith } from "./option.ts";
    import { assertEquals } from "../deps.ts";

    interface Point {
    x: number;
    y: number;
    }

    const newPoint = zipWith((x: number, y: number): Point => ({
    x,
    y,
    }));

    assertEquals(newPoint(some(17.5))(some(42.7)), some({ x: 17.5, y: 42.7 }));
    assertEquals(newPoint(none())(none()), none());

Generated using TypeDoc