I recently converted some code that made use of regular objects as maps to the new es6 Map
class. I encountered an issue pretty quickly as, while the Map
class includes a forEach
like Array
, it does not include a some
method along with many other Array.prototype
methods.
To give some context, the original code with regular JS objects looked something like this:
var map = {
entry1: 'test',
entry2: 'test2'
};
Object.keys(map).some(key => {
var value = map[key];
// Do something...found a match
return true;
});
The Map
class does include an entries
method but sadly this returns an Iterator
object. This doesn't include any easy way to access the Array.prototype
methods either.
I'm curious if there's a clean way to do this or if I'm barking up the wrong tree.