fasthash

0.2.0 • Public • Published

fasthash

Calculate hashes for files and directories the streaming way

Example

var fasthash = require("./fasthash");
 
// Defaults
var options = {
    algorithm: 'md5',
    relative: true 
};
 
// Usage: fasthash.file(filePath, [options], onComplete)
fasthash.file("testdata/index.html", options, function(error, hash) {
    if(error) {
        console.log(error);
    }
    console.log(hash);
    // a6febb912da51bcbcc443fc658c76c3d
});
 
// Usage: fasthash.file(dirPath, [options], onComplete)
fasthash.directory("testdata", options, function(hashes) {
    console.log(hashes);
    //  {
    //      'testdata/Dokumentation.pdf': 'a7b638e4e2cf0aa0cb945db4481da807',
    //      'testdata/index.html': 'a6febb912da51bcbcc443fc658c76c3d',
    //      'testdata/vendor/animate.min.css': '60aca30e688004a84ab7c554d257e527',
    //      ...
    //  }
});

Package Sidebar

Install

npm i fasthash

Weekly Downloads

2

Version

0.2.0

License

MIT

Last publish

Collaborators

  • tonbert