# key-value-file-store

> Simple key value store where and each value is a file.

Latest version **1.1.1** (published 2022-05-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install key-value-file-store
pnpm add key-value-file-store
yarn add key-value-file-store
bun add key-value-file-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.1 |
| Published | 2022-05-02 |
| First published | 2021-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | 'Dominic Tarr' |
| Maintainers | staltz, arj03 |

## Links

- npm: https://www.npmjs.com/package/key-value-file-store
- Repository: https://github.com/arj03/key-value-file-store
- Issues: https://github.com/arj03/key-value-file-store/issues
- npm.io page: https://npm.io/package/key-value-file-store

## Dependencies (1)

- [atomic-file-rw](https://npm.io/package/atomic-file-rw.md) ^0.3.0

## Recent versions

- 1.1.1 (latest) — 2022-05-02
- 1.1.0 — 2022-05-02
- 1.0.1 — 2021-10-30
- 1.0.0 — 2021-10-29

## README

# Key value file store

Simple key value store where and each value is a file.

This project is a fork of [lossy-store] where raw fs is replaced with
[atomic-file-rw] to provide browser support.

## api

### store = LossyStore(dir, codec?)

create a lossy store with the given [codec] (or JSON by default) at
the `dir`

### store.has(key)

returns true if this key is currently in the store.

### store.ensure(key, cb)

ensure that this key is loaded from the file system.
if the file has already been read, `cb` is called immediately.
if `set` is called while waiting for the filesystem, `cb` is called immediately.

### store.get (key, cb)

get the current value for key, loading it if necessary

### store.get (key) => value

return the currently set `value` for `key`. may be null.

### store.set(key, value)

Set a new value. this will trigger a write to be performed (at some point)

### store.delete(key)

Delete a key-value from the store.

## License

MIT

[lossy-store]: https://github.com/dominictarr/lossy-store
[codec]: https://www.npmjs.com/package/flumecodec
[atomic-file-rw]: https://github.com/ssb-ngi-pointer/atomic-file-rw

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