varta
Guard your arguments. Verify and throw error if they do not meet your contract
usage
var guard = ;{// this line will throw exception if logger instance is null or doesn't have// a method called `log`:;}
You can also expect multiple properties from an object:
var guard = ;{// this line will throw exception if logger instance is null or doesn't have// all three methods: `warn`, `info`, and `debug`;}
You can save expectations and reuse them in the code:
var verify = ;{// Our expectations are saved above. If the logger does not have all three// methods (`warn`, `info`, and `debug`) the code will throw an exception;}
why?
Failing early is very helpful technique when it comes to maintaining large code bases. If you fail as early as possible you will know exactly where something went wrong, instead of debugging a cryptic error message down the stack.
install
With npm do:
npm install varta
license
MIT