custom-transform-stream.js
✓ Published0🌍 Public
Aalessioalex
Last edited Nov 22, 2014
Created on Nov 22, 2014
This example demonstrates a custom Node.js transform stream that computes a SHA-1 hash of incoming text data. The stream, named `ShaSum`, uses the `stream.Transform` base class and the `crypto.createHash` API to update the hash incrementally with each chunk. It writes two lines of input, then outputs the final hex digest to `process.stdout` via the `_flush` method, showing how transform streams can process data piecewise and emit a result only at the end.
AI-generated description