Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@UziTech
Copy link
Contributor

@UziTech UziTech commented Aug 14, 2019

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 nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Aug 14, 2019
@Trott
Copy link
Member

Trott commented Aug 14, 2019

@nodejs/fs

}

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

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

@UziTech UziTech Aug 14, 2019

Choose a reason for hiding this comment

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

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
Member

Choose a reason for hiding this comment

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

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
Copy link
Member

Trott commented Aug 14, 2019

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
Copy link
Member

Trott commented Aug 14, 2019

@Trott
Copy link
Member

Trott commented Aug 14, 2019

Welcome @UziTech and thanks for the pull request!

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

Can you add a test?

@UziTech
Copy link
Contributor Author

UziTech commented Aug 14, 2019

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

@UziTech
Copy link
Contributor Author

UziTech commented Aug 14, 2019

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

@nodejs-github-bot
Copy link
Collaborator

@UziTech
Copy link
Contributor Author

UziTech commented Aug 15, 2019

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

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Aug 16, 2019

Landed in 4111c57.

Thanks for the contribution! 🎉

@Trott 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>
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.