varta
Guard your arguments. Verify and throw error if they do not meet your contract
usage
var guard = require('varta');
function log(logger) {
guard(logger).has('log');
}
You can also expect multiple properties from an object:
var guard = require('varta');
function log(logger) {
guard(logger).has('warn', 'info', 'debug');
}
You can save expectations and reuse them in the code:
var verify = require('varta').has('warn', 'info', 'debug');
function log(logger) {
verify(logger);
}
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