mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-24 09:13:11 +01:00
14 lines
466 B
JavaScript
14 lines
466 B
JavaScript
export default class assert {
|
|
static type(object, type, msg) {
|
|
if (!(object instanceof type)) throw new TypeError(msg || `assertion failed - unexpected type for ${object.toString()}`);
|
|
return object;
|
|
}
|
|
|
|
static truthy(object, msg) {
|
|
if (!object) throw new TypeError(msg || `assertion failed - object is not truthy`);
|
|
}
|
|
|
|
static fail(object, msg) {
|
|
throw new TypeError(msg || `assertion failed - ${object}`);
|
|
}
|
|
}
|