Skip to main content
Module

x/fuzzy_octo_guacamole/mod.ts>isMatching

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

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

Read documentation for isMatching on GitHub

Examples

const hasName = isMatching({ name: P.string })

declare let input: unknown

if (hasName(input)) { // input inferred as { name: string } return input.name }

Type Parameters

p extends Pattern<unknown>

Parameters

pattern: p

Returns

(value: unknown) => value is P.infer<p>

isMatching takes pattern and a value and checks if the value matches this pattern.

Read documentation for isMatching on GitHub

Examples

declare let input: unknown

if (isMatching({ name: P.string }, input)) { // input inferred as { name: string } return input.name }

Type Parameters

p extends Pattern<unknown>

Parameters

pattern: p
value: unknown

Returns

value is P.infer<p>