1 2 3 4 5 6 7 8 9 10
// Iterator.prototype.map must not leak the original item function* gen() { for (let i = 0; i < 5; i++) { yield { index: i }; } } const mapped = gen().map(x => x.index * 2); for (const val of mapped) {}