Skip to content

Instantly share code, notes, and snippets.

@Lcfvs
Last active July 8, 2021 09:50
Show Gist options
  • Save Lcfvs/97dd2e1ea922621e2cbbfa783a1d3323 to your computer and use it in GitHub Desktop.
Save Lcfvs/97dd2e1ea922621e2cbbfa783a1d3323 to your computer and use it in GitHub Desktop.
abort controller generator
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