[![logo][]](https://xylabs.com)

# @xylabs/storage

[![npm][npm-badge]][npm-link]
[![license][license-badge]][license-link]

> Base functionality used throughout XY Labs TypeScript/JavaScript libraries

## Install

Using npm:

```sh
npm install {{name}}
```

Using yarn:

```sh
yarn add {{name}}
```

Using pnpm:

```sh
pnpm add {{name}}
```

Using bun:

```sh
bun add {{name}}
```


## License

See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).

## Reference

### packages

  ### storage

    ### .temp-typedoc

      ### interfaces

        ### <a id="KeyValueStore"></a>KeyValueStore

[**@xylabs/storage**](#../README)

***

A read/write storage device.

## Extends

- [`ReadonlyKeyValueStore`](#ReadonlyKeyValueStore)\<`TValue`, `TKey`\>

## Type Parameters

### TValue

`TValue`

### TKey

`TKey` = `string`

## Methods

### get()

```ts
get(key): Promisable<TValue | undefined>;
```

Returns a promise that resolves to the value for the given key.

### Parameters

#### key

`TKey`

The key to get the value for.

### Returns

`Promisable`\<`TValue` \| `undefined`\>

### Inherited from

[`ReadonlyKeyValueStore`](#ReadonlyKeyValueStore).[`get`](ReadonlyKeyValueStore.md#get)

***

### keys()?

```ts
optional keys(): Promisable<TKey[]>;
```

The keys an array of keys.

### Returns

`Promisable`\<`TKey`[]\>

### Inherited from

[`ReadonlyKeyValueStore`](#ReadonlyKeyValueStore).[`keys`](ReadonlyKeyValueStore.md#keys)

***

### clear()?

```ts
optional clear(): Promisable<void>;
```

Removes all entries from the store.

### Returns

`Promisable`\<`void`\>

***

### delete()

```ts
delete(key): Promisable<void>;
```

Deletes the entry with the given key.

### Parameters

#### key

`TKey`

The key of the entry to delete

### Returns

`Promisable`\<`void`\>

***

### set()

```ts
set(key, value): Promisable<void>;
```

Sets a value for the given key, creating or updating the entry.

### Parameters

#### key

`TKey`

The key to set

#### value

`TValue`

The value to store

### Returns

`Promisable`\<`void`\>

        ### <a id="ReadonlyKeyValueStore"></a>ReadonlyKeyValueStore

[**@xylabs/storage**](#../README)

***

A readonly storage device.

## Extended by

- [`KeyValueStore`](#KeyValueStore)

## Type Parameters

### TValue

`TValue`

### TKey

`TKey` = `string`

## Methods

### get()

```ts
get(key): Promisable<TValue | undefined>;
```

Returns a promise that resolves to the value for the given key.

### Parameters

#### key

`TKey`

The key to get the value for.

### Returns

`Promisable`\<`TValue` \| `undefined`\>

***

### keys()?

```ts
optional keys(): Promisable<TKey[]>;
```

The keys an array of keys.

### Returns

`Promisable`\<`TKey`[]\>

## Credits

[Made with 🔥 and ❄️ by XY Labs](https://xylabs.com)

[npm-badge]: https://img.shields.io/npm/v/@xylabs/storage.svg
[npm-link]: https://www.npmjs.com/package/@xylabs/storage
[license-badge]: https://img.shields.io/npm/l/@xylabs/storage.svg
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
[logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
