# checkpoint-store

> In-memory key-value store with history! Keys are strings, values are any type.

Latest version **1.1.0** (published 2015-10-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install checkpoint-store
pnpm add checkpoint-store
yarn add checkpoint-store
bun add checkpoint-store
```

## 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 | 1.1.0 |
| Published | 2015-10-06 |
| First published | 2015-10-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | kumavis |
| Maintainers | kumavis |

## Links

- npm: https://www.npmjs.com/package/checkpoint-store
- Repository: https://github.com/kumavis/checkpoint-store
- Homepage: https://github.com/kumavis/checkpoint-store#readme
- Issues: https://github.com/kumavis/checkpoint-store/issues
- npm.io page: https://npm.io/package/checkpoint-store

## Dependencies (1)

- [functional-red-black-tree](https://npm.io/package/functional-red-black-tree.md) ^1.0.1

## Recent versions

- 1.1.0 (latest) — 2015-10-06
- 1.0.0 — 2015-10-06

## README

# Checkpoint-Store

In-memory key-value store with history!
Keys are strings, values are any type.

```js
var store = new CheckpointStore()
store.put('xyz', 'hello world')
store.checkpoint()
store.put('xyz', 'haay wuurl')

store.get('xyz') //=> 'haay wuurl'
store.revert()
store.get('xyz') //=> 'hello world'
```

Uses [functional-red-black-tree](https://github.com/mikolalysenko/functional-red-black-tree) under the hood.

### api

##### new CheckpointStore(initialState)

creates a new store. optionally pass in the intial state as a pojo.

##### store.put(key, value)

sets a value. key is a string. value is any type.

##### store.get(key)

returns a value. key is a string. value is any type.

##### store.del(key)

deletes a value. key is a string.

##### store.checkpoint()

adds a checkpoint. state of the store can be returned to this point.

##### store.revert()

returns to the state of the previous checkpoint. throws an error if there are no checkpoints.

##### store.commit()

keeps the state and removes the previous checkpoint. throws an error if there are no checkpoints.

##### store.isCheckpointed()

returns true if the store has remaining checkpoints.

##### store.copy()

returns a new CheckpointStore with matching state and checkpoints.

##### store.toJSON()

returns an object (not a string!) of the current state.

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