filestash/public/assets/lib/assert.js
2023-12-18 23:42:09 +11:00

15 lines
423 B
JavaScript

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