20 lines
559 B
JavaScript
20 lines
559 B
JavaScript
// Minimal assertions in the spirit of nanoassert (MIT).
|
|||
|
|
// These guard the public API in development; a production bundler can strip
|
||
|
|
// them by replacing this module with no-ops.
|
||
|
|
|
||
|
|
export function ok (value, message) {
|
||
|
|
if (!value) throw new Error(message || 'assertion failed')
|
||
|
|
}
|
||
|
|
|
||
|
|
/* eslint-disable eqeqeq */
|
||
|
|
export function equal (a, b, message) {
|
||
|
|
if (a != b) throw new Error(message || `${a} != ${b}`)
|
||
|
|
}
|
||
|
|
|
||
|
|
export function notEqual (a, b, message) {
|
||
|
|
if (a == b) throw new Error(message || `${a} == ${b}`)
|
||
|
|
}
|
||
|
|
/* eslint-enable eqeqeq */
|
||
|
|
|
||
|
|
export default ok
|