-
Notifications
You must be signed in to change notification settings - Fork 285
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
Documentation fsPromises.readdir: possibly superfluous await #3317
Comments
It is. :) You can also submit a PR for this directly if you like, the documentation files are in |
Hi @michaelrommel - Is it okay if I go ahead and create a PR for fixing this issue? |
I'll create the PR tomorrow morning. I was snowed under last week... |
So, it took me some learning and reformatting the commit message to conform to the guidelines. I should have done that right away using the commandline, instead of trying that in the github UI... It's my first PR to node... Thank you all for your help and patience. Node is awesome. I would now close this issue, as it is now in the hands of the node project repo itself or will that close by itself, once the referenced PR lands or is closed? |
Thanks for the contribution! 🎉 |
The `await` operator in the example, iterating over the returned array of filenames is not necessary, since the returned array is either consisting of `string`s or of `fs.Dirent` objects, neither providing an asyncIterator. Refs: nodejs/help#3317 PR-URL: #38293 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
The documentation at: https://nodejs.org/api/fs.html#fs_fspromises_readdir_path_options provides an example to iterate over the returned file array. It uses the construct:
I thought, that this
await
would only be necessary, if the returned array would contain objects of a class, which provides an asyncIterator, like fs.Dir (https://nodejs.org/api/fs.html#fs_dir_symbol_asynciterator).Why is this await statement necessary? I would understand, if the example had the
options
object set towithFileTypes
set to true, because in this case the returned array is of typefs.Dirent
and not an array ofString
s orBuffer
s. (But even then it is questionable, since alsofs.Dirent
does not document an asyncIterator.If this is an error in the documentation, I am happy to open an issue on the node repository.
The text was updated successfully, but these errors were encountered: