npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dynamodb-stream-emitter

v0.2.0

Published

EventEmitter adapter for DynamoDB streams

Readme

dynamodb-stream-emitter

Current Version Build Status via Travis CI Dependencies belly-button-style

EventEmitter adapter for DynamoDB streams.

Usage

dynamodb-stream-emitter exports a single class, DynamoDBStreamEmitter that extends the Node.js EventEmitter. The following example demonstrates its usage.

'use strict';
const { DynamoDBStreamEmitter } = require('dynamodb-stream-emitter');
const { DynamoDBStreams } = require('aws-sdk');
const client = new DynamoDBStreams();
const ee = new DynamoDBStreamEmitter({ client });

ee.on('record', (record, streamArn, shardId) => {
  console.log(record, streamArn, shardId);
});

ee.start();

API

The DynamoDBStreamEmitter class is an abstraction around the AWS SDK's DynamoDBStreams client.

DynamoDBStreamEmitter(options) Constructor

  • Arguments
    • options (object) - Configuration data supporting the following options:
      • client (object) - An AWS SDK DynamoDBStreams client.
      • describeStreamLimit (integer) - The maximum number of streams to return from each call to DescribeStream(). Optional. Defaults to 100 (the maximum value supported by AWS).
      • getRecordsLimit (integer) - The maximum number of streams to return from each call to GetRecords(). Optional. Defaults to 1,000 (the maximum value supported by AWS).
      • listStreamsLimit (integer) - The maximum number of streams to return from each call to ListStreams(). Optional. Defaults to 100 (the maximum value supported by AWS).
      • sleepMs (integer) - The amount of time, in milliseconds, to wait between polling API calls. Optional. Defaults to 1,000 milliseconds.
      • tableName (string) - The name of the DynamoDB table to return streams for. Optional. Defaults to all available streams.

Constructs a new DynamoDBStreamEmitter instance.

DynamoDBStreamEmitter.prototype.start(initialState)

  • Arguments
    • state (Map or array representation of a Map) - A map of shard IDs (string) to shard states (object) to poll on. Only shards belonging to streams that the emitter is polling are processed. The schema of each shard state is:
      • streamArn (string) - The stream ARN of the shard.
      • shardId (string) - The shard identifier.
      • iteratorType (string) - The type of DynamoDB shard iterator to create. If lastSequenceNumber is present, this field will be set to 'AFTER_SEQUENCE_NUMBER'.
      • lastSequenceNumber (string) - The sequence number in the shard to resume reading after. Optional.
  • Returns
    • Nothing

This function begins polling for DynamoDB stream events. If start() is called on an emitter that is already polling, an exception is thrown.

DynamoDBStreamEmitter.prototype.stop()

  • Arguments
    • None
  • Returns
    • Nothing

This function stops polling for DynamoDB stream events. Unlike start(), the stop() function is idempotent.

DynamoDBStreamEmitter.prototype.isPolling()

  • Arguments
    • None
  • Returns
    • A boolean indicating whether the emitter is polling or not.

This function returns a boolean indicating whether the emitter is polling or not.

'record' Event

  • Arguments
    • record (object) - A Record object.
    • streamArn (string) - The stream ARN that produced record.
    • shardId (string) - The shard identifier that produced record.

This event is emitted each time a new record is read from the stream.

'start' Event

  • Arguments
    • None

This event is emitted once DynamoDBStreamEmitter.prototype.start() has been called and stream polling has begun.

'stop' Event

  • Arguments
    • state (Map) - The current state of all DynamoDB streams being polled by the emitter.

This event is emitted once DynamoDBStreamEmitter.prototype.stop() has been called and any existing DynamoDB polling streams are shutdown. The current state of all existing streams is also provided as an argument to the event handler.

The state is represented as a JavaScript Map. The state Map can be passed to DynamoDBStreamEmitter.prototype.start() in order to resume listening. The state Map can be serialized to JSON using JSON.stringify(Array.from(state)) and deserialized back to a Map using new Map(JSON.parse(jsonString)).