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.
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)