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

Commit 178caa5

Browse filesBrowse files
UziTechtargos
authored andcommitted
fs: add default options for *stat()
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>
1 parent 62a0e91 commit 178caa5
Copy full SHA for 178caa5

File tree

Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed
Open diff view settings
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ function readdirSync(path, options) {
796796
return options.withFileTypes ? getDirents(path, result) : result;
797797
}
798798

799-
function fstat(fd, options, callback) {
799+
function fstat(fd, options = { bigint: false }, callback) {
800800
if (typeof options === 'function') {
801801
callback = options;
802802
options = {};
@@ -807,7 +807,7 @@ function fstat(fd, options, callback) {
807807
binding.fstat(fd, options.bigint, req);
808808
}
809809

810-
function lstat(path, options, callback) {
810+
function lstat(path, options = { bigint: false }, callback) {
811811
if (typeof options === 'function') {
812812
callback = options;
813813
options = {};
@@ -819,7 +819,7 @@ function lstat(path, options, callback) {
819819
binding.lstat(pathModule.toNamespacedPath(path), options.bigint, req);
820820
}
821821

822-
function stat(path, options, callback) {
822+
function stat(path, options = { bigint: false }, callback) {
823823
if (typeof options === 'function') {
824824
callback = options;
825825
options = {};
Collapse file

‎test/parallel/test-fs-stat.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-stat.js
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,14 @@ fs.stat(__filename, common.mustCall(function(err, s) {
154154
}
155155
);
156156
});
157+
158+
// Should not throw an error
159+
fs.stat(__filename, undefined, common.mustCall(() => {}));
160+
161+
fs.open(__filename, 'r', undefined, common.mustCall((err, fd) => {
162+
// Should not throw an error
163+
fs.fstat(fd, undefined, common.mustCall(() => {}));
164+
}));
165+
166+
// Should not throw an error
167+
fs.lstat(__filename, undefined, common.mustCall(() => {}));

0 commit comments

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