Skip to main content
Module

x/fuzzy_octo_guacamole/patterns.ts>when

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

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