Skip to content

Instantly share code, notes, and snippets.

@aetheryx
Created October 15, 2017 00:33
Show Gist options
  • Save aetheryx/81fa81feb8bb806a905e71c152b6e529 to your computer and use it in GitHub Desktop.
Save aetheryx/81fa81feb8bb806a905e71c152b6e529 to your computer and use it in GitHub Desktop.
Map.filter polyfill
Object.defineProperty(Map.prototype, 'filter', {
value: function (filterFunction) {
const myMap = new Map();
for (const [key, value] of this) {
if (filterFunction(value, key, this)) {
myMap.set(key, value);
}
}
return myMap;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment