Files
insomnia/packages/insomnia-data/common-src/invariant.ts
Bingbing b09cde814d refactor: extract insomnia-data into workspace package (#10010)
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.
2026-06-02 09:49:10 +00:00

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);
}