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

Docs: fixes filehandle.read docs to show default buffer value length as 0 #39163

Closed
wants to merge 1 commit into from

Conversation

rbrishabh
Copy link
Contributor

@rbrishabh rbrishabh commented Jun 26, 2021

Fixes: #39034

Hey @Linkgoron, @Ayase-252 - how does this look?
Let me know if this needs any changes! Thanks

@github-actions github-actions bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Jun 26, 2021
@Linkgoron
Copy link
Member

IMO there should no default values mentioned at all (for any of the paramaters), as the function arguments are not optional. This is true for both filehandle.read(buffer, offset, length, position) and fs.read(fd, buffer, offset, length, position, callback). For example, if length is not provided, the function doesn't actually read anything (as it is converted to 0), which is probably not what anyone meant.

@rbrishabh
Copy link
Contributor Author

makes sense! I'll make the changes

@rbrishabh
Copy link
Contributor Author

I've made the changes! thoughts @Linkgoron?

doc/api/fs.md Outdated Show resolved Hide resolved
doc/api/fs.md Outdated Show resolved Hide resolved
@rbrishabh
Copy link
Contributor Author

my bad @Linkgoron, I should have been more careful. Done! :)

@lydell
Copy link

lydell commented Jun 27, 2021

Is it worth mentioning that fileHandle.read differs compared to fs.readSync (no parameter defaults)? Seems like an easy mistake to make.

@rbrishabh
Copy link
Contributor Author

rbrishabh commented Jun 27, 2021

Happy to make changes for any suggestions you have @lydell

@lydell
Copy link

lydell commented Jun 28, 2021

My bad, fs.readSync isn’t documented to have parameter defaults either:

https://nodejs.org/api/fs.html#fs_fs_readsync_fd_buffer_offset_length_position

I think I’ve finally figured out what confused me: For fs.readSync, buffer is always the first argument. So fs.readSync(fd, buffer) triggers the fs.readSync(fd, buffer, [options]) overload, and options has defaults. But fileHandle.read() takes buffer inside the options object. So I can’t say filehandle.read(buffer) – it has to be filehandle.read({buffer}). Oh well.

I think this PR is correct – none of the 3 read variants take parameter defaults (only the overloads with options objects have defaults). And I don’t think any additional text is needed.

@rbrishabh
Copy link
Contributor Author

Makes complete sense @lydell! Thanks for your review :)

@subson
Copy link

subson commented Jul 8, 2021

@rbrishabh - Can you amend the commit message to less than 72 characters, thats the check failing for this PR.

@rbrishabh rbrishabh force-pushed the fileHandle-length-default branch 2 times, most recently from 472522b to 23c5385 Compare July 8, 2021 18:10
@rbrishabh
Copy link
Contributor Author

Hi @subson! done! let me know if this needs any other changes! thx

@subson
Copy link

subson commented Jul 8, 2021

Hey @Linkgoron @lydell, can you approve this PR again to kick of the workflows as commit message has been updated?

@Linkgoron
Copy link
Member

You need to change the subsystem to doc instead of Docs in the commit message.

@jasnell
Copy link
Member

jasnell commented Jul 9, 2021

You need to change the subsystem to doc instead of Docs in the commit message.

FWIW, that can be done by whomever lands the PR really.

@subson
Copy link

subson commented Jul 13, 2021

@rbrishabh - Hey, Need to update commit again to doc: instead of Docs:.

@rbrishabh
Copy link
Contributor Author

Sure! I can do that

@rbrishabh
Copy link
Contributor Author

Hi @subson! done! let me know if this needs any other changes! thank you

@Ayase-252 Ayase-252 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Sep 21, 2021
@github-actions github-actions bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 21, 2021
@github-actions
Copy link
Contributor

Landed in 7153d25...479658b

@github-actions github-actions bot closed this Sep 21, 2021
nodejs-github-bot pushed a commit that referenced this pull request Sep 21, 2021
PR-URL: #39163
Fixes: #39034
Reviewed-By: Nitzan Uziely <[email protected]>
Reviewed-By: Qingyu Deng <[email protected]>
@nodejs nodejs deleted a comment Sep 21, 2021
@nodejs nodejs deleted a comment Sep 21, 2021
BethGriggs pushed a commit that referenced this pull request Sep 21, 2021
PR-URL: #39163
Fixes: #39034
Reviewed-By: Nitzan Uziely <[email protected]>
Reviewed-By: Qingyu Deng <[email protected]>
BethGriggs pushed a commit that referenced this pull request Sep 21, 2021
PR-URL: #39163
Fixes: #39034
Reviewed-By: Nitzan Uziely <[email protected]>
Reviewed-By: Qingyu Deng <[email protected]>
@BethGriggs BethGriggs mentioned this pull request Sep 21, 2021
1 task
@lilit-harutyunyan
Copy link

🤒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fileHandle.read argument defaults don’t seem to work
7 participants