Skip to main content
Module

x/fuzzy_octo_guacamole/mod.ts

A playground for testing CI setup that deploys on Deno and NPM
Latest
import * as fuzzyOctoGuacamole from "https://deno.land/x/fuzzy_octo_guacamole@v5.0.1/mod.ts";

Variables

P._ is a wildcard pattern, matching any value. It's an alias to P.any.

P.any is a wildcard pattern, matching any value.

P.number.between(min, max) matches number between min and max, equal to min or equal to max.

P.bigint.between(min, max) matches bigint between min and max, equal to min or equal to max.

P.bigint is a wildcard pattern, matching any bigint.

P.boolean is a wildcard pattern, matching any boolean.

P.number.finite matches finite numbers.

P.number.gt(min) matches number greater than min.

P.bigint.gt(min) matches bigint greater than min.

P.number.gte(min) matches number greater than or equal to min.

P.bigint.gte(min) matches bigint greater than or equal to min.

P.number.int matches integer numbers.

P.number.lt(max) matches number smaller than max.

P.bigint.lt(max) matches bigint smaller than max.

P.number.lte(max) matches number smaller than or equal to max.

P.bigint.lte(max) matches bigint smaller than or equal to max.

Symbols used internally within ts-pattern to construct and discriminate Guard, Not, and Select, and AnonymousSelect patterns

P.number.negative matches negative numbers.

P.bigint.negative matches negative bigints.

P.nullish is a wildcard pattern, matching null or undefined.

P.number is a wildcard pattern, matching any number.

P.number.positive matches positive numbers.

P.bigint.positive matches positive bigints.

P.string is a wildcard pattern, matching any string.

P.symbol is a wildcard pattern, matching any symbol.

P._ is a wildcard pattern, matching any value. It's an alias to P.any.

P.any is a wildcard pattern, matching any value.

P.number.between(min, max) matches number between min and max, equal to min or equal to max.

P.bigint.between(min, max) matches bigint between min and max, equal to min or equal to max.

P.bigint is a wildcard pattern, matching any bigint.

P.boolean is a wildcard pattern, matching any boolean.

P.number.finite matches finite numbers.

P.number.gt(min) matches number greater than min.

P.bigint.gt(min) matches bigint greater than min.

P.number.gte(min) matches number greater than or equal to min.

P.bigint.gte(min) matches bigint greater than or equal to min.

P.number.int matches integer numbers.

P.number.lt(max) matches number smaller than max.

P.bigint.lt(max) matches bigint smaller than max.

P.number.lte(max) matches number smaller than or equal to max.

P.bigint.lte(max) matches bigint smaller than or equal to max.

Symbols used internally within ts-pattern to construct and discriminate Guard, Not, and Select, and AnonymousSelect patterns

P.number.negative matches negative numbers.

P.bigint.negative matches negative bigints.

P.nullish is a wildcard pattern, matching null or undefined.

P.number is a wildcard pattern, matching any number.

P.number.positive matches positive numbers.

P.bigint.positive matches positive bigints.

P.string is a wildcard pattern, matching any string.

P.symbol is a wildcard pattern, matching any symbol.

Functions

isMatching takes pattern and returns a type guard function, cheching if a value matches this pattern.

match creates a pattern matching expression.

  • Use .with(pattern, handler) to pattern match on the input.
  • Use .exhaustive() or .otherwise(() => defaultValue) to end the expression and get the result.

P.array(subpattern) takes a sub pattern and returns a pattern, which matches arrays if all their elements match the sub pattern.

P.instanceOf(SomeClass) is a pattern matching instances of a given class.

P.intersection(...patterns) returns a pattern which matches only if every patterns provided in parameter match the input.

P.set(subpattern) takes a sub pattern and returns a pattern that matches sets if all their elements match the sub pattern.

P.not(pattern) returns a pattern which matches if the sub pattern doesn't match.

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.

P.select() is a pattern which will always match, and will inject the selected piece of input in the handler function.

P.set(subpattern) takes a sub pattern and returns a pattern that matches sets if all their elements match the sub pattern.

P.union(...patterns) returns a pattern which matches if at least one of the patterns provided in parameter match the input.

P.array(subpattern) takes a sub pattern and returns a pattern, which matches arrays if all their elements match the sub pattern.

P.instanceOf(SomeClass) is a pattern matching instances of a given class.

P.intersection(...patterns) returns a pattern which matches only if every patterns provided in parameter match the input.

P.set(subpattern) takes a sub pattern and returns a pattern that matches sets if all their elements match the sub pattern.

P.not(pattern) returns a pattern which matches if the sub pattern doesn't match.

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.

P.select() is a pattern which will always match, and will inject the selected piece of input in the handler function.

P.set(subpattern) takes a sub pattern and returns a pattern that matches sets if all their elements match the sub pattern.

P.union(...patterns) returns a pattern which matches if at least one of the patterns provided in parameter match the input.

Type Aliases

P.infer<typeof somePattern> will return the type of the value matched by this pattern.

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

P.infer<typeof somePattern> will return the type of the value matched by this pattern.

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