8000 Add `.throw` and `.return` interface methods to StreamToAsyncIterator · Issue #1 · basicdays/node-stream-to-async-iterator · GitHub
[go: up one dir, main page]

Skip to content

Add .throw and .return interface methods to StreamToAsyncIterator #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
basicdays opened this issue Jan 19, 2017 · 1 comment · Fixed by #11
Closed

Add .throw and .return interface methods to StreamToAsyncIterator #1

basicdays opened this issue Jan 19, 2017 · 1 comment · Fixed by #11

Comments

@basicdays
Copy link
Owner

Generators can also provide methods to implement a return and throw feature to help handle additional syntax operators in a for-of loop.

For example:

const readStream = fs.createReadStream(__filename);
    for await (const chunk of new S2A(readStream)) {
        console.log(chunk);
        if (chunk === ...) break;
    }

This is how it is used within a vanilla generator:

function* gen(){
  try {
    for (var i = 0;; i++) yield i;
  } finally {
    console.log('done');
  }
}

for (var i of gen()) {
  if (i > 5) break;
}
@basicdays
Copy link
Owner Author
basicdays commented Jan 19, 2017

basicdays added a commit that referenced this issue Mar 16, 2022
-   Breaking Change: Dropping support for Node 11 and below.
-   Breaking Change: Dropping support for Flow.
-   Bug Fix: Resolves #5. Event handlers are cleaned up after each iteration, fixing some memory leak issues.
-   Bug Fix: Resolves #7. Code no longer depends on babel runtimes or regenerator.
-   Bug Fix: Handles stream not buffering due to starving the event loop.
-   Feature: Resolves #1. Now handles `.throw` and `.return` hooks on the async iterator.
-   Feature: Properly closes stream when finished.
-   Feature: Added support for TypeScript.
-   Feature: Support for Node.js versions 12, 14, and 16.
-   Chore: General overhaul of project setup (should not impact what is published).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0