Skip to content

fs: add static Stats.isStats() method - #67716

Open
LiviaMedeiros wants to merge 1 commit into
nodejs:mainfrom
LiviaMedeiros:fs-stats-isstats
Open

LiviaMedeiros wants to merge 1 commit into
nodejs:mainfrom
LiviaMedeiros:fs-stats-isstats

Conversation

@LiviaMedeiros

Copy link
Copy Markdown
Member

fs.Stats class is very problematic because its shape depends on the bigint option passed to the stats functions.

In the documentation, it's defined as single class that has "bigint" version. In the internal implementation, there are separate Stats and BigIntStats classes. As result, stats instanceof fs.Stats in userland returns different results depending on bigint option.

This PR adds static Stats.isStats method that covers both Stats and BigIntStats.


This should help us to move forward with making DEP0180 to EOL (#67491) and potentially moving further (e.g. deprecating bigint option in favour of exposing nanosecond precision on Stats, or rewriting internal implementation), providing users documented alternative to instanceof checks for now.

This deliberately doesn't distinguish between Stats and BigIntStats and doesn't provide more specific checks to give us more freedom for internal changes.

I'm open for any actionable suggestions here.

@LiviaMedeiros LiviaMedeiros added fs Issues and PRs related to file-system APIs and the fs module. semver-minor PRs that contain new features and should be released in the next minor version. needs-ci PRs that need a full CI run. labels Nov 22, 2026
Signed-off-by: LiviaMedeiros <livia@cirno.name>
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.53%. Comparing base (97d5d90) to head (089ff38).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67716      +/-   ##
==========================================
- Coverage   90.55%   90.53%   -0.02%     
==========================================
  Files         801      801              
  Lines      284111   284128      +17     
  Branches    54879    54885       +6     
==========================================
- Hits       257279   257240      -39     
- Misses      17006    17051      +45     
- Partials     9826     9837      +11     
Files with missing lines Coverage Δ
lib/internal/fs/utils.js 96.11% <100.00%> (+0.02%) ⬆️

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@LiviaMedeiros LiviaMedeiros added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 23, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 23, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

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 file-system APIs and the fs module. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants