Skip to content

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

Closed
rbrishabh wants to merge 1 commit into
nodejs:masterfrom
rbrishabh:fileHandle-length-default
Closed

Docs: fixes filehandle.read docs to show default buffer value length as 0#39163
rbrishabh wants to merge 1 commit into
nodejs:masterfrom
rbrishabh:fileHandle-length-default

Conversation

@rbrishabh

@rbrishabhrbrishabh commented Jun 26, 2021

Copy link
Copy Markdown
Contributor

Fixes: #39034

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

@github-actionsgithub-actionsBot 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
Copy Markdown
Contributor

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
Copy Markdown
ContributorAuthor

makes sense! I'll make the changes

@rbrishabh

Copy link
Copy Markdown
ContributorAuthor

I've made the changes! thoughts @Linkgoron?

Comment threaddoc/api/fs.md Outdated
Comment threaddoc/api/fs.md Outdated
@rbrishabh

Copy link
Copy Markdown
ContributorAuthor

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

@lydell

Copy link
Copy Markdown

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

@rbrishabh

rbrishabh commented Jun 27, 2021

Copy link
Copy Markdown
ContributorAuthor

Happy to make changes for any suggestions you have @lydell

@lydell

lydell commented Jun 28, 2021

Copy link
Copy Markdown

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 bufferinside 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
Copy Markdown
ContributorAuthor

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

@subson

Copy link
Copy Markdown

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

@rbrishabh
rbrishabhforce-pushed the fileHandle-length-default branch 2 times, most recently from 472522b to 23c5385CompareJuly 8, 2021 18:10
@rbrishabh

Copy link
Copy Markdown
ContributorAuthor

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

@subson

Copy link
Copy Markdown

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

@Linkgoron

Copy link
Copy Markdown
Contributor

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

@jasnell

Copy link
Copy Markdown
Member

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
Copy Markdown

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

@rbrishabh

Copy link
Copy Markdown
ContributorAuthor

Sure! I can do that

@rbrishabh
rbrishabhforce-pushed the fileHandle-length-default branch from 23c5385 to c7b725eCompareJuly 14, 2021 17:56
@rbrishabh

Copy link
Copy Markdown
ContributorAuthor

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

@Ayase-252Ayase-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-actionsgithub-actionsBot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 21, 2021
@github-actions

Copy link
Copy Markdown
Contributor

Landed in 7153d25...479658b

nodejs-github-bot pushed a commit that referenced this pull request Sep 21, 2021
PR-URL: #39163Fixes: #39034
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
@nodejsnodejs deleted a comment Sep 21, 2021
@nodejsnodejs deleted a comment Sep 21, 2021
BethGriggs pushed a commit that referenced this pull request Sep 21, 2021
PR-URL: #39163Fixes: #39034
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
BethGriggs pushed a commit that referenced this pull request Sep 21, 2021
PR-URL: #39163Fixes: #39034
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
@BethGriggsBethGriggs mentioned this pull request Sep 21, 2021
1 task
@lilit-harutyunyan

Copy link
Copy Markdown

🤒

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.docIssues and PRs related to the documentations.fsIssues 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

@rbrishabh@Linkgoron@lydell@subson@jasnell@lilit-harutyunyan@Ayase-252