Use NodeHash as a Transform stream
masterThe NodeHash class extends Node.js Transform. This allows you to pipe data directly into the hasher and receive the digest as the output of the stream. When the stream is flushed, it emits the digest.
import { createHash } from 'blake3-wasm/src/node/hash-instance';
import { Readable } from 'stream';
const hasher = createHash();
const source = Readable.from(['chunk1', 'chunk2']);
source
.pipe(hasher)
.on('data', (digest: Buffer) => {
console.log('Hash:', digest.toString('hex'));
});