import { is } from "https://deno.land/x/typeguardkit@0.33.0/mod.ts";
is
wraps asserter
with a predicate signature, creating a type guard, so
that value
can be narrowed to Type
. If asserter.assert
throws an error,
is
will catch it and return false
. Otherwise, is
will return true
.
Example:
import { _string, is } from "typeguardkit";
function handleUnknown(x: unknown) {
if (is(_string, x)) {
handleString(x);
}
}
function handleString(x: string) {}