universal-asyncstorage
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

universal-asyncstorage npm

AsyncStorage

Support

browser weex miniApp wechatMiniprogram quickApp bytedanceMicroApp

Install

$ npm install universal-asyncstorage --save

Usage

import AsyncStorage from 'universal-asyncstorage';
 
// How to use it in quickapp
// import chooseImage from 'universal-asyncstorage/lib/quickapp;
 
// setItem(key, value)
AsyncStorage.setItem('key', 'value').then(() => {});
 
// getItem(key)
AsyncStorage.getItem('key').then(value => {
  if (value !== null){
    console.log(value);
  }
});
 
// removeItem(key)
AsyncStorage.removeItem('key').then(res => {});
 
// getAllKeys()
AsyncStorage.getAllKeys().then(res => {
  console.log(res.join());
});
 
// clear()
AsyncStorage.clear().then(() => {});

Methods

setItem(key: string, value: string): Promise<null>

Arguments

Property Type Description Default
key string Storage key -
value string Storage value -

getItem(key: string): Promise<string | null>

Arguments

Property Type Description Default
key string Storage key -

Returns

Property Type Description
result string | null Storage value

removeItem(key: string): Promise<null>

Arguments

Property Type Description Default
key string Storage key -

getAllKeys(): Promise<string[]>

Returns

Property Type Description
result string[] Storage all keys

clear(): Promise<null>

Readme

Keywords

none

Package Sidebar

Install

npm i universal-asyncstorage

Weekly Downloads

24

Version

1.3.0

License

BSD-3-Clause

Unpacked Size

36.4 kB

Total Files

28

Last publish

Collaborators

  • zeroling
  • yuanyan
  • rax-publisher