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

@bimetal/data

v0.9.0

Published

Event-sourcing data core for calendar applications: CalendarStore, undo/redo, pluggable storage

Downloads

733

Readme

@bimetal/data

Event-sourcing data core for calendar applications. Immutable, append-only, pluggable storage.

Installation

npm install @bimetal/data

Quick Start

import { createCalendarStore, createEvent, updateEvent, deleteEvent } from '@bimetal/data';
import { createDateTime, createTimeRange } from '@bimetal/core';

const store = createCalendarStore();

// Create
const event = {
  id: 'e1',
  title: 'Meeting',
  timeRange: createTimeRange(
    createDateTime(2026, 3, 15, 9, 0, 'Europe/Berlin'),
    createDateTime(2026, 3, 15, 10, 0, 'Europe/Berlin'),
  ),
  allDay: false,
  metadata: { color: '#007AFF', category: 'Work' },
};
await store.dispatch(createEvent(event));

// Update
await store.dispatch(updateEvent('e1', { title: 'Updated Meeting' }));

// Delete
await store.dispatch(deleteEvent('e1'));

// Undo (compensating event, append-only)
await store.undo('e1');

// Read
store.getEvents();                          // CalendarEvent[]
store.getEventsInRange(start, end);         // filtered by TimeRange
store.getHistory('e1');                     // DomainEvent[] — full timeline

// React to changes
store.subscribe(state => console.log(state.events));

Event Sourcing

State is never mutated directly. Every change produces an immutable domain event:

| Command | Domain Event | |---------|-------------| | createEvent(event) | CalendarEventCreated | | updateEvent(id, changes) | CalendarEventUpdated (carries previous for undo) | | deleteEvent(id) | CalendarEventDeleted (carries snapshot for restore) | | store.undo(id) | CalendarEventReverted (compensating event) |

Current state is a projection over the event stream. The event stream is the source of truth.

Pluggable Storage

EventStore is an interface. Default: InMemoryEventStore.

import { createCalendarStore } from '@bimetal/data';
import type { EventStore } from '@bimetal/data';

// Custom storage backend
const myStore: EventStore = {
  async append(streamId, events, expectedVersion) { /* ... */ },
  async read(streamId, fromVersion?) { /* ... */ },
  subscribe(handler, streamId?) { /* ... */ },
};

const store = createCalendarStore({ eventStore: myStore });

Command ID and Tracing

The command id is stored as causationId on resulting domain events for tracing. It does not provide deduplication — repeated dispatches of the same command will produce duplicate events.

Optimistic Concurrency

append() takes an expectedVersion. If another write happened in between, ConcurrencyError is thrown.

Configuration

createCalendarStore({
  defaultStreamId: 'my-calendar',
  clock: { now: () => Date.now() },        // injectable for tests
  generateId: () => crypto.randomUUID(),    // injectable for determinism
  eventStore: createInMemoryEventStore(),   // pluggable backend
});