1 | Object.prototype.map = function(fn){ return Object.entries(this).reduce((acc,[k,v]) => ({...acc,[k]:fn(v,k)}),{}); };
|
2 | Object.prototype.filter = function(fn){ return Object.entries(this).reduce((acc,[k,v]) => fn(v,k) && ({...acc,[k]:v}),{}) || acc; };
|
3 |
|
4 | const map = fn => col => col.map(fn);
|
5 | const filter = fn => col => col.filter(fn);
|
6 |
|
7 | module.exports = {map, filter};
|