-
Notifications
You must be signed in to change notification settings - Fork 114
Open
Labels
after modulesThis should be postponed until after modularization (temporary label, see #220)This should be postponed until after modularization (temporary label, see #220)enhancement
Description
_.if would take two arguments, a primary function and a conditional function. It would return a new function that, when called, will call the primary function only if the conditional (called with the same arguments) returns a truthy value. It would look something like this:
_.if = function(func, condition){
return function(){
if (condition.apply(this, arguments)){
return func.apply(this, arguments);
}
}
};This way you can write generic functions and then easily add conditions for execution when passing them to iterators. Something like:
items.forEach(_(processItem).if(isNotProcessed));Would this be a useful addition?
bdavidxyz and ddo88
Metadata
Metadata
Assignees
Labels
after modulesThis should be postponed until after modularization (temporary label, see #220)This should be postponed until after modularization (temporary label, see #220)enhancement