Last active
March 31, 2016 13:15
-
-
Save alexeyraspopov/e1d54954bb35774162b11a3cff0cf368 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class KeyedCollection extends Map { | |
map(fn) { | |
const mappedEntries = Array.from(this, ([k, v]) => [k, fn(v, k, this)]); | |
return new this.constructor(mappedEntries); | |
} | |
mapKeys(fn) { | |
const mappedEntries = Array.from(this, ([k, v]) => [fn(k, v, this), v]); | |
return new this.constructor(mappedEntries); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment