Skip to content

mateusmaso/underscore.prefilter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published