Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
exists-file
Advanced tools
Check if a file exists. A fs.exists implementation that is not deprecated.
Check if a file exists. A fs.exists implementation that is not deprecated.
Because fs.exist and fs.existsSync are deprecated this an implementation using fs.stats and fs.statsSync for get the same result.
Also always keep in mind:
fs.exists() should not be used to check if a file exists before calling fs.open(). Doing so introduces a race condition since other processes may change the file's state between the two calls. Instead, user code should call fs.open() directly and handle the error raised if the file is non-existent.
npm install exists-file --save
var existsFile = require('exists-file')
// async with a callback
existsFile('./README.md', console.log) // => null, true
// async with a promise
existsFile('./README.md').then(console.log).catch(console.error) // => true
// sync
var exists = existsFile.sync('./README.md')
console.log(exists) // => true
Required
Type: string
The relative or absolute file path.
Type: function
If cb
is not provided then it returns a promise
.
Required
Type: string
The relative or absolute file path.
MIT © Kiko Beats
FAQs
Check if a file exists. A fs.exists implementation that is not deprecated.
We found that exists-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.