mirror of
https://github.com/bcomnes/deploy-to-neocities.git
synced 2026-01-17 15:06:29 +00:00
19 lines
438 B
JavaScript
19 lines
438 B
JavaScript
module.exports = assert
|
|
|
|
class AssertionError extends Error {}
|
|
AssertionError.prototype.name = 'AssertionError'
|
|
|
|
/**
|
|
* Minimal assert function
|
|
* @param {any} t Value to check if falsy
|
|
* @param {string=} m Optional assertion error message
|
|
* @throws {AssertionError}
|
|
*/
|
|
function assert (t, m) {
|
|
if (!t) {
|
|
var err = new AssertionError(m)
|
|
if (Error.captureStackTrace) Error.captureStackTrace(err, assert)
|
|
throw err
|
|
}
|
|
}
|