Complete File System Cache v1.0.0 Documentation
Table of contents
Description
Caches every file that exists in the file system and stores the whole
file system files, where you want it to store and based on that it can
do fast search in the cached content.
Installation
npm i complete-file-system-cache
Usage example
import { CompleteFileSystemCache } from 'complete-file-system-cache'
import { join } from 'path'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
;(async () => {
const completeFileSystemCache = new CompleteFileSystemCache(__dirname)
await completeFileSystemCache.cacheFileSystem()
const results = completeFileSystemCache.search(
['/Users/datomarjanidze'],
['.git', 'node_modules', '.cache', '.angular']
)
})()
API
Types
type FileSystemCache = string[]
CompleteFileSystemCache properties
cachedFileSystem
Returns the FileSystemCache
if it exists.
CompleteFileSystemCache methods
constructor(projectRootDir)
projectRootDir: string
This directory path will be used to store the
file system cache.
cacheFileSystem()
async
- Returns:
Promise<FileSystemCache>
Tries to load the file system from the cache file called
.complete-file-system-cache
or reads the whole file system and caches
everything.
reloadFileSystemCache()
async
- Returns:
Promise<FileSystemCache>
Reloads the cache.
search(includedPathSegments, excludedPathSegments, ignoreCase)
includedPathSegments: string[]
Path segments which should be
included from the search results.excludedPathSegments: string[]
Default: []
Path segments
which should be excluded from the search results.ignoreCase
Default: true
Executes case insensitive search,
if the provided argument is true
.- cleanCache()
Cleans the cache file from the file system and the cached data from the
CompleteFileSystemCache
class object.