What is fs-exists-cached?
The fs-exists-cached npm package provides a simple and efficient way to check if a file or directory exists, with caching to improve performance for repeated checks.
What are fs-exists-cached's main functionalities?
Check if a file or directory exists
This feature allows you to check if a specified file or directory exists. The result is cached to improve performance for subsequent checks.
const fsExistsCached = require('fs-exists-cached');
fsExistsCached('path/to/file/or/directory').then(exists => {
console.log(exists ? 'Exists' : 'Does not exist');
});
Synchronous check if a file or directory exists
This feature provides a synchronous method to check if a specified file or directory exists. The result is cached for performance optimization.
const fsExistsCached = require('fs-exists-cached');
const exists = fsExistsCached.sync('path/to/file/or/directory');
console.log(exists ? 'Exists' : 'Does not exist');
Other packages similar to fs-exists-cached
fs-extra
fs-extra is a package that extends the native Node.js fs module with additional methods, including methods to check if a file or directory exists. Unlike fs-exists-cached, fs-extra does not cache the results of existence checks.
path-exists
path-exists is a simple package to check if a path exists. It provides both asynchronous and synchronous methods. However, it does not include caching like fs-exists-cached.
file-exists
file-exists is another package for checking if a file exists. It offers both asynchronous and synchronous methods but does not provide caching functionality.