0.0.2 • Published 9 years ago

reqo v0.0.2

Weekly downloads
8
License
MIT
Repository
github
Last release
9 years ago

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