UNPKG

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