mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-24 09:13:11 +01:00
15 lines
423 B
JavaScript
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}`);
|
|
}
|
|
}
|