initial commit

This commit is contained in:
dude
2026-09-01 18:33:56 +00:00
commit c24449ee0a
2761 changed files with 302737 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _stream = require('stream');
var _crypto = require('crypto');
class HashStream extends _stream.Transform {
constructor(algo) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref$encoding = _ref.encoding;
let encoding = _ref$encoding === undefined ? 'hex' : _ref$encoding;
super({ objectMode: true });
this.algo = algo;
this.digestEncoding = encoding;
this.hashSum = (0, _crypto.createHash)(algo);
}
_transform(chunk, encoding, cb) {
// Update hash sum objects
this.hashSum.update(chunk);
cb();
}
_flush(cb) {
// Compute hash digest
const digest = this.hashSum.digest(this.digestEncoding);
// this.emit('hash', hash)
this.push({ digest });
cb(null);
}
}
exports.default = HashStream;