refactor: cleanup assert() & AssertionError definitions (#13859)

This commit is contained in:
Leo Kettmeir 2022-03-19 13:57:37 +01:00 committed by GitHub
parent ad8e238348
commit e55dee7fd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 60 deletions

View file

@ -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 {