1.0.5 • Published 3 years ago
@savant/fs-cache v1.0.5
@savant/fs-cache
A simple NodeJS library for checking if the contents of a file or directory have changed since the last time the function was called.
Installation
npm install @savant/fs-cacheUsage
const fsCache = require('@savant/fs-cache');
let didChange;
// Initial call
console.log(fsCache.hasChanged('unique-id', '/path/to/directory')); // true
// Subsequent calls
console.log(fsCache.hasChanged('unique-id', '/path/to/directory')); // false
// Changed ID call
console.log(fsCache.hasChanged('changed-new-unique-id', '/path/to/directory')); // trueAPI
hasChanged(id: string, path: string)
Parameters
id: a unique string identifier for the directory or file you want to check.path: the file or directory path you want to check.
Returns
trueif the contents of the file or directory have changed since the last call with the same id.falseif the contents of the file or directory have not changed since the last call with the same id.