merged with main

This commit is contained in:
lomonoshka
2023-08-24 10:33:05 +03:00
13 changed files with 3203 additions and 1735 deletions

18
src/utils/invariant.ts Normal file
View File

@@ -0,0 +1,18 @@
export function invariant<T = unknown>(
condition: T,
errorMessage?: ((condition: T) => string) | string,
): asserts condition {
if (condition) {
return;
}
if (typeof errorMessage === 'undefined') {
throw new Error('Invariant failed');
}
if (typeof errorMessage === 'string') {
throw new Error(errorMessage);
}
throw new Error(errorMessage(condition));
}