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: expose BigIntStats, StatFs, FSWatcher, StatWatcher classes #51681

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3242,6 +3242,18 @@ defineLazyProperties(
['Dir', 'opendir', 'opendirSync'],
);

defineLazyProperties(
fs,
'internal/fs/utils',
['BigIntStats', 'StatFs'],
);

defineLazyProperties(
fs,
'internal/fs/watchers',
['FSWatcher', 'StatWatcher'],
);

ObjectDefineProperties(fs, {
F_OK: { __proto__: null, enumerable: true, value: F_OK || 0 },
R_OK: { __proto__: null, enumerable: true, value: R_OK || 0 },
Expand Down
1 change: 1 addition & 0 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ module.exports = {
getStatsFromBinding,
stringToFlags,
stringToSymlinkType,
StatFs,
Stats,
toUnixTimestamp,
validateBufferArray,
Expand Down
25 changes: 25 additions & 0 deletions test/parallel/test-fs-classes-exist.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import '../common/index.mjs';
import { equal } from 'node:assert/strict';
import {
BigIntStats,
Dir,
Dirent,
FSWatcher,
StatWatcher,
ReadStream,
Stats,
StatFs,
WriteStream,
} from 'node:fs';

// Test classes listed in https://nodejs.org/api/fs.html#common-objects

equal(typeof BigIntStats, 'function');
equal(typeof Dir, 'function');
equal(typeof Dirent, 'function');
equal(typeof FSWatcher, 'function');
equal(typeof StatWatcher, 'function');
equal(typeof ReadStream, 'function');
equal(typeof Stats, 'function');
equal(typeof StatFs, 'function');
equal(typeof WriteStream, 'function');
Loading