Closed MattiasBuelens closed 2 years ago
I'm seeing all this _
prefix everywhere all over the pr and in all the files... why don't you just use #
instead?
I still ship a build for ES5, so I have to be very careful with what syntax features I can or cannot use. The down-level emit for private fields uses WeakMap
, and I'm not 100% sure if that's safe to use everywhere... 😬
I could move everything into a semi-private Symbol("state")
or something (like in Node), and replace Symbol
with String
on platforms that don't support it. Not sure yet. 😛
I'm not sure if typescript can handle that down leveling for you, don't use typescript... but i prefer the god old _ prefix over symbol cuz it's cleaner code.
I could throw Babel into the mix and use the loose
option instead. That changes the emit to generate a unique property name for the private field instead, which would work on ES5. See demo.
It would make the brand checks nicer though, since you can do #privateField in this
instead and be guaranteed that this
was constructed by your class. See docs. This ties in with https://github.com/MattiasBuelens/web-streams-polyfill/issues/70#issuecomment-851058462.
Anyway, I'll leave that for another time. 😛
This re-implements
TransformStream
to use the public API ofReadableStream
andWritableStream
, rather than using internal abstract ops. The idea is that, in the future, we could construct a polyfillTransformStream
on top of a nativeReadableStream
and/orWritableStream
.This also adds partial support for
WritableStreamDefaultController.signal.reason
, which we use to detect whenwritable.abort(reason)
is called. We do have to "cheat" a bit here, sinceAbortSignal.reason
may not yet be supported everywhere andweb-streams-polyfill
does not attempt to polyfill this API by itself.