What is @aws-sdk/util-stream-node?
@aws-sdk/util-stream-node is a utility package from the AWS SDK for JavaScript that provides functions to work with Node.js streams. It is particularly useful for handling streaming data in AWS services.
What are @aws-sdk/util-stream-node's main functionalities?
streamToBuffer
Converts a readable stream into a buffer. This is useful when you need to process the entire content of a stream as a single buffer.
const { streamToBuffer } = require('@aws-sdk/util-stream-node');
const { Readable } = require('stream');
const readableStream = Readable.from(['Hello', ' ', 'World']);
streamToBuffer(readableStream).then(buffer => {
console.log(buffer.toString()); // Output: Hello World
});
streamToString
Converts a readable stream into a string. This is useful when you need to process the entire content of a stream as a single string.
const { streamToString } = require('@aws-sdk/util-stream-node');
const { Readable } = require('stream');
const readableStream = Readable.from(['Hello', ' ', 'World']);
streamToString(readableStream).then(string => {
console.log(string); // Output: Hello World
});
bufferToStream
Converts a buffer into a readable stream. This is useful when you need to process a buffer as a stream.
const { bufferToStream } = require('@aws-sdk/util-stream-node');
const buffer = Buffer.from('Hello World');
const stream = bufferToStream(buffer);
stream.on('data', chunk => {
console.log(chunk.toString()); // Output: Hello World
});
Other packages similar to @aws-sdk/util-stream-node
stream-to-buffer
The 'stream-to-buffer' package provides a simple utility to convert a stream into a buffer. It is similar to the 'streamToBuffer' function in @aws-sdk/util-stream-node but is a standalone package.
stream-to-string
The 'stream-to-string' package provides a utility to convert a stream into a string. It is similar to the 'streamToString' function in @aws-sdk/util-stream-node but is a standalone package.
buffer-to-stream
The 'buffer-to-stream' package provides a utility to convert a buffer into a stream. It is similar to the 'bufferToStream' function in @aws-sdk/util-stream-node but is a standalone package.
@aws-sdk/util-stream-node
Deprecated package
This internal package is deprecated in favor of @aws-sdk/util-stream.
Package with utilities to operate on Node.JS streams.
Usage
You probably shouldn't, at least directly.