@rr0/common
Version:
Common and utility classes
26 lines • 674 B
JavaScript
export class AssertionError extends Error {
constructor(message) {
super(message);
}
}
export class ObjectUtils {
static isUndefined(obj) {
return obj === void 0;
}
static isDefined(obj) {
return !ObjectUtils.isUndefined(obj);
}
static isNotSet(obj) {
return ObjectUtils.isUndefined(obj) || obj === null;
}
static isSet(obj) {
return !this.isNotSet(obj);
}
static asSet(obj, msg) {
if (this.isNotSet(obj)) {
throw new AssertionError(msg !== null && msg !== void 0 ? msg : "value is not set");
}
return obj;
}
}
//# sourceMappingURL=ObjectUtils.js.map