FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fs: add default options for stat, fstat, and lstat by UziTech · Pull Request #29114 · nodejs/node · GitHub

/ node Public

fs: add default options for stat, fstat, and lstat - #29114

Closed
UziTech wants to merge 2 commits into
nodejs:masterfrom
UziTech:patch-1
Closed

fs: add default options for stat, fstat, and lstat#29114
UziTech wants to merge 2 commits into
nodejs:masterfrom
UziTech:patch-1

Conversation

UziTech commented Aug 14, 2019
edited
Loading

Copy link
Copy Markdown
Contributor

Add default options to the function signatures for fs.stat, fs.fstat, and fs.lstat.

This allows a library to pass undefined to get the default options.

Fixes: #29113

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Aug 14, 2019

Trott commented Aug 14, 2019

Copy link
Copy Markdown
Member

@nodejs/fs

Comment thread lib/fs.js
}

function fstat(fd, options, callback) {
function fstat(fd, options = { bigint: false }, callback) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why not just options = {}? (Same below.)

UziTech Aug 14, 2019
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I just copied fs/promises.js

async function fstat(handle, options = { bigint: false }) {

Should I use getOptions(options, {bigint: false}) to match the other functions?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

getOptions() does a bunch of other things that do not fit these APIs (like accepting a string as the encoding option), using default arguments should be fine considering we do this for many other APIs as well.

Trott commented Aug 14, 2019

Copy link
Copy Markdown
Member

I seem to recall that we used to avoid default options like this because it would run slower than doing the equivalent in the first few lines of the function. But I don't know if that's no longer a problem or not (or if it never was an I'm imagining it). /ping @mscdex

Trott commented Aug 14, 2019

Copy link
Copy Markdown
Member

Trott commented Aug 14, 2019

Copy link
Copy Markdown
Member

Welcome @UziTech and thanks for the pull request!

joyeecheung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you add a test?

UziTech commented Aug 14, 2019

Copy link
Copy Markdown
Contributor Author

@joyeecheung I am not very familiar with the node codebase. Where would you like me to add the tests?

UziTech commented Aug 14, 2019

Copy link
Copy Markdown
Contributor Author

I think I found the right place. I added the tests to /test/parallel/test-fs-stat.js

Copy link
Copy Markdown
Collaborator

UziTech commented Aug 15, 2019

Copy link
Copy Markdown
Contributor Author

I don't think the failed tests have anything to do with my code changes.

Copy link
Copy Markdown
Collaborator

Trott commented Aug 16, 2019

Copy link
Copy Markdown
Member

Landed in 4111c57.

Thanks for the contribution! 🎉

Trott closed this Aug 16, 2019
Trott pushed a commit that referenced this pull request Aug 16, 2019
PR-URL: #29114
Fixes: #29113
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
targos pushed a commit that referenced this pull request Aug 19, 2019
PR-URL: #29114
Fixes: #29113
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot read property 'bigint' of undefined

7 participants


Back | FazBrowse Home | New Git URL