mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-19 06:46:15 +01:00
15 lines
474 B
JavaScript
15 lines
474 B
JavaScript
export default class assert {
|
|
static type(object, type, msg) {
|
|
if (object instanceof type) return;
|
|
throw new Error(msg ? msg : `assertion failed - unexpected type for ${object.toString()}`);
|
|
}
|
|
|
|
static truthy(object, msg) {
|
|
if (object) return;
|
|
throw new Error(msg ? msg : `assertion failed - object is not truthy`);
|
|
}
|
|
|
|
static fail(object, msg) {
|
|
throw new Error(msg ? msg : `assertion failed - ${object}`);
|
|
}
|
|
}
|