2019-02-05 21:05:24 -08:00
|
|
|
'use strict';
|
|
|
|
|
2019-03-13 22:43:00 +08:00
|
|
|
let error;
|
|
|
|
function lazyError() {
|
2024-10-09 02:42:16 -04:00
|
|
|
return error ??= require('internal/errors').codes.ERR_INTERNAL_ASSERTION;
|
2019-03-13 22:43:00 +08:00
|
|
|
}
|
2019-11-27 22:56:21 -08:00
|
|
|
|
2019-02-05 21:05:24 -08:00
|
|
|
function assert(value, message) {
|
|
|
|
if (!value) {
|
2019-03-13 22:43:00 +08:00
|
|
|
const ERR_INTERNAL_ASSERTION = lazyError();
|
|
|
|
throw new ERR_INTERNAL_ASSERTION(message);
|
2019-02-05 21:05:24 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-12 16:44:42 -08:00
|
|
|
function fail(message) {
|
2019-03-13 22:43:00 +08:00
|
|
|
const ERR_INTERNAL_ASSERTION = lazyError();
|
|
|
|
throw new ERR_INTERNAL_ASSERTION(message);
|
2019-02-12 16:44:42 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
assert.fail = fail;
|
|
|
|
|
2019-02-05 21:05:24 -08:00
|
|
|
module.exports = assert;
|