
💃 Getting Started ​
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
$ npm i @jolly-pixel/event-store
# or
$ yarn add @jolly-pixel/event-store👀 Usage example ​
import * as EventStore from "@jolly-pixel/event-store";
const store = EventStore.persistence.memory();
store.writer.append({
assetType: "pixelart",
assetId: "<UUID>",
eventType: "pixelart.command",
eventData: {
action: "uv-region-moved",
metadata: {},
clientId: "533454a2-4f09-47c5-8e24-dc5d479c578e",
timestamp: 1788814248122
},
actor: {
type: "user",
id: "533454a2-4f09-47c5-8e24-dc5d479c578e"
}
}).unwrap();
const events = store.reader.list("<UUID>");
console.log(events);📚 API ​
All backends expose the same EventStore API.
📦 Persistence ​
Each factory returns a writer and a reader sharing the same storage, plus lifecycle close().
import * as EventStore from "@jolly-pixel/event-store";
EventStore.persistence.memory();
await EventStore.persistence.sqlite();
await EventStore.persistence.indexeddb({ name: "events" });NOTE
The package entrypoint is safe to import from browser code. persistence.sqlite loads its Node-only backend when called.
📈 Benchmarks ​
$ pnpm --filter @jolly-pixel/event-store bench
$ pnpm --filter @jolly-pixel/event-store bench readSuites live in bench/ and run on the shared @jolly-pixel/bench harness. They cover append, the reader, listFromCheckpoints against listAll, and compact, over three backends: memory, sqlite:memory and sqlite:file.
✨ Contributors guide ​
If you are a developer looking to contribute to the project, you must first read the CONTRIBUTING guide.
Run these commands from the monorepo root:
$ pnpm --filter @jolly-pixel/event-store test
$ pnpm run lintCAUTION
In case you introduce a new feature or fix a bug, make sure to include tests for it as well.
📃 License ​
MIT