Skip to content

Instantly share code, notes, and snippets.

@Fishrock123
Created August 28, 2019 23:09
Show Gist options
  • Save Fishrock123/05dc69d0cfef602178468a26b6dcd2b8 to your computer and use it in GitHub Desktop.
Save Fishrock123/05dc69d0cfef602178468a26b6dcd2b8 to your computer and use it in GitHub Desktop.
iterator-break-yield-not-done.js
function* f() {
try {
yield 1
yield 2
yield 3
} finally {
yield 4
yield 5
}
}
const iter = f()
for (const val of iter) {
console.log(val)
if (val === 2) break
}
console.log(iter.next())
console.log(iter.next())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment