1 | export default class MapWithFilter extends Map {
|
2 | constructor (data) {
|
3 | super(data)
|
4 | }
|
5 |
|
6 | filter (predicate) {
|
7 | return new MapWithFilter(Array.from(this.entries()).filter(([ id, entry ], index, array) => predicate(entry, index, array)))
|
8 | }
|
9 |
|
10 | toArray () {
|
11 | return Array.from(this).map(([ , entry ]) => entry)
|
12 | }
|
13 | }
|