-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: modernize and fix code examples in fs.md #12035
Conversation
doc/api/fs.md
Outdated
@@ -2173,7 +2172,7 @@ Example: | |||
```js | |||
fs.writeFile('message.txt', 'Hello Node.js', (err) => { | |||
if (err) throw err; | |||
console.log('It\'s saved!'); | |||
console.log("It's saved!"); |
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.
Nit: the quote can be avoided if the message is something like The file has been saved!
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.
@joyeecheung Done)
doc/api/fs.md
Outdated
} | ||
|
||
throw err; | ||
} else { |
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.
Nit: how about removing also this else
branch?
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.
Done.
Delete unnecessary `else` after `return` and `throw`.
* unify quotes in fs.md * avoid quote escaping in fs.md * simplify logics in fs.md * concatenation -> template literal in fs.md * add missing callback in fs.md * fix typo in fs.md * update output example in fs.md PR-URL: #12035 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 31da375 |
* unify quotes in fs.md * avoid quote escaping in fs.md * simplify logics in fs.md * concatenation -> template literal in fs.md * add missing callback in fs.md * fix typo in fs.md * update output example in fs.md PR-URL: #12035 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* unify quotes in fs.md * avoid quote escaping in fs.md * simplify logics in fs.md * concatenation -> template literal in fs.md * add missing callback in fs.md * fix typo in fs.md * update output example in fs.md PR-URL: #12035 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* unify quotes in fs.md * avoid quote escaping in fs.md * simplify logics in fs.md * concatenation -> template literal in fs.md * add missing callback in fs.md * fix typo in fs.md * update output example in fs.md PR-URL: #12035 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* unify quotes in fs.md * avoid quote escaping in fs.md * simplify logics in fs.md * concatenation -> template literal in fs.md * add missing callback in fs.md * fix typo in fs.md * update output example in fs.md PR-URL: nodejs/node#12035 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Checklist
Affected core subsystem(s)
doc, fs
else
afterreturn
andthrow
)