reqo
v0.0.2
Published
Function decorator for validating required options in an options hash.
Downloads
7
Readme
reqo
Function decorator for validating required options in an options hash.
This project mostly exists as an example of $ yo es6nm
generator-es6nm
Example
'use strict';
var reqo = require('reqo');
var decoratedFunc;
// Function where options.a and options.b are both required to exist.
function myFunc(options) {
console.log(options.a + ':' + options.b);
}
decoratedFunc = reqo(myFunc, ['a', 'b']);
// Works, logs 'a:b'
decoratedFunc({a: 'a', b: 'b'});
// Throws a RangeError: Options must contain b
decoratedFunc({a: 'a'});
Install
$ npm install --save reqo