# @windingtree/sdk-storage

> Key-value database abstraction layer

Latest version **1.5.0** (published 2024-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @windingtree/sdk-storage
pnpm add @windingtree/sdk-storage
yarn add @windingtree/sdk-storage
bun add @windingtree/sdk-storage
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2024-03-11 |
| First published | 2023-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 220.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Kostiantyn Smyrnov |
| Maintainers | kostysh, kvakes, tomashq |

## Links

- npm: https://www.npmjs.com/package/@windingtree/sdk-storage
- Repository: https://github.com/windingtree/sdk.git#readme
- Homepage: https://github.com/windingtree/sdk/tree/readme#readme
- Issues: https://github.com/windingtree/sdk/issues
- npm.io page: https://npm.io/package/@windingtree/sdk-storage

## Dependencies (5)

- [buffer](https://npm.io/package/buffer.md) ^6.0.3
- [superjson](https://npm.io/package/superjson.md) ^2.2.1
- [classic-level](https://npm.io/package/classic-level.md) ^1.3.0
- [level-transcoder](https://npm.io/package/level-transcoder.md) ^1.0.1
- [@windingtree/sdk-logger](https://npm.io/package/@windingtree/sdk-logger.md) 1.1.4

## Recent versions

- 1.5.0 (latest) — 2024-03-11
- 1.4.1-beta.0 (beta) — 2024-01-17
- 1.4.2 — 2024-01-26
- 1.4.1 — 2024-01-17
- 1.4.0 — 2023-12-22
- 1.3.1 — 2023-12-11
- 1.3.0 — 2023-11-29
- 1.2.2 — 2023-10-31
- 1.2.1 — 2023-10-31
- 1.2.0 — 2023-10-25
- 1.2.0-beta.0 — 2023-10-25
- 1.1.0 — 2023-07-27
- 1.1.0-beta.3 — 2023-07-27
- 1.1.0-beta.2 — 2023-07-27
- 1.1.0-beta.1 — 2023-07-23
- … 1 more at https://npm.io/package/@windingtree/sdk-storage/versions

## README

# @windingtree/sdk-storage

The package `@windingtree/sdk-storage` provides a key-value database abstraction layer for Winding Tree SDK. It includes concrete implementations for in-memory storage and browser localStorage. More implementations are expected soon.

## Installation

```bash
pnpm i @windingtree/sdk-storage
```

## Key concepts

- The `Storage` class is an interface for key-value databases. It defines methods for setting, getting, and deleting keys, as well as iterating over all entries.
- The `MemoryStorage` class is an in-memory storage implementation of the `Storage` interface.
- The `LocalStorage` class is a browser localStorage implementation of the `Storage` interface.
- Storage classes include methods to handle storage scope and serialization/deserialization of values.

## Usage

Here is a simplified example of how you can use the `@windingtree/sdk-storage` package:

```typescript
import { memoryStorage, localStorage } from '@windingtree/sdk-storage';

// Create an instance of memory storage
const memStorage = await memoryStorage.createInitializer()();

// Use the storage
await memStorage.set('key1', 'value1');
const value = await memStorage.get('key1'); // 'value1'

// Create an instance of local storage
const localStore = await localStorage.createInitializer()();

// Use the storage
await localStore.set('key2', 'value2');
const value = await localStore.get('key2'); // 'value2'
```

## Documentation

For full documentation and examples, visit [windingtree.github.io/sdk](https://windingtree.github.io/sdk)

## Testing

```bash
pnpm test
```

## Contributing

[Contribution guidelines](https://windingtree.github.io/sdk/#/docs/contribution)

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