Skip to content

Instantly share code, notes, and snippets.

@Fishrock123
Created August 29, 2019 00:22
Show Gist options
  • Save Fishrock123/d430d3cb6ba5ce152b44e8de6e2e61d0 to your computer and use it in GitHub Desktop.
Save Fishrock123/d430d3cb6ba5ce152b44e8de6e2e61d0 to your computer and use it in GitHub Desktop.

Revisions

  1. Fishrock123 created this gist Aug 29, 2019.
    17 changes: 17 additions & 0 deletions iterators-break-recursion-loop.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    function* f() {
    try {
    yield 1
    yield 2
    yield 3
    } finally {
    yield* f()
    }
    }

    const iter = f()
    while (true) {
    for (const val of iter) {
    console.log(val)
    if (val === 2) break
    }
    }