source: node_modules/es-toolkit/dist/util/invariant.d.mts@ ba17441

Last change on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
3 *
4 * @param {unknown} condition - The condition to evaluate.
5 * @param {string} message - The error message to throw if the condition is false.
6 * @returns {void} Returns void if the condition is true.
7 * @throws {Error} Throws an error if the condition is false.
8 *
9 * @example
10 * // This call will succeed without any errors
11 * invariant(true, 'This should not throw');
12 *
13 * // This call will fail and throw an error with the message 'This should throw'
14 * invariant(false, 'This should throw');
15 */
16declare function invariant(condition: unknown, message: string): asserts condition;
17/**
18 * Asserts that a given condition is true. If the condition is false, an error is thrown with the provided error.
19 *
20 * @param {unknown} condition - The condition to evaluate.
21 * @param {Error} error - The error to throw if the condition is false.
22 * @returns {void} Returns void if the condition is true.
23 * @throws {Error} Throws an error if the condition is false.
24 *
25 * @example
26 * // This call will succeed without any errors
27 * invariant(true, new Error('This should not throw'));
28 *
29 * class CustomError extends Error {
30 * constructor(message: string) {
31 * super(message);
32 * }
33 * }
34 *
35 * // This call will fail and throw an error with the message 'This should throw'
36 * invariant(false, new CustomError('This should throw'));
37 */
38declare function invariant(condition: unknown, error: Error): asserts condition;
39
40export { invariant };
Note: See TracBrowser for help on using the repository browser.