jmou/yakatak
git clone https://github.com/jmou/yakatak.git
git clone git@github.com:jmou/yakatak.git
Loading…
(top)/operation/src/utils.ts
language: TypeScript
262 Bytes / 12 lines / 10 loc
History
View raw
class AssertionError extends Error {}

export function assert(expr: unknown): asserts expr {
  if (expr === false || expr == null) {
    throw new AssertionError();
  }
}

export function checked<T>(value: T): NonNullable<T> {
  assert(value);
  return value;
}