-
-
Save thehypergraph/2c74d8eb5b830bb9a5e665760e38556e to your computer and use it in GitHub Desktop.
Node.Js Class Iterator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Symbol.iterator]() { | |
let index = 0 | |
return { | |
next: () => { | |
if (index <= this.items.length) { | |
const res = { value: this.items[index], done: false } | |
index = index + 1 | |
return res | |
} else { | |
return { value: null, done: true } | |
} | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment