-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc: add fsPromises.readFile() example #40237
doc: add fsPromises.readFile() example #40237
Conversation
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 wonder if an example showing how to read a package.json
relative to the current module wouldn't be more common than from an absolute path.
Would love a second opinion on whether or not we'd prefer to use |
I see path.join is already used in the same file for other examples. I don't have a strong preference but I would lean towards using the path.join version suggested. |
(going to pull and make some small tweaks) |
Signed-off-by: Tierney Cyren <hello@bnb.im>
39ec877
to
a580c73
Compare
force pushed to fix prefix issues. hopefully mergable now :) |
it looks like this line is over 80 characters. Do we block on that for code examples? |
Co-authored-by: Rich Trott <rtrott@gmail.com>
Co-authored-by: Rich Trott <rtrott@gmail.com>
Co-authored-by: Rich Trott <rtrott@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Commit Queue failed- Loading data for nodejs/node/pull/40237 ✔ Done loading data for nodejs/node/pull/40237 ----------------------------------- PR info ------------------------------------ Title doc: add fsPromises.readFile() example (#40237) Author Tierney Cyren (@bnb) Branch bnb:bnb/add-fspromises-readfile-example -> nodejs:main Labels doc, fs Commits 7 - doc: add fsPromises.readFile() example - doc: simplify code example - doc: simplify code example - doc: remove unnecessary line break - doc: fix line length issue - doc: use `node:` prefix for node modules - doc: use `node:` prefix for node modules Committers 2 - Tierney Cyren - GitHub PR-URL: https://github.com/nodejs/node/pull/40237 Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/40237 Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel -------------------------------------------------------------------------------- ℹ This PR was created on Mon, 27 Sep 2021 23:22:52 GMT ✔ Approvals: 2 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/40237#pullrequestreview-787530318 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/40237#pullrequestreview-1136672708 ✔ Last GitHub CI successful ℹ Green GitHub CI is sufficient -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 40237 From https://github.com/nodejs/node * branch refs/pull/40237/merge -> FETCH_HEAD ✔ Fetched commits as 1124558b655c..90a77178015a -------------------------------------------------------------------------------- Auto-merging doc/api/fs.md [main 5a063004ea] doc: add fsPromises.readFile() example Author: Tierney Cyren Date: Mon Nov 15 17:22:46 2021 -0500 1 file changed, 26 insertions(+) Auto-merging doc/api/fs.md [main c10f6c3798] doc: simplify code example Author: Tierney Cyren Date: Mon Oct 10 19:03:27 2022 +0200 1 file changed, 2 insertions(+), 1 deletion(-) Auto-merging doc/api/fs.md [main 92f98b36c4] doc: simplify code example Author: Tierney Cyren Date: Mon Oct 10 19:03:44 2022 +0200 1 file changed, 2 insertions(+), 1 deletion(-) Auto-merging doc/api/fs.md [main 40cef2f085] doc: remove unnecessary line break Author: Tierney Cyren Date: Mon Oct 10 19:03:59 2022 +0200 1 file changed, 1 deletion(-) Auto-merging doc/api/fs.md [main 496078fb77] doc: fix line length issue Author: Tierney Cyren Date: Tue Oct 11 00:03:02 2022 +0200 1 file changed, 3 insertions(+), 1 deletion(-) Auto-merging doc/api/fs.md [main 366bef88c7] doc: use `node:` prefix for node modules Author: Tierney Cyren Date: Tue Oct 11 00:03:25 2022 +0200 1 file changed, 1 insertion(+), 1 deletion(-) Auto-merging doc/api/fs.md [main 19a6ba1076] doc: use `node:` prefix for node modules Author: Tierney Cyren Date: Tue Oct 11 00:03:35 2022 +0200 1 file changed, 2 insertions(+), 2 deletions(-) ✔ Patches applied There are 7 commits in the PR. Attempting autorebase. Rebasing (2/14)https://github.com/nodejs/node/actions/runs/3223732038 |
Landed in 624dadb |
Signed-off-by: Tierney Cyren <hello@bnb.im> PR-URL: #40237 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Adds a CJS and MJS example to the
readFile
method on fsPromises. There is an example with AbortController but it's slightly misleading if you're just looking at the examples, since you don't actually need to do that.