Skip to main content
Module

x/fun/mod.ts>option.exists

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function option.exists
import { option } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { exists } = option;

Apply a predicate to the inner value of an Option, returning true if the option is Some and the predicate returns true, otherwise returning false.

Examples

Example 1

import * as O from "./option.ts";
import { pipe } from "./fn.ts";

const positive = (n: number) => n > 0;

const result1 = pipe(O.some(1), O.exists(positive)); // true
const result2 = pipe(O.some(0), O.exists(positive)); // false
const result3 = pipe(O.none, O.exists(positive)); // false

Parameters

predicate: Predicate<A>

Returns

(ua: Option<A>) => boolean