-
Notifications
You must be signed in to change notification settings - Fork 133
Open
Description
I was trying to rewrite the "extend" function by introducing more combinators and make it look better. Please do comment on this.
// This function should be renamed ... Any suggestions ??
function objMapWith( fn ) {
return function ( obj ) {
Object.keys( obj ).forEach( function (key) {
fn(key, obj[key]);
});
};
}
// This is not pure function but might be the required one.
// Comments ??
function addPropTo( obj ) {
return function (key, val) {
return obj[key] = val;
}
}
extend = variadic( function (consumer, providers) {
mapWith( objMapWith( addPropTo( consumer )))( providers );
return consumer;
});Metadata
Metadata
Assignees
Labels
No labels