const filter = (obj, fun) => Object.entries(obj).reduce( (prev, [key, value]) => ({ ...prev, ...(fun(key, value) ? { [key]: value } : {}) }), {} );