Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ts_matches/src/parsers/index.ts

Being able to pattern match in typescript
Latest
import * as tsMatches from "https://deno.land/x/ts_matches@v5.4.0/src/parsers/index.ts";

Classes

A Parser is usually a function that takes a value and returns a Parsed value. For this class we have that as our main reason but we want to be able to have other methods including testing and showing text representations.

Functions

We would like to validate that all of the array is of the same type

Must pass the shape that we expect since typescript as of this point can't infer with recursive like structures like this.

Intersection is a good tool to make sure that the validated value is in the intersection of all the validators passed in. Basically an and operator for validators

Create a custom type guard

Must pass the shape that we expect since typescript as of this point can't infer with recursive functions like this.

Union is a good tool to make sure that the validated value is in the union of all the validators passed in. Basically an or operator for validators.