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

x/ts_matches/src/parsers/shape-parser.ts>ShapeParser

Being able to pattern match in typescript
Go to Latest
class ShapeParser
implements IParser<A, B>
import { ShapeParser } from "https://deno.land/x/ts_matches@v5.2.0/src/parsers/shape-parser.ts";

Given an object, we want to make sure the key exists and that the value on the key matches the parser

Constructors

new
ShapeParser(
parserMap: [key in keyof B]: Parser<unknown, B[key]>,
isPartial: boolean,
parserKeys?,
description?,
)

Type Parameters

A extends unknown
Key extends string | number | symbol
B

Methods

parse<C, D>(a: unknown, onParse: OnParse<A, [key in Key]?: B, C, D>): C | D