Beginner here, I'm a bit lost with es6 set, map and generators.
How can I select an item in a map, then iterate backwards from that point on effectively? Preferably without going through the whole set/map.
let v = myMap.get('key')
so, from 'v' to the beginning of the map (backwards)?
thank you!
You can create a set of iteration helpers and then compound to create the effect you want:
You can then use and compound like this:
What you probably want is a
slice
of thekeys
from the first element to the index of thekey
, reverse that, iterate over that and get the values from the map.I am assuming your
map
is an object:You don't really need a generator.