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

feat: implement createReadStream and createWriteStream on FileHandle #1076

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

graue
Copy link
Contributor

@graue graue commented Nov 27, 2024

Closes #1063

Thanks for making this library! My test needed these methods to exist so I took a stab at adding support.

@graue
Copy link
Contributor Author

graue commented Nov 28, 2024

Well, that's embarrassing: the first version of this that I submitted didn't work, due to another issue: the fs.createWriteStream method as defined on memfs volumes did not allow the fd option to be a FileHandle, as Node.js's fs module does.

In my second commit, I've aligned that behavior with the Node API (which makes my first commit work), and in my third commit, I've added a test for this. Let me know if you want me to rebase, or handle any of this differently.

@G-Rath G-Rath changed the title Implement create{Read,Write}Stream on FileHandle feat: implement createReadStream and createWriteStream on FileHandle Nov 28, 2024
@G-Rath
Copy link
Collaborator

G-Rath commented Nov 28, 2024

the fs.createWriteStream method as defined on memfs volumes did not allow the fd option to be a FileHandle

would you be ok doing a dedicated PR for that? it sounds like it's a clean bugfix that can get its own version and changelog entry

@graue
Copy link
Contributor Author

graue commented Nov 28, 2024

Done: #1077

I'll wait for that to be merged then rebase this.

@graue
Copy link
Contributor Author

graue commented Dec 2, 2024

Rebased!

@@ -33,6 +33,14 @@ export class FileHandle implements IFileHandle {
return promisify(this.fs, 'fdatasync')(this.fd);
}

createReadStream(options: opts.IFileHandleReadStreamOptions): IReadStream {
Copy link
Collaborator

Choose a reason for hiding this comment

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

would it be possible to get some basic tests for these?

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.

memfs.createWriteStream() exists, while filehandle.createWriteStream() doesn't
2 participants