You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
464 B
17 lines
464 B
/** |
|
* @fileoverview Assertion utilities. |
|
* @author Nicholas C. Zakas |
|
*/ |
|
|
|
/** |
|
* Throws an error if the given condition is not truthy. |
|
* @param {boolean} condition The condition to check. |
|
* @param {string} message The message to include with the error. |
|
* @returns {void} |
|
* @throws {Error} When the condition is not truthy. |
|
*/ |
|
export function assert(condition, message = "Assertion failed.") { |
|
if (!condition) { |
|
throw new Error(message); |
|
} |
|
}
|
|
|