-
Notifications
You must be signed in to change notification settings - Fork 163
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
Should we add writableStream.write()? readableStream.read()? #1072
Comments
My impression is that the |
That was my initial impression, but it appears to not be the case: https://wicg.github.io/native-file-system/#dom-filesystemwritablefilestream-write . |
Heh, yeah. I think earlier on we had some thoughts that the via the WritableStreamDefaultWriter should only accept bytes, and we'd provide the Stream.write as a convenience to support blobs and strings as well. But then to get seek/truncate working the underlying sink would have to accept something more complicated anyway. So yeah, now it is just a wrapper around creating a writer. |
An alternative would be to go the other way around, and have |
We are hearing a need for this convenience method from users (at least the write one). One common example is writing to a subprocess stdout. I have opened a small PR to implement |
I was reviewing https://wicg.github.io/native-file-system/#api-filesystemwritablefilestream, which is one of the the major non-TransformStream users of WritableStream in spec land so far. And I noticed they added a
write()
convenience method that just wrapsthis.getWriter().write()
+ a release step, similar to the existingwritableStream.close()
andwritableStream.abort()
.It feels like maybe we're doing something wrong, if specs are subclassing us to add convenience methods in this way. Should we consider adding one-shot writing methods? What about one-shot reading methods?
It would be a nice simplification for folks who are just writing simple code and don't need to care about the exclusivity of their writers/readers...
On the other hand, maybe the real issue here is that it's too hard to add convenience methods to the return value of
getWriter()
? Maybe if that were easier, the NativeFS spec would have stuck with the "acquire a writer first" design, and just added theseek()
andtruncate()
convenience methods to the writer?/cc @mkruisselbrink
The text was updated successfully, but these errors were encountered: