How can one iterate over an ES6 Map or Set in Coffeescript?
In Javascript one would use e.g.
s = new Set()
s.add({a: 1})
for (x of s) {
console.log(x);
}
However Coffeescript has its own of
operator that gets converted to in
, i.e.:
console.log(x) for x of s
becomes ... for (x in s) { ... }
.
How can one access Javascript's of
operator in Coffeescript?
One could write their own custom iterator by cycling over s.values().next()
, but that'd be an abomination. :)