-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
fs: add Blob
methods to FileHandle
#40021
Conversation
} | ||
|
||
text() { | ||
return this.readFile({ encoding: 'utf8' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toUSVString
?
https://fetch.spec.whatwg.org/#body-mixin? Ah, I see you want to implement |
Why does it need to be synchronous? |
I think @jasnell is planning on implementing |
I don't feel strongly about it,
Can I create a |
You can create it synchronously but it cannot be read synchronously. So you just create a new instance that has an asynchronous read operation, i.e. just create a new file handle with an start + len offset. |
Parts of
Given that, I think it's fair to assume we don't want My take on this is we should try to match the web spec where it makes sense and deviates where it makes sense, like we do for the |
I agree with this, although it may be desirable in future to have a |
To be honest, I'm not sold on the idea of adding these methods to |
It would be a bit inconsistent/weird to have to import consumers from |
If #40009 lands, I'd be also more inclined to stick to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it explicit, I'd prefer not to do it this way. Let's use stream/consumers
Closing as there doesn’t seem to have a need for this actually. |
Adding
.text()
and.arrayBuffer()
methods toFileHandle
to make it closer to W3CFile
interface.I'm proposing to add
.stream()
in #40016, and I don't think we want to have the.slice()
as it would require a synchronous read of the file.