Git Product home page Git Product logo

Comments (3)

MattiasBuelens avatar MattiasBuelens commented on May 31, 2024

Some more thoughts on this...

Right now, the polyfill always replaces the global stream implementations. However, if the native implementation were fully spec-compliant, the polyfill should detect this and simply use the native implementation. (At the moment, Chrome 68 is the closest to full compliance, supporting everything except for readable byte streams.)

If the polyfill would re-export the native implementation, then we can't provide ReadableStream.from without mutating the global ReadableStream. Therefore, we should not use static utility methods.

from web-streams-polyfill.

jimmywarting avatar jimmywarting commented on May 31, 2024

Looks like the spec is planing on adding ReadableStream.from(iterable) now as well.

It could serve as a grate utility to convert the polyfill stream to/from a native one (until you are using native streams - #20)

maybe could have two implementation in the meanwhile?

  • window.ReadableStream.from(iterable) // converts iterable to native
  • polyfill.ReadableStream.from(iterable) // converts iterable to polyfilled version

all doe the later one would quickly be obsolete when you are using native streams.
the native ReadableStream would also need asyncIterable to work...

from web-streams-polyfill.

MattiasBuelens avatar MattiasBuelens commented on May 31, 2024

Good idea! 👍

Indeed, if ReadableStream.from() becomes a thing, the polyfill can provide a version which also handles conversions. Aside from accepting an (async) iterable, it could also accept a native ReadableStream (even if the native stream is not async iterable itself).

I'll keep it in mind when I (eventually) get to this. Right now, I'm keeping an eye on the ongoing work for converting the spec to WebIDL, in particular on the functional changes that will be needed for the polyfill... 👀

from web-streams-polyfill.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.