@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
39 lines • 1.25 kB
JavaScript
;
/** use this to ensure that all cases are covered in case of a selection */
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertUnreachable = assertUnreachable;
exports.isNotUndefined = isNotUndefined;
exports.isUndefined = isUndefined;
exports.isNotNull = isNotNull;
exports.guard = guard;
/* v8 ignore next */
function assertUnreachable(x) {
throw new Error(`Unexpected object: ${JSON.stringify(x)}`);
}
function isNotUndefined(x) {
return x !== undefined;
}
function isUndefined(x) {
return x === undefined;
}
function isNotNull(x) {
return x !== null;
}
class GuardError extends Error {
constructor(message) {
super(message);
this.name = 'GuardError';
}
}
/**
* @param assertion - will be asserted
* @param message - if a string, we will use it as the error message, if it is a function, we will call it to produce the error message (can be used to avoid costly message generations)
* @throws GuardError - if the assertion fails
*/
function guard(assertion, message = 'Assertion failed') {
/* v8 ignore next 3 */
if (!assertion) {
throw new GuardError(typeof message === 'string' ? message : message());
}
}
//# sourceMappingURL=assert.js.map