I noticed that iterators produced by the toIter and iterator methods don't have a Symbol.iterator/@@iterator method on them and thus won't work with for..in, yield*, new Set(), etc. This is mentioned in the comments as part of iterator protocol, so before I submit a PR I was wondering: is that an intentional omission?
It'd be nice to have in ES6, so the resultant iterators can be used with things like
function* flatten(iterable) {
for (let item of iterable) {
if (item[Symbol.iterator]) yield* flatten(item);
yield item;
}
}
Hey there!
I noticed that iterators produced by the
toIter
anditerator
methods don't have aSymbol.iterator
/@@iterator
method on them and thus won't work withfor..in
,yield*
,new Set()
, etc. This is mentioned in the comments as part of iterator protocol, so before I submit a PR I was wondering: is that an intentional omission?It'd be nice to have in ES6, so the resultant iterators can be used with things like