Last active
May 14, 2019 21:20
-
-
Save jcreighton/0ea233dd0391d57d866e78a6b538775c to your computer and use it in GitHub Desktop.
Irritable Iterator
This file contains 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
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