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

event-storage

v1.3.4

Published

An optimized embedded event store for node.js

Readme

event-storage

build npm version Code Climate Coverage Status Code documentation

node-event-storage

An optimized embedded event store for modern node.js, written in ES6.

📖 Full documentation on readthedocs.io


Why?

There is currently only a single other embedded event store for node/javascript: node-eventstore. It has a few drawbacks:

  • Its API requires loading a full Event Stream before committing, making it unfit for frequently-restarting client applications.
  • Its embeddable backends (TingoDB, NeDB) do not persist indexes and are slow on initial load.
  • Events are fixed to one stream — creating overlapping projection streams is not possible.

node-event-storage is built from first principles for append-only workloads, giving you near-optimal write speed with no unnecessary overhead.


Installation

npm install event-storage

CommonJS / require() users: version 1.0 is ESM-only. If your project uses require() and migrating to ESM is not an option, install the 0.x series (npm install event-storage@0) which is functionally equivalent and retains full CJS support.

import { EventStore } from 'event-storage';

const eventstore = new EventStore('my-event-store', { storageDirectory: './data' });

eventstore.on('ready', () => {
    // Write events
    eventstore.commit('my-stream', [{ type: 'SomethingHappened', value: 42 }], 0, () => {
        console.log('Written!');
    });

    // Read events
    const stream = eventstore.getEventStream('my-stream');
    for (const event of stream) {
        console.log(event);
    }
});

Key Features

| Feature | Summary | |---------|---------| | Optimistic concurrency | Pass expectedVersion to commit() to guarantee conflict-free writes. | | Flexible stream reading | Range queries, reverse iteration, and a fluent builder API. | | Derived streams | Filter or combine events into new read-only streams. | | Object matchers | Support nested equality, array values (OR semantics), and scalar operators like $gt / $gte / $lt / $lte / $eq / $ne, while still benefiting from O(1) discriminant routing on writes. | | DCB | Configure typeAccessor to have per-type stream indexes maintained automatically, and use query() / Condition for fine-grained, query-scoped optimistic concurrency (Dynamic Consistency Boundaries). | | Stream categories | Name streams <category>-<id> and query the whole category at once. | | Durable consumers | At-least-once (and exactly-once with setState) event delivery with automatic position tracking. | | Consistency guards | Build aggregates that enforce business invariants with built-in snapshotting. | | Read-only mode | Open the store from a second process to build projections without touching the writer. | | Crash safety | Torn writes detected and truncated on startup; automatic index repair via LOCK_RECLAIM; bounded, predictable data loss validated by a dedicated stress test. | | Custom serialization | Plug in msgpack, protobuf, or any other codec. | | Compression | Apply LZ4, zstd, or any other compression via the serializer option. | | Access control hooks | preCommit / preRead hooks with per-stream metadata for authorization. |


DCB Example

const { stream, condition } = store.query(['OrderPlaced'], { payload: { customerId: 'cust-1' } });
const hasOpenOrder = stream.some((event) => event.status === 'open');

if (!hasOpenOrder) {
    store.commit('orders-cust-1', [{ type: 'OrderPlaced', customerId: 'cust-1' }], condition);
}

Object Matcher Syntax

Object matchers support nested equality, array values, and scalar operators like $gt, $gte, $lt, $lte, $eq, and $ne.

{ payload: { type: ['OrderPlaced', 'OrderCancelled'] } }
{ payload: { amount: { $gte: 100, $lt: 1000 } } }

HTTP API

To expose an event store over HTTP, see the companion package event-storage-http:

npm install event-storage-http
import EventStore from 'event-storage';
import { createEventStoreHttpServer } from 'event-storage-http';

const eventStore = new EventStore('my-store', { storageDirectory: './data' });
const server = createEventStoreHttpServer(eventStore);
server.listen(3000);

The package exposes NDJSON stream endpoints, durable consumer management, and an HttpEventStream client helper for consuming event streams over fetch.


Documentation

The full documentation is hosted at https://node-event-storage.readthedocs.io/en/latest/ and covers:

  • Getting Started — installation, constructor options, basic usage.
  • Event Streams — writing, reading, optimistic concurrency, fluent API, joining streams, categories, and event metadata.
  • Dynamic Consistency Boundaries (DCB)typeAccessor, query matchers, consistency tokens, and the full DCB workflow.
  • Consumers — at-least-once and exactly-once delivery, consumer state, consistency guards, and read-only mode.
  • Advanced Topics — ACID properties, reliability and crash-safety guarantees, storage configuration, partitioning, custom serialization, compression, security, and access control hooks.

Run Tests

npm test