import { option } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { some } = option;
The some constructer takes any value and wraps it in the Some type.
Examples
Example 1
Example 1
import type { Option } from "./option.ts";
import * as O from "./option.ts";
function fromNilable<A>(a: A | null | undefined): Option<A> {
return a === null || a === undefined ? O.none : O.some(a);
}
const result1 = fromNilable(null); // None
const result2 = fromNilable(1); // Some<number>
Parameters
value: A