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