Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/silicon/deps.ts>assert

Deno module to generate images from source code using Aloxaf/silicon.
Latest
function assert
import { assert } from "https://deno.land/x/silicon@v1.0.0/deps.ts";

Asserts that the given value satisfies the provided predicate.

import { assert } from "./util.ts";
import is from "./is.ts";

const a: unknown = "hello";
assert(a, is.String);
// a is now narrowed to string

Parameters

x: unknown

The value to be asserted.

pred: Predicate<T>

The predicate function to test the value against.

optional
options: { message?: string; name?: string; } = [UNSUPPORTED]

Optional configuration for the assertion.

Returns

asserts x is T

Nothing. The function has a return type of asserts x is T to help TypeScript narrow down the type of x after the assertion.