UNPKG

mjdapi

Version:
28 lines (27 loc) 1.08 kB
"use strict"; // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. Object.defineProperty(exports, "__esModule", { value: true }); exports.unreachable = exports.assert = exports.DenoStdInternalError = void 0; /** * All internal non-test code, that is files that do not have `test` or `bench` in the name, must use the assertion functions within `_utils/asserts.ts` and not `testing/asserts.ts`. This is to create a separation of concerns between internal and testing assertions. */ class DenoStdInternalError extends Error { constructor(message) { super(message); this.name = "DenoStdInternalError"; } } exports.DenoStdInternalError = DenoStdInternalError; /** Make an assertion, if not `true`, then throw. */ function assert(expr, msg = "") { if (!expr) { throw new DenoStdInternalError(msg); } } exports.assert = assert; /** Use this to assert unreachable code. */ function unreachable() { throw new DenoStdInternalError("unreachable"); } exports.unreachable = unreachable;