Skip to content

Instantly share code, notes, and snippets.

@Fishrock123
Created August 28, 2019 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fishrock123/5bdcf236efd4a4f5004bb372a34d02e3 to your computer and use it in GitHub Desktop.
Save Fishrock123/5bdcf236efd4a4f5004bb372a34d02e3 to your computer and use it in GitHub Desktop.
breaking an iteratable with yields in finally
function* f() {
try {
yield 1
yield 2
yield 3
} finally {
yield 4
yield 5
}
}
for (const val of f()) {
console.log(val)
if (val === 2) break
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment