mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
refactor: cleanup assert() & AssertionError definitions (#13859)
This commit is contained in:
parent
ad8e238348
commit
e55dee7fd8
8 changed files with 30 additions and 60 deletions
|
@ -21,7 +21,6 @@
|
|||
BigInt64ArrayPrototype,
|
||||
BigUint64ArrayPrototype,
|
||||
DataView,
|
||||
Error,
|
||||
Int8ArrayPrototype,
|
||||
Int16ArrayPrototype,
|
||||
Int32ArrayPrototype,
|
||||
|
@ -58,24 +57,7 @@
|
|||
WeakMapPrototypeSet,
|
||||
} = globalThis.__bootstrap.primordials;
|
||||
const consoleInternal = window.__bootstrap.console;
|
||||
|
||||
class AssertionError extends Error {
|
||||
constructor(msg) {
|
||||
super(msg);
|
||||
this.name = "AssertionError";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {unknown} cond
|
||||
* @param {string=} msg
|
||||
* @returns {asserts cond}
|
||||
*/
|
||||
function assert(cond, msg = "Assertion failed.") {
|
||||
if (!cond) {
|
||||
throw new AssertionError(msg);
|
||||
}
|
||||
}
|
||||
const { AssertionError, assert } = window.__bootstrap.infra;
|
||||
|
||||
/** @template T */
|
||||
class Deferred {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue