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

Example for polyfilling TextDecoderStream in previous browsers #116

Open
Krithika3 opened this issue May 11, 2022 · 2 comments
Open

Example for polyfilling TextDecoderStream in previous browsers #116

Krithika3 opened this issue May 11, 2022 · 2 comments
Labels

Comments

@Krithika3
Copy link

Hi I was looking to see if we could get an example to polyfill web-streams TextDecoderStream for browsers like firefox as listed here:
https://developer.mozilla.org/en-US/docs/Web/API/TransformStream

It would be great if I could find an example for the same

@MattiasBuelens
Copy link
Owner

There's a polyfill for TextEncoderStream and TextDecoderStream in the demos of the Streams standard. You can first load web-streams-polyfill to define TransformStream, and then load the encoding stream polyfill.

Even better: the encoding streams polyfill is available as an npm package over at @stardazed/streams-text-encoding. It should be compatible with web-streams-polyfill, so you can do something like:

import 'web-streams-polyfill';
import { TextDecoderStream } from '@stardazed/streams-text-encoding';

readable.pipeThrough(new TextDecoderStream()).pipeTo(/* ... */);

@Krithika3
Copy link
Author

Thanks @MattiasBuelens :) I will try it out. Appreciate your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants