# cf-workers-kv

> Cloudflare workers KV with customizable backing store for testing.

Latest version **0.0.0** (published 2021-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install cf-workers-kv
pnpm add cf-workers-kv
yarn add cf-workers-kv
bun add cf-workers-kv
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0 |
| Published | 2021-05-13 |
| First published | 2021-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Alan Shaw |
| Maintainers | alanshaw |
| Keywords | cloudflare, kv, store, map |

## Links

- npm: https://www.npmjs.com/package/cf-workers-kv
- Repository: https://github.com/alanshaw/cf-workers-memkv
- Homepage: https://github.com/alanshaw/cf-workers-memkv#readme
- Issues: https://github.com/alanshaw/cf-workers-memkv/issues
- npm.io page: https://npm.io/package/cf-workers-kv

## Recent versions

- 0.0.0 (latest) — 2021-05-13

## README

# cf-workers-kv

[![Build Status](https://travis-ci.com/alanshaw/cf-workers-kv.svg?branch=main)](https://travis-ci.com/alanshaw/cf-workers-kv)
[![dependencies Status](https://status.david-dm.org/gh/alanshaw/cf-workers-kv.svg)](https://david-dm.org/alanshaw/cf-workers-kv)

Cloudflare workers KV with customizable backing store for testing.

## Install

```sh
npm install cf-workers-kv
```

## Usage

```js
import { KV } from 'cf-workers-kv'

// In memory map backend, also supports AsyncMapLike inerface for backing stores
// with async get/put etc. https://npm.im/async-map-like
const backend = new Map()
const fruits = new KV(backend)

const key = 'apple:grannysmith'
const value = { name: 'Granny Smith', type: 'apple', color: 'green' }
const metadata = { name: 'Granny Smith' }

await fruits.put(key, JSON.stringify(value), { metadata })

const apple = await fruits.get(key, 'json')
console.log(apple) // { name: 'Granny Smith', type: 'apple', color: 'green' }

const apples = await fruits.list({ prefix: 'apple:' })
console.log(apples) // { keys: [{ name: 'apple:grannysmith', metadata: { name: 'Granny Smith' } }], list_complete: true }

await fruits.delete(key)
```

## API

See [Cloudflare Workers Runtime API docs](https://developers.cloudflare.com/workers/runtime-apis/kv).

## Contribute

Feel free to dive in! [Open an issue](https://github.com/alanshaw/cf-workers-kv/issues/new) or submit PRs.

## License

[MIT](LICENSE) © Alan Shaw

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