filestash/public/assets/lib/assert.js
2024-02-26 00:23:39 +11:00

15 lines
459 B
JavaScript

export default class assert {
static type(object, type, msg) {
if (object instanceof type) return;
throw new Error(msg || `assertion failed - unexpected type for ${object.toString()}`);
}
static truthy(object, msg) {
if (object) return;
throw new Error(msg || `assertion failed - object is not truthy`);
}
static fail(object, msg) {
throw new Error(msg || `assertion failed - ${object}`);
}
}