# keyv-extensions

> Adds functionality and sub content to keyv

Latest version **1.3.7** (published 2020-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install keyv-extensions
pnpm add keyv-extensions
yarn add keyv-extensions
bun add keyv-extensions
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.7 |
| Published | 2020-04-12 |
| First published | 2020-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Harry Kruger |
| Maintainers | non-hacker |
| Keywords | keyv, data, store, sub |

## Links

- npm: https://www.npmjs.com/package/keyv-extensions
- Repository: https://github.com/ha6000/Keyv-Extensions
- Homepage: https://github.com/ha6000/Keyv-Extensions#readme
- Issues: https://github.com/ha6000/Keyv-Extensions/issues
- npm.io page: https://npm.io/package/keyv-extensions

## Dependencies (1)

- [keyv](https://npm.io/package/keyv.md) ^4.0.0

## 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

- 1.3.7 (latest) — 2020-04-12
- 1.3.6 — 2020-04-12
- 1.3.4 — 2020-04-12
- 1.3.3 — 2020-04-11
- 1.3.2 — 2020-04-11
- 1.3.1 — 2020-04-11
- 1.3.0 — 2020-04-11
- 1.2.2 — 2020-04-11
- 1.2.1 — 2020-04-11
- 1.2.0 — 2020-04-11
- 1.1.2 — 2020-04-11

## README

# Keyv-Extensions ![.github/workflows/build.yml](https://github.com/ha6000/Keyv-Extensions/workflows/.github/workflows/build.yml/badge.svg?event=push)
> Adds functionality and sub content to keyv

## Introduction
The idea for this is to have proxy arrays and keyv stores that will allow you to save array or another keyv database inside a keyv database

## Examples

### Proxy Array

Creating a array linked to a database and adding test value

```js
const keyvExt = require('keyv-extensions');
const arr = keyvExt.keyvArray(keyv, 'arr');
arr[0] = 'test';
```

### Sub Keyv

Creating a sub keyv and setting values

```js
const keyvExt = require('keyv-extensions');
const sub = new Keyv({store: new keyvExt(keyv, 'sub')});
sub.set('test', 'testvalue');
```
# Documentation
## Classes

<dl>
<dt><a href="#KeyvSub">KeyvSub</a></dt>
<dd><p>A Keyv store, so you can put a keyv db inside another keyv db</p>
</dd>
</dl>

## Functions

<dl>
<dt><a href="#keyvArray">keyvArray(database, key, [arr])</a> ⇒ <code>Promise.&lt;Array&gt;</code></dt>
<dd><p>Creates a array inside a keyv database</p>
</dd>
</dl>

<a name="KeyvSub"></a>

## KeyvSub
A Keyv store, so you can put a keyv db inside another keyv db

**Kind**: global class  

* [KeyvSub](#KeyvSub)
    * [new KeyvSub(database, key)](#new_KeyvSub_new)
    * [.get(key)](#KeyvSub+get) ⇒ <code>Promise.&lt;any&gt;</code>
    * [.set(key, value)](#KeyvSub+set) ⇒ <code>Promise.&lt;true&gt;</code>
    * [.delete(key)](#KeyvSub+delete) ⇒ <code>Promise.&lt;boolean&gt;</code>
    * [.clear()](#KeyvSub+clear) ⇒ <code>Promise.&lt;true&gt;</code>

<a name="new_KeyvSub_new"></a>

### new KeyvSub(database, key)

| Param | Type | Description |
| --- | --- | --- |
| database | <code>Keyv</code> | The database to put the key in |
| key | <code>string</code> | Key name |

**Example**  
```js
var sub = new Keyv({store: new KeyvSub(db, 'data')})
```
<a name="KeyvSub+get"></a>

### keyvSub.get(key) ⇒ <code>Promise.&lt;any&gt;</code>
Gets a value

**Kind**: instance method of [<code>KeyvSub</code>](#KeyvSub)  
**Returns**: <code>Promise.&lt;any&gt;</code> - The value  

| Param | Type |
| --- | --- |
| key | <code>string</code> | 

<a name="KeyvSub+set"></a>

### keyvSub.set(key, value) ⇒ <code>Promise.&lt;true&gt;</code>
Sets a key to some value

**Kind**: instance method of [<code>KeyvSub</code>](#KeyvSub)  
**Returns**: <code>Promise.&lt;true&gt;</code> - True if it was succesfull  

| Param | Type |
| --- | --- |
| key | <code>string</code> | 
| value | <code>any</code> | 

<a name="KeyvSub+delete"></a>

### keyvSub.delete(key) ⇒ <code>Promise.&lt;boolean&gt;</code>
Deletets a value

**Kind**: instance method of [<code>KeyvSub</code>](#KeyvSub)  
**Returns**: <code>Promise.&lt;boolean&gt;</code> - True if it exists and false if not  

| Param | Type |
| --- | --- |
| key | <code>string</code> | 

<a name="KeyvSub+clear"></a>

### keyvSub.clear() ⇒ <code>Promise.&lt;true&gt;</code>
Clears the database

**Kind**: instance method of [<code>KeyvSub</code>](#KeyvSub)  
**Returns**: <code>Promise.&lt;true&gt;</code> - True if it was succesfull  
<a name="keyvArray"></a>

## keyvArray(database, key, [arr]) ⇒ <code>Promise.&lt;Array&gt;</code>
Creates a array inside a keyv database

**Kind**: global function  
**Returns**: <code>Promise.&lt;Array&gt;</code> - Promise with the array  

| Param | Type | Description |
| --- | --- | --- |
| database | <code>Keyv</code> | The database to put the array in |
| key | <code>string</code> | The key the array will be stored in |
| [arr] | <code>Array</code> | The array to create on |

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