()
| 293 | let idx: number; |
| 294 | let data: V[]; |
| 295 | const next = (): IteratorResult<V> => { |
| 296 | if (!data) { |
| 297 | // lazy till first invocation |
| 298 | data = []; |
| 299 | idx = 0; |
| 300 | this._forEach(node, value => data.push(value)); |
| 301 | } |
| 302 | if (idx >= data.length) { |
| 303 | return { done: true, value: undefined }; |
| 304 | } |
| 305 | |
| 306 | if (!res) { |
| 307 | res = { done: false, value: data[idx++] }; |
| 308 | } else { |
| 309 | res.value = data[idx++]; |
| 310 | } |
| 311 | return res; |
| 312 | }; |
| 313 | return { next }; |
| 314 | } |
| 315 |