mirror of
https://github.com/Kong/insomnia.git
synced 2026-06-04 06:10:24 -04:00
Move insomnia-data models, services, database code, and common utilities into a dedicated workspace package. Update consumers to import from the new package entrypoints and declare workspace dependencies for the extracted package.
16 lines
502 B
TypeScript
16 lines
502 B
TypeScript
// Throw an error if the condition fails
|
|
// > Not providing an inline default argument for message as the result is smaller
|
|
export function invariant(
|
|
condition: any,
|
|
// Can provide a string, or a function that returns a string for cases where
|
|
// the message takes a fair amount of effort to compute
|
|
message?: string | (() => string),
|
|
): asserts condition {
|
|
if (condition) {
|
|
return;
|
|
}
|
|
// Condition not passed
|
|
|
|
throw new Error(typeof message === 'function' ? message() : message);
|
|
}
|