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

Replace createWriter, FileSystemWriter with createWritable, WritableFileStream #62

Merged
merged 2 commits into from
Mar 10, 2020

Conversation

oyiptong
Copy link
Collaborator

@oyiptong oyiptong commented Jun 11, 2019

This adds specs for WritableFileStream and the factory and options.
It links to WritableStreams related specs, with an inheritance
relationship.


Preview | Diff

@oyiptong
Copy link
Collaborator Author

@domenic, what do you think of this PR as a response to #19?

In particular, what do you think of the initialization of position in createWritable(). This would be used instead of a seek() method on the WritableFileStream.

Copy link
Contributor

@mkruisselbrink mkruisselbrink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good start, although I do wonder about the exact API shape in a number of places.... Interested to hear what domenic's thoughts are.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
@oyiptong oyiptong changed the title Replace createWriter, FileSystemWRiter with createWritable, WritableFileStream Replace createWriter, FileSystemWriter with createWritable, WritableFileStream Jun 12, 2019
index.bs Outdated Show resolved Hide resolved
index.bs Outdated

<xmp class=idl>
[Exposed=(Window,Worker), SecureContext]
interface FileSystemWriter {
interface FileSystemWritableFileStream : WritableStream {
Promise<void> write(unsigned long long position, (BufferSource or Blob or USVString) data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't define write() and close(); users should call those via the writer.

To customize the behavior of the writer, instead you need to define (in the definition of createWritable) what the underlying sink algorithms are. See https://fetch.spec.whatwg.org/#concept-construct-readablestream and its call sites for some rough guidance (although that's for readable; for writable you'd be using https://streams.spec.whatwg.org/#create-writable-stream).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of defining write() and truncate(), so that FileSystemWritableFileStream can be used directly?

For instance, one could do:

const stream = await handle.createWritable();
await stream.write(new Blob(['foo']); // New method, peer to `seek` and `truncate`.
await stream.close(); // Overrided method from WritableStream.

At the same time, the underlying sink algorithms will be implemented to accept WriteParams to execute commands, or to take byte-like data.

index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
…ileStream

This adds specs for `WritableFileStream` and options.

It links to `WritableStreams` related specs, with an inheritance
relationship.
@oyiptong
Copy link
Collaborator Author

Closes #19

@mkruisselbrink mkruisselbrink merged commit 48e383f into WICG:master Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants