reqo

0.0.2 • Public • Published

reqo Build Status

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

Readme

Keywords

none

Package Sidebar

Install

npm i reqo

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • jinsyaoommen
  • nackjicholson