Skip to main content
Module

x/fuzzy_octo_guacamole/patterns.ts>optional

A playground for testing CI setup that deploys on Deno and NPM
Go to Latest
function optional
import { optional } from "https://deno.land/x/fuzzy_octo_guacamole@v2.0.0/patterns.ts";

P.optional(subpattern) takes a sub pattern and returns a pattern which matches if the key is undefined or if it is defined and the sub pattern matches its value.

Read P.optional documentation on GitHub

Examples

match(value) .with({ greeting: P.optional('Hello') }, () => 'will match { greeting?: "Hello" }')

Type Parameters

input
p extends unknown extends input ? UnknownPattern : Pattern<input>

Parameters

pattern: p