-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix(node/fs): add a createReadStream method to the FileHandle class #27591
base: main
Are you sure you want to change the base?
fix(node/fs): add a createReadStream method to the FileHandle class #27591
Conversation
createReadStream(options?: CreateReadStreamOptions): ReadStream { | ||
assertNotClosed(this, createReadStream.name); | ||
const opts = options as Omit<CreateReadStreamOptions, "encoding">; | ||
return createReadStream(this.#path, opts); |
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.
This opens another file object. We need to reuse #rid
of this file handle.
Please follow what Node.js does here https://github.com/nodejs/node/blob/5770972dc6c0458af5458b8056b16d70905ea9d8/lib/internal/fs/promises.js#L361-L364
chmod(mode: Mode): Promise<void> { | ||
assertNotClosed(this, promises.chmod.name); | ||
return promises.chmod(this.#path, mode); | ||
} | ||
|
||
createReadStream(options?: CreateReadStreamOptions): ReadStream { | ||
assertNotClosed(this, createReadStream.name); |
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.
This assertion doesn't exist in Node.js https://github.com/nodejs/node/blob/5770972dc6c0458af5458b8056b16d70905ea9d8/lib/internal/fs/promises.js#L361-L364
f2859fe
to
d7e0037
Compare
Add the createReadStream method to the FileHandle class in node compat as part of #25554