Created
October 15, 2017 00:33
-
-
Save aetheryx/81fa81feb8bb806a905e71c152b6e529 to your computer and use it in GitHub Desktop.
Map.filter polyfill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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