@apptus/esales-api
Version:
Library for making requests to Elevate 4 API v3
17 lines (14 loc) • 546 B
text/typescript
export class AssertionError extends Error {
override name = 'AssertionError';
constructor(message: string) {
super(message);
}
}
/** Asserts that the provided condition is truthy */
export function assert(condition: unknown, message = ''): asserts condition {
if (!condition) throw new AssertionError(message);
}
/** Asserts that the provided value is a non-empty string */
export function assertString(value: unknown, message?: string): asserts value is string {
assert(typeof value === 'string' && value.length > 0, message);
}