# @drpiou/async-storage

> Wraps the @react-native-async-storage/async-storage package

Latest version **0.0.2** (published 2022-07-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install @drpiou/async-storage
pnpm add @drpiou/async-storage
yarn add @drpiou/async-storage
bun add @drpiou/async-storage
```

## 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.2 |
| Published | 2022-07-11 |
| First published | 2022-06-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alex |
| Maintainers | dr.piou |

## Links

- npm: https://www.npmjs.com/package/@drpiou/async-storage
- Repository: https://github.com/drpiou/async-storage
- Homepage: https://github.com/drpiou/async-storage#readme
- Issues: https://github.com/drpiou/async-storage/issues
- npm.io page: https://npm.io/package/@drpiou/async-storage

## Recent versions

- 0.0.2 (latest) — 2022-07-11
- 0.0.1 — 2022-06-19

## README

# `@drpiou/async-storage`

![GitHub](https://img.shields.io/github/license/drpiou/async-storage)
![GitHub package.json version](https://img.shields.io/github/package-json/v/drpiou/async-storage)
![Jest tests](https://img.shields.io/badge/stage-experimental-important)

The `@drpiou/async-storage` package wraps the `@react-native-async-storage/async-storage` package.

> - type AsyncStorage.
> - written in TypeScript.

<!--ts-->

- [Compatibility](compatibility)
- [Installation](#installation)
- [Example](#example)
- [Documentation](#documentation)

<!--te-->

## Compatibility

- React (17.0.2+)
- React Native (0.64.0+)
- Expo (43+)

## Installation

```shell
yarn add @drpiou/async-storage
```

### Peer Dependencies

React and React Native project:

```shell
yarn add @react-native-async-storage/async-storage@~1.17.3
```

Expo project:

```shell
expo install @react-native-async-storage/async-storage
```

## Example

```typescript
import { AsyncStorage } from '@drpiou/async-storage';

type StorageItemValueMap = {
  lang_code: string;
  theme: string;
};

const storage = new AsyncStorage<StorageItemValueMap>();
```

## Documentation

```typescript
class AsyncStorage<S extends Record<string, unknown>> {
  getItem: <K extends keyof S, D extends S[K] | undefined>(
    key: K,
    defaultValue?: D,
    autoSet?: boolean,
  ) => Promise<D extends undefined ? S[K] | undefined : S[K]>;

  setItem: <K extends keyof S>(key: K, value: S[K]) => Promise<void>;

  hasItem: (key: keyof S) => Promise<boolean>;
  
  removeItem: (key: keyof S) => Promise<void>
}
```

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