Skip to main content
Module

x/fuzzy_octo_guacamole/patterns.ts>Pattern

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

Pattern<a> is the generic type for patterns matching a value of type a. A pattern can be any (nested) javascript value.

They can also be wildcards, like P._, P.string, P.number, or other matchers, like P.when(predicate), P.not(pattern), etc.

Read Patterns documentation on GitHub

Examples

const pattern: P.Pattern = { name: P.string }

definition: Matcher<a, unknown, any, any> | (a extends Primitives ? a : unknown extends a ? UnknownPattern : a extends readonly (infer i)[] ? a extends readonly [any, ...any] ? readonly [index in keyof a]: Pattern<a[index]> : readonly [] | readonly [Pattern<i>, ...Pattern<i>[]] : a extends Map<infer k, infer v> ? Map<k, Pattern<v>> : a extends Set<infer v> ? Set<Pattern<v>> : a extends object ? readonly [k in keyof a]?: Pattern<Exclude<a[k], undefined>> : a)