anki/ts/lib/typing.ts

17 lines
427 B
TypeScript
Raw Normal View History

2021-04-13 10:57:08 +02:00
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export function assertUnreachable(x: never): never {
throw new Error(`unreachable: ${x}`);
}
export type Callback = () => void;
export function singleCallback(...callbacks: Callback[]): Callback {
return () => {
for (const cb of callbacks) {
cb();
}
};
}