What is @aws-sdk/eventstream-marshaller?
@aws-sdk/eventstream-marshaller is a package within the AWS SDK for JavaScript that provides utilities for serializing and deserializing event streams. This is particularly useful for working with AWS services that use event streams, such as AWS Transcribe and AWS Kinesis.
What are @aws-sdk/eventstream-marshaller's main functionalities?
Serialize Event Stream
This feature allows you to serialize an event stream. The code sample demonstrates how to create an instance of EventStreamMarshaller and use it to serialize an event.
const { EventStreamMarshaller } = require('@aws-sdk/eventstream-marshaller');
const { TextEncoder } = require('util');
const marshaller = new EventStreamMarshaller(new TextEncoder(), new TextDecoder());
const event = { headers: {}, body: Buffer.from('example data') };
const serialized = marshaller.marshall(event);
console.log(serialized);
Deserialize Event Stream
This feature allows you to deserialize an event stream. The code sample demonstrates how to create an instance of EventStreamMarshaller and use it to deserialize an event.
const { EventStreamMarshaller } = require('@aws-sdk/eventstream-marshaller');
const { TextDecoder } = require('util');
const marshaller = new EventStreamMarshaller(new TextEncoder(), new TextDecoder());
const serialized = Buffer.from('example serialized data');
const event = marshaller.unmarshall(serialized);
console.log(event);
Other packages similar to @aws-sdk/eventstream-marshaller
event-stream
The event-stream package is a toolkit for working with streams in Node.js. It provides a variety of utilities for creating and manipulating streams, including event streams. While it is more general-purpose compared to @aws-sdk/eventstream-marshaller, it can be used for similar tasks involving stream processing.
kinesis-client-library
The kinesis-client-library is a package specifically designed for working with AWS Kinesis streams. It provides higher-level abstractions for consuming and processing Kinesis streams, making it more specialized compared to @aws-sdk/eventstream-marshaller, which is more low-level and general-purpose for event stream serialization and deserialization.