fs-compare
Simple comparison of attributes of two files.
Installation
npm install fs-compare
Usage
Asynchronous
var fsCompare = ; var { fs;}; ;
Stat helpers are included, so you can shortcut the above with:
var fsCompare = ; fsCompare;
Synchronous
var fsCompareSync = sync; var { return fsmtime;}; var diff = ; // diff is -1 if foo.txt was created before bar.txt// diff is 0 if foo.txt was created at the same time as bar.txt// diff is 1 if foo.txt was created after bar.txt
Stat helpers are included, so you can shortcut the above with:
var fsCompareSync = sync; var diff = fsCompareSync; // diff is -1 if foo.txt was created before bar.txt// diff is 0 if foo.txt was created at the same time as bar.txt// diff is 1 if foo.txt was created after bar.txt
API
fsCompare(testFunction, fileNameA, fileNameB, callback)
testFunction
- Function with parameters(fileName, cb)
which tests the file and returns the value to be compared on the callback.fileNameA
,fileNameB
- Filenames of files to be tested.callback
- Callback to accept(error, diff)
, wherediff
is:- -1 - file A tests less than file B
- 0 - file A tests equal to file B
- 1 - file A tests greater than file B
fsCompare.mtime(fileNameA, fileNameB, callback)
Compares the modified timestamp of the files.
fsCompare.ctime(fileNameA, fileNameB, callback)
Compares the created timestamp of the files.
fsCompare.atime(fileNameA, fileNameB, callback)
Compares the access timestamp of the files.
fsCompare.size(fileNameA, fileNameB, callback)
Compares the size of the files.
fsCompareSync(testFunction, fileNameA, fileNameB)
Synchronous version of fsCompare
.
fsCompareSync.mtime(fileNameA, fileNameB, callback)
Synchronous version of fsCompare.mtime
.
fsCompareSync.ctime(fileNameA, fileNameB, callback)
Synchronous version of fsCompare.ctime
.
fsCompareSync.atime(fileNameA, fileNameB, callback)
Synchronous version of fsCompare.atime
.
fsCompareSync.size(fileNameA, fileNameB, callback)
Synchronous version of fsCompare.size
.