Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Irritable Iterator
function irritable() {
let step = 0;
return {
next: function() {
step++;
if (step === 1) {
return { value: '😠', done: false };
}
if (step === 2) {
return { value: '😡', done: false };
}
if (step === 3) {
return { value: '🤬', done: false };
}
return { value: undefined, done: true };
}
};
}
Array.prototype[Symbol.iterator] = irritable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment