Function assert

  • Make an assertion, error will be thrown if expr does not have truthy value.

    Parameters

    • expr: unknown

      The expression to test.

    • msg: string = ""

      The optional message to display if the assertion fails.

    Returns asserts expr

    import { assert } from "@std/assert";

    assert("hello".includes("ello")); // Doesn't throw
    assert("hello".includes("world")); // Throws