# @taterer/persist-memory

> Persistence in memory

Latest version **2.0.0** (published 2023-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @taterer/persist-memory
pnpm add @taterer/persist-memory
yarn add @taterer/persist-memory
bun add @taterer/persist-memory
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-06-15 |
| First published | 2022-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 796.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Taylor McKay |
| Maintainers | jtmckay |
| Keywords | memory, persistence, database, functional, reactive, rxjs |

## Links

- npm: https://www.npmjs.com/package/@taterer/persist-memory
- Repository: https://github.com/taterer/persist
- Homepage: https://taterer.github.io/persist/
- Issues: https://github.com/taterer/persist/issues
- npm.io page: https://npm.io/package/@taterer/persist-memory

## Dependencies (1)

- [@taterer/persist](https://npm.io/package/@taterer/persist.md) ^2.0.0

## Recent versions

- 2.0.0 (latest) — 2023-06-15
- 1.0.5 — 2022-08-28
- 1.0.4 — 2022-08-28
- 1.0.3 — 2022-08-28
- 1.0.2 — 2022-08-28
- 1.0.1 — 2022-08-28

## README

# persist-memory
For when things should be remembered. Useful for domain entities.
Implements the @taterer/persist interface

## What is it?
A basic in-memory database, implemented with simply a Map.

## Why?
The @taterer/persist interface enables use in entity services. See https://github.com/taterer/rx-entity

## Example use
```
import { from, shareReplay, withLatestFrom } from "rxjs"
import { Persistable, Persistence } from "@taterer/persist"
import { memoryFactory } from "@taterer/persist-memory"

export enum MemoryEntity {
  line = 'line',
  shape = 'shape',
}

export async function memoryPersistence (): Promise<Persistence<any & Persistable, MemoryEntity>> {
  return memoryFactory<MemoryEntity>([
    {
      name: MemoryEntity.line,
    },
    {
      name: MemoryEntity.shape,
    },
  ])
}

export const memoryDB$ = from(memoryPersistence()).pipe(shareReplay(1))

export function withMemoryDB<T> () {
  return withLatestFrom<T, [Persistence<any & Persistable, MemoryEntity>]>(memoryDB$)
}
```

---
_Source: https://npm.io/package/@taterer/persist-memory · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
