Skip to main content
Module

x/fuzzy_octo_guacamole/mod.ts>Pattern.optional

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

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 the documentation for P.optional 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

Returns

Chainable<OptionalP<input, p>, "optional">