Skip to content
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

Use TransformStream in Examples #8

Open
anthumchris opened this issue Mar 5, 2018 · 0 comments
Open

Use TransformStream in Examples #8

anthumchris opened this issue Mar 5, 2018 · 0 comments
Labels
awaiting browser implementation Browsers do not currently support this

Comments

@anthumchris
Copy link
Owner

Refactor with TransformStream as described by @ricea:

The examples would be cleaner with TransformStream, but unfortunately no browser is shipping it yet. You could be really concise, something like (totally untested)

fetchEvent.respondWith(new Response(response.body.pipeThrough(new TransformStream({
  transform(chunk, controller) {
    loaded += chunk.length;
    progress({loaded, total});
    controller.enqueue(chunk);
  }
})), response));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting browser implementation Browsers do not currently support this
Projects
None yet
Development

No branches or pull requests

1 participant