Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sync-storage

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sync-storage

Synchronous storage for React Native.

  • 0.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

SyncStorage

Synchronous storage for React Native AsyncStorage.

Build Status codecov npm version license

Get Started

Installation

yarn add sync-storage
# or
# npm i --save sync-storage

Usage

import SyncStorage from 'sync-storage';

SyncStorage.set('foo', 'bar');

const result = SyncStorage.get('foo');
console.log(result); // 'bar'

Methods Available

init()

Init prepares the SyncStorage to work synchronously, by getting all values for all keys previously saved on RN AsyncStorage. See the example:

const data = await SyncStorage.init();
console.log('AsyncStorage is ready!', data);
get(key: string)

Returns the value of key.

SyncStorage.get('foo'); // 'bar'
set(key: string, value: Any type)

It saves the value on memory and on the AsyncStorage.

SyncStorage.set('foo', 'bar');
SyncStorage.get('foo'); // 'bar'

It also returns a Promise for post verification.

SyncStorage.set('foo', 'bar')
  .then(() => {
    SyncStorage.get('foo'); // 'bar'
  })
  .catch(error => {
    console.log(error);
  });
remove(key: string)

It removes the value from the memory and from the AsyncStorage.

SyncStorage.remove('foo');

It also returns a Promise for post verification.

SyncStorage.remove('foo')
  .then(() => {
    SyncStorage.get('foo'); // undefined
  })
  .catch(error => {
    console.log(error);
  });
getAllKeys()

returns an array from all the keys.

SyncStorage.set('foo', 'bar');
SyncStorage.set('boo', 'baz');
console.log(SyncStorage.getAllKeys()) // ['foo', 'boo']

Keywords

FAQs

Package last updated on 27 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc