Gathering detailed insights and metrics for @stdlib/fs-exists
Gathering detailed insights and metrics for @stdlib/fs-exists
Gathering detailed insights and metrics for @stdlib/fs-exists
Gathering detailed insights and metrics for @stdlib/fs-exists
@stdlib/fs-exists-cli
Test whether a path exists on the filesystem.
@nurliman/file-exists-cli
Check if a file exists
@omegion1npm/maiores-similique-fuga
`@omegion1npm/maiores-similique-fuga.js` implements a CommonJS-style module system for NodeJS which has a high degree of compatibility with the default module system, npm, etc -- but which exists in a separate vm context and not share an exports object g
Test whether a path exists on the filesystem.
npm install @stdlib/fs-exists
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.4
Supply Chain
96.7
Quality
81.6
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
80,478,479
Last Day
13,651
Last Week
425,503
Last Month
1,918,600
Last Year
23,967,606
Apache-2.0 License
1 Stars
67 Commits
3 Watchers
6 Branches
14 Contributors
Updated on May 26, 2025
Minified
Minified + Gzipped
Latest Version
0.2.2
Package Id
@stdlib/fs-exists@0.2.2
Unpacked Size
34.00 kB
Size
9.40 kB
File Count
12
NPM Version
8.19.4
Node Version
16.20.2
Published on
Jul 27, 2024
Cumulative downloads
Total Downloads
Last Day
-2.6%
13,651
Compared to previous day
Last Week
-10%
425,503
Compared to previous week
Last Month
-4.1%
1,918,600
Compared to previous month
Last Year
-40.9%
23,967,606
Compared to previous year
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
Test whether a path exists on the filesystem.
1npm install @stdlib/fs-exists
1var exists = require( '@stdlib/fs-exists' );
Asynchronously tests whether a path exists on the filesystem.
1exists( __dirname, done ); 2 3function done( bool ) { 4 if ( bool ) { 5 console.log( '...path exists.' ); 6 } else { 7 console.log( '...path does not exist.' ); 8 } 9}
The above callback signature matches the now deprecated fs.exists()
API. The function also accepts the more conventional error
-first style callback signature found in most asynchronous Node APIs.
1exists( __dirname, done ); 2 3function done( error, bool ) { 4 if ( error ) { 5 console.error( error.message ); 6 } 7 if ( bool ) { 8 console.log( '...path exists.' ); 9 } else { 10 console.log( '...path does not exist.' ); 11 } 12}
Synchronously tests whether a path exists on the filesystem.
1var bool = exists.sync( __dirname ); 2// returns <boolean>
The following is considered an anti-pattern:
1var path = require( 'path' ); 2var readFileSync = require( '@stdlib/fs-read-file' ).sync; 3 4var file = path.join( __dirname, 'foo.js' ); 5if ( exists.sync( __dirname ) ) { 6 file = readFileSync( file ); 7}
Because time elapses between checking for existence and performing IO, at the time IO is performed, the path is no longer guaranteed to exist. In other words, a race condition exists between the process attempting to read and another process attempting to delete.
Instead, the following pattern is preferred, where errors
are handled explicitly:
1var path = require( 'path' ); 2var readFileSync = require( '@stdlib/fs-read-file' ).sync; 3 4var file = path.join( __dirname, 'foo.js' ); 5try { 6 file = readFileSync( file ); 7} catch ( error ) { 8 console.log( 'unable to read file.' ); 9 console.error( error ); 10}
Nevertheless, use cases exist where one desires to check existence without performing IO. For example,
1var path = require( 'path' ); 2var writeFileSync = require( '@stdlib/fs-write-file' ).sync; 3 4var file = path.join( __dirname, 'foo.js' ); 5if ( exists.sync( file ) ) { 6 console.log( 'Don\'t overwrite the file!' ); 7} else { 8 writeFileSync( file, 'beep', { 9 'encoding': 'utf8' 10 }); 11}
1var exists = require( '@stdlib/fs-exists' ); 2 3/* Sync */ 4 5console.log( exists.sync( __dirname ) ); 6// => true 7 8console.log( exists.sync( 'beepboop' ) ); 9// => false 10 11/* Async */ 12 13exists( __dirname, done ); 14exists( 'beepboop', done ); 15 16function done( error, bool ) { 17 if ( error ) { 18 console.error( error.message ); 19 } else { 20 console.log( bool ); 21 } 22}
@stdlib/fs-exists-cli
: CLI package for use as a command-line utility.@stdlib/fs-read-file
: read the entire contents of a file.@stdlib/fs-read-dir
: read the entire contents of a directory.This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2024. The Stdlib Authors.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
project is not fuzzed
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More