1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 30x 30x 3x 27x 23x 55x 52x 17x | import Iterator from './Iterator'; export default class SkipIterator extends Iterator { constructor(arr, count) { super(arr); if (!count || count < 1) { throw new Error('The count must be larger than 0'); } this.count = count; } *[Symbol.iterator]() { for (let item of this.arr) { yield item; if (--this.count <= 0) { break; } } } } |