Skip to main content
Module

x/optio/mod.ts>flat

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

Converts from Option<Option<T>> to Option<T>.

Examples

Example 1

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

const option: Option<Option<number>> = Some(Some(0));
assertEquals(flat(option), Some(0));