# @castore/event-storage-adapter-in-memory

> DRY Castore EventStorageAdapter implementation using a JS object

Latest version **2.4.2** (published 2025-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @castore/event-storage-adapter-in-memory
pnpm add @castore/event-storage-adapter-in-memory
yarn add @castore/event-storage-adapter-in-memory
bun add @castore/event-storage-adapter-in-memory
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.4.2 |
| Published | 2025-04-18 |
| First published | 2023-10-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 169.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 276 |
| Maintainers | julietteff, charlesgery, valentinbeggi, thomasaribart |
| Keywords | event, source, store, typescript |

## Links

- npm: https://www.npmjs.com/package/@castore/event-storage-adapter-in-memory
- Repository: https://github.com/castore-dev/castore
- Homepage: https://github.com/castore-dev/castore#readme
- Issues: https://github.com/castore-dev/castore/issues
- npm.io page: https://npm.io/package/@castore/event-storage-adapter-in-memory

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 2.4.2 (latest) — 2025-04-18
- 2.4.1 — 2025-02-25
- 2.4.0 — 2025-02-18
- 2.3.1 — 2024-04-25
- 2.3.0 — 2024-03-20
- 2.2.0 — 2024-01-16
- 2.1.0 — 2023-11-03
- 2.0.0 — 2023-10-27

## README

# In Memory Event Storage Adapter

DRY Castore [`EventStorageAdapter`](https://castore-dev.github.io/castore/docs/event-sourcing/fetching-events/) implementation using a JS object.

This class is mainly useful for manual and unit tests. It is obviously not recommended for production uses 🙂

## 📥 Installation

```bash
# npm
npm install @castore/event-storage-adapter-in-memory

# yarn
yarn add @castore/event-storage-adapter-in-memory
```

This package has `@castore/core` as peer dependency, so you will have to install it as well:

```bash
# npm
npm install @castore/core

# yarn
yarn add @castore/core
```

## 👩‍💻 Usage

```ts
import { InMemoryEventStorageAdapter } from '@castore/event-storage-adapter-in-memory';

const pokemonsEventStorageAdapter = new InMemoryEventStorageAdapter({
  // 👇 You can specify an initial state for your event store
  initialEvents: [
    {
      aggregateId: '123',
      ...
    },
  ],
});

const pokemonsEventStore = new EventStore({
  ...
  eventStorageAdapter: pokemonsEventStorageAdapter,
});
```

## 🤔 How it works

This adapter simply persists events in a local dictionary. You can retrieve it at all time through the `eventStore` property:

```ts
const eventStore = pokemonsEventStore.eventStore;
// => { [aggregateId: string]: EventDetail[] }
```

---
_Source: https://npm.io/package/@castore/event-storage-adapter-in-memory · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
