Skip to content

Instantly share code, notes, and snippets.

@amiralies
Created July 25, 2019 15:39
Show Gist options
  • Select an option

  • Save amiralies/a019828ce6686d7ccb4df8fd03880dce to your computer and use it in GitHub Desktop.

Select an option

Save amiralies/a019828ce6686d7ccb4df8fd03880dce to your computer and use it in GitHub Desktop.

Revisions

  1. amiralies created this gist Jul 25, 2019.
    8 changes: 8 additions & 0 deletions filter.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    const filter = (obj, fun) =>
    Object.entries(obj).reduce(
    (prev, [key, value]) => ({
    ...prev,
    ...(fun(key, value) ? { [key]: value } : {})
    }),
    {}
    );