1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 61x 61x 2x 59x 50x 185x | import Iterator from './Iterator'; export default class SelectIterator extends Iterator { constructor(arr, callback) { super(arr); if (typeof callback !== 'function') { throw new Error('Callback must be a function'); } this.callback = callback; } *[Symbol.iterator]() { for (let item of this.arr) { yield this.callback(item); } } } |