cosmjs-util/packages/utils/src/assert.ts
2020-08-06 14:10:08 +02:00

13 lines
410 B
TypeScript

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function assert(condition: any, msg?: string): asserts condition {
if (!condition) {
throw new Error(msg || "condition is not truthy");
}
}
export function assertDefined<T>(value: T | undefined, msg?: string): asserts value is T {
if (value === undefined) {
throw new Error(msg || "value is undefined");
}
}