Skip to main content
Module

x/fuzzy_octo_guacamole/mod.ts>P.when

A playground for testing CI setup that deploys on Deno and NPM
Latest
function P.when
import { P } from "https://deno.land/x/fuzzy_octo_guacamole@v5.0.1/mod.ts";
const { when } = P;

P.when((value) => boolean) returns a pattern which matches if the predicate returns true for the current input.

Read the documentation for P.when on GitHub

Examples

match<{ age: number }>(value) .with({ age: P.when(age => age > 21) }, (x) => 'will match if value.age > 21' )

Type Parameters

input
p extends (value: input) => unknown

Parameters

predicate: p

Returns

GuardP<input, p extends (value: any) => value is infer narrowed ? narrowed : never>

Type Parameters

input
narrowed extends input
excluded

Parameters

predicate: (input: input) => input is narrowed

Returns

GuardExcludeP<input, narrowed, excluded>