Node.js API compatibility - Stream
This documentation explores the integration and use of the Node.js Stream module within the Azion Runtime. The Stream module is a fundamental part of Node.js, providing an abstract interface for handling streaming data.
The stream module in Node.js is a core component that facilitates the handling of streaming data. It allows developers to read and write data in a continuous flow, making it efficient for processing large volumes of data without consuming excessive memory.
Example: Basic readable and writable streams
The example below shows how to use the stream module in a function:
Example: Transform stream for data processing
Use Transform streams to modify data as it passes through:
Example: PassThrough stream for data forwarding
Use PassThrough streams to forward data without modification:
Example: Duplex stream for bidirectional communication
Create streams that can both read and write:
Example: Processing request body with streams
Stream request body data for efficient processing:
Supported APIs
| API | Status |
|---|---|
stream.Readable | 🟢 Supported |
stream.Writable | 🟢 Supported |
stream.Duplex | 🟢 Supported |
stream.Transform | 🟢 Supported |
stream.PassThrough | 🟢 Supported |
stream.pipeline() | 🟢 Supported |
stream.compose() | 🟡 Partially supported |
stream.finished() | 🟡 Partially supported |
readable.pipe() | 🟢 Supported |
readable.on('data') | 🟢 Supported |
readable.on('end') | 🟢 Supported |
readable.on('error') | 🟢 Supported |
writable.write() | 🟢 Supported |
writable.end() | 🟢 Supported |
transform.push() | 🟢 Supported |