file-entry-cache
- Version 10.0.4
- Published
- 50 kB
- 1 dependency
- MIT license
Install
npm i file-entry-cache
yarn add file-entry-cache
pnpm add file-entry-cache
Overview
A lightweight cache for file metadata, ideal for processes that work on a specific set of files and only need to reprocess files that have changed since the last run
Index
Functions
function create
create: ( cacheId: string, cacheDirectory?: string, useCheckSum?: boolean, currentWorkingDirectory?: string) => FileEntryCache;
function createFromFile
createFromFile: ( filePath: string, useCheckSum?: boolean, currentWorkingDirectory?: string) => FileEntryCache;
Classes
class FileEntryCache
class FileEntryCache {}
constructor
constructor(options?: FileEntryCacheOptions);
property cache
cache: FlatCache;
property currentWorkingDirectory
currentWorkingDirectory: string;
property hashAlgorithm
hashAlgorithm: string;
property useCheckSum
useCheckSum: boolean;
method analyzeFiles
analyzeFiles: (files: string[]) => AnalyzedFiles;
Analyze the files analyzeFiles
Parameter files
The files to analyze
Returns
{AnalyzedFiles} The analysis of the files
method createFileKey
createFileKey: ( filePath: string, options?: { currentWorkingDirectory?: string }) => string;
Create the key for the file path used for caching. createFileKey
Parameter filePath
{String}
method deleteCacheFile
deleteCacheFile: () => boolean;
Delete the cache file from the disk deleteCacheFile {boolean} true if the file was deleted, false otherwise
method destroy
destroy: () => void;
Remove the cache from the file and clear the memory cache destroy
method getAbsolutePath
getAbsolutePath: ( filePath: string, options?: { currentWorkingDirectory?: string }) => string;
Get the Absolute Path. If it is already absolute it will return the path as is. getAbsolutePath
Parameter filePath
The file path to get the absolute path for
Parameter options
The options for getting the absolute path. The current working directory is used if not provided.
Returns
{string}
method getFileDescriptor
getFileDescriptor: ( filePath: string, options?: GetFileDescriptorOptions) => FileDescriptor;
Get the file descriptor for the file path getFileDescriptor
Parameter filePath
The file path to get the file descriptor for
Parameter options
The options for getting the file descriptor
Returns
The file descriptor
method getFileDescriptorsByPath
getFileDescriptorsByPath: (filePath: string) => FileDescriptor[];
Get the not found files getFileDescriptorsByPath
Parameter filePath
the files that you want to get from a path
Returns
{FileDescriptor[]} The not found files
method getHash
getHash: (buffer: Buffer) => string;
Given a buffer, calculate md5 hash of its content. getHash
Parameter buffer
buffer to calculate hash on {String} content hash digest
method getUpdatedFiles
getUpdatedFiles: (files: string[]) => string[];
Get the updated files getUpdatedFiles
Parameter files
The files to get the updated files for
Returns
{string[]} The updated files
method hasFileChanged
hasFileChanged: (filePath: string) => boolean;
Check if the file has changed hasFileChanged
Parameter filePath
The file path to check
Returns
{boolean} if the file has changed, false otherwise
method isRelativePath
isRelativePath: (filePath: string) => boolean;
Check if the file path is a relative path isRelativePath
Parameter filePath
The file path to check
Returns
{boolean} if the file path is a relative path, false otherwise
method normalizeEntries
normalizeEntries: (files?: string[]) => FileDescriptor[];
Get the file descriptors for the files normalizeEntries
Parameter files
?: string[] - The files to get the file descriptors for
Returns
The file descriptors
method reconcile
reconcile: () => void;
Reconcile the cache reconcile
method removeEntry
removeEntry: ( filePath: string, options?: { currentWorkingDirectory?: string }) => void;
Remove and Entry From the Cache removeEntry
Parameter filePath
The file path to remove from the cache
method renameAbsolutePathKeys
renameAbsolutePathKeys: (oldPath: string, newPath: string) => void;
Rename the absolute path keys. This is used when a directory is changed or renamed. renameAbsolutePathKeys
Parameter oldPath
The old path to rename
Parameter newPath
The new path to rename to
class FileEntryDefault
class FileEntryDefault {}
property create
static create: ( cacheId: string, cacheDirectory?: string, useCheckSum?: boolean, currentWorkingDirectory?: string) => FileEntryCache;
property createFromFile
static createFromFile: ( filePath: string, useCheckSum?: boolean, currentWorkingDirectory?: string) => FileEntryCache;
Type Aliases
type AnalyzedFiles
type AnalyzedFiles = { changedFiles: string[]; notFoundFiles: string[]; notChangedFiles: string[];};
type FileDescriptor
type FileDescriptor = { key: string; changed?: boolean; meta: FileDescriptorMeta; notFound?: boolean; err?: Error;};
type FileDescriptorMeta
type FileDescriptorMeta = { size?: number; mtime?: number; hash?: string; data?: unknown;};
type FileEntryCacheOptions
type FileEntryCacheOptions = { currentWorkingDirectory?: string; useCheckSum?: boolean; hashAlgorithm?: string; cache?: FlatCacheOptions;};
type GetFileDescriptorOptions
type GetFileDescriptorOptions = { useCheckSum?: boolean; currentWorkingDirectory?: string;};
Package Files (1)
Dependencies (1)
Dev Dependencies (7)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/file-entry-cache
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/file-entry-cache)
- HTML<a href="https://www.jsdocs.io/package/file-entry-cache"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2878 ms. - Missing or incorrect documentation? Open an issue for this package.