Skip to content

Instantly share code, notes, and snippets.

@thehypergraph
Created July 20, 2023 01:38
Show Gist options
  • Save thehypergraph/2c74d8eb5b830bb9a5e665760e38556e to your computer and use it in GitHub Desktop.
Save thehypergraph/2c74d8eb5b830bb9a5e665760e38556e to your computer and use it in GitHub Desktop.
Node.Js Class Iterator
[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