I'm trying to use the new Map object from Javascript EC6, since it's already supported in the latest Firefox and Chrome versions.
But I'm finding it very limited in "functional" programming, because it lacks classic map, filter etc. methods that would work nicely with a [key, value]
pair. It has a forEach but that does NOT returns the callback result.
If I could transform its map.entries()
from a MapIterator into a simple Array I could then use the standard .map
, .filter
with no additional hacks.
Is there a "good" way to transform a Javascript Iterator into an Array?
In python it's as easy as doing list(iterator)
... but Array(m.entries())
return an array with the Iterator as its first element!!!
EDIT
I forgot to specify I'm looking for an answer which works wherever Map works, which means at least Chrome and Firefox (Array.from does not work in Chrome).
PS.
I know there's the fantastic wu.js but its dependency on traceur puts me off...
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…