check.js
1 // Run-time checking of preconditions. 2 3 function fail(message) { 4 throw new Error(message); 5 } 6 7 // Precondition function that checks if the given predicate is true. 8 // If not, it will throw an error. 9 function argument(predicate, message) { 10 if (!predicate) { 11 fail(message); 12 } 13 } 14 15 export { fail, argument, argument as assert }; 16 export default { fail, argument, assert: argument };