-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
clarify the position argument for fs.read #14612
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1640,7 +1640,9 @@ Read data from the file specified by `fd`. | |
| `length` is an integer specifying the number of bytes to read. | ||
|
|
||
| `position` is an integer specifying where to begin reading from in the file. | ||
| If `position` is `null`, data will be read from the current file position. | ||
| If `position` is `null`, data will be read from the current file position, | ||
| and the file position will be updated for subsequent reads. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is only one current file position, its used for read and for write, but this makes it sound like its used only for reads. I would just say the current file position is updated.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's pretty obvious that there is only one file position, this "for subsequent reads" was to ring a bell.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sam-github's concern here can be addressed with a simple edit here... |
||
| If `position` is an integer, the file position will remain unchanged. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe it feels obvious, but for null you say where it reads from (current position) and what happens to current position (its updated). For the integer case this says file position is unchange, but it doesn't say where read is from, which is from the integer as a positive offset from beginning of file (-4 won't read from 4 bytes before end of file, for example). also, the file position will be changed on Windows, though there is a UV PR to change windows to be like unix: libuv/libuv#1357, not sure if that has effected node yet, though.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like that PR landed in libuv 1.13.0, so it has at least made its way to Node.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah and let's say what happen if you have a position that goes over the size of the file and specify that it's bytes, also say that the position in the end is the quantity that has been read + the previous position but let's wait that you do it on an other PR because this has noting to do with this one |
||
|
|
||
| The callback is given the three arguments, `(err, bytesRead, buffer)`. | ||
|
|
||
|
|
||
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.
I suggest "is an argument", its not always an integer, null is not an integer
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.
#14621