Skip to content

Instantly share code, notes, and snippets.

@behnamazimi
Last active September 1, 2020 07:37
Show Gist options
  • Save behnamazimi/564411c371d10e480fd6f956247594cf to your computer and use it in GitHub Desktop.
Save behnamazimi/564411c371d10e480fd6f956247594cf to your computer and use it in GitHub Desktop.
const data = {
items: ["A", "B", "C"],
pointerIndex: 0,
next() {
if (this.pointerIndex < this.items.length) // if not done
return { value: this.items[this.pointerIndex++], done: false }
else // if done
return { value: undefined, done: true };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment