Last active
July 8, 2021 09:50
-
-
Save Lcfvs/97dd2e1ea922621e2cbbfa783a1d3323 to your computer and use it in GitHub Desktop.
abort controller generator
This file contains hidden or 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* controller (end) { | |
while (end !== (yield)) {} | |
} | |
const end = Symbol() | |
const it = controller(end) | |
console.log(it.next()) // { value: undefined, done: false } | |
console.log(it.next(end)) // { value: undefined, done: true } -> aborted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment