* Verify that a certain condition is met, or throw an error if otherwise. * * This is useful for communicating expectations in the code to other human * readers as well as catching bugs that accidentally violate these expectations. * * ```js * const { assert } = require('ember-cli/lib/debug');
(description, condition)
| 23 | * If falsy, an error will be thrown. |
| 24 | */ |
| 25 | function assert(description, condition) { |
| 26 | if (!description) { |
| 27 | throw new Error('When calling `assert`, you must provide a description as the first argument.'); |
| 28 | } |
| 29 | |
| 30 | if (condition) { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | throw new Error(`ASSERTION FAILED: ${description}`); |
| 35 | } |
| 36 | |
| 37 | module.exports = assert; |
no outgoing calls
no test coverage detected
searching dependent graphs…