mateusmaso / underscore.prefilter

Underscore helper for pre-filtering methods before calling them

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

underscore.prefilter Build Status

This library is an extension for Underscore which allows wrapping a conditional method before executing the main one, if true it calls the subsequent method.

Features

  • Prevent functions to be called unintentionally.

Dependencies

  • underscore.js (>= 1.5.0)

Node

var _ = require('underscore');
_.mixin(require('underscore.prefilter'));

Examples

var bark = function(sentence) {
  console.log("woof " + sentence + "!");
};

bark = _.prefilter(bark, function(sentence) {
  return !_.isNumber(sentence);
});

bark("woof"); // woof woof!
bark(123); // undefined

License

Copyright (c) 2013-2014 Mateus Maso. Released under an MIT license.

About

Underscore helper for pre-filtering methods before calling them

License:MIT License


Languages

Language:JavaScript 100.0%