Skip to content

Instantly share code, notes, and snippets.

@behnamazimi
Created December 27, 2019 11:22
Show Gist options
  • Save behnamazimi/be35b5f133e703c991818a0e4f211663 to your computer and use it in GitHub Desktop.
Save behnamazimi/be35b5f133e703c991818a0e4f211663 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 done
return { value: this.items[this.pointerIndex++], done: false }
else // if not done
return { value: undefined, done: true };
}
}
for(let item of data) {
console.log(item);
}
//o: Uncaught TypeError: data is not iterable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment