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