Skip to content
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

fs: use consistent defaults in sync stat functions #31097

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/fs.js
Expand Up @@ -922,15 +922,15 @@ function stat(path, options = { bigint: false }, callback) {
binding.stat(pathModule.toNamespacedPath(path), options.bigint, req);
}

function fstatSync(fd, options = {}) {
function fstatSync(fd, options = { bigint: false }) {
validateInt32(fd, 'fd', 0);
const ctx = { fd };
const stats = binding.fstat(fd, options.bigint, undefined, ctx);
Copy link
Member

Choose a reason for hiding this comment

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

For @devsnek 's concerns, how about changing this to:

Suggested change
const stats = binding.fstat(fd, options.bigint, undefined, ctx);
const stats = binding.fstat(fd, options.bigint || false, undefined, ctx);

Copy link
Member

Choose a reason for hiding this comment

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

in a future change we could do { bigint = false } = {} for all of them

handleErrorFromBinding(ctx);
return getStatsFromBinding(stats);
}

function lstatSync(path, options = {}) {
function lstatSync(path, options = { bigint: false }) {
path = getValidatedPath(path);
const ctx = { path };
const stats = binding.lstat(pathModule.toNamespacedPath(path),
Expand All @@ -939,7 +939,7 @@ function lstatSync(path, options = {}) {
return getStatsFromBinding(stats);
}

function statSync(path, options = {}) {
function statSync(path, options = { bigint: false }) {
path = getValidatedPath(path);
const ctx = { path };
const stats = binding.stat(pathModule.toNamespacedPath(path),
Expand Down