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

async-storage-repl

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-storage-repl

AsyncStorageRepl provides you to manipurate ReactNative AsyncStorage API on your node REPL.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

AsyncStorageREPL

AsyncStorageRepl provides you to access remote ReactNative application's AsyncStorage from your node REPL.

gif

npm i async-storage-repl -D

BasicUsage

  1. Write bellow code in your ReactNative Application.
import AsyncStorageREPL from 'async-storage-repl';
AsyncStorageREPL().connect();
  1. Start node REPL.
./node_modules/.bin/async-storage-repl
  1. Let's get access your ReactNative application's storage from your node REPL.
$ ./node_modules/.bin/async-storage-repl
> RNAsyncStorage.getItem('item1')
null
> RNAsyncStorage.setItem('item1', 'nice value!')
null
> RNAsyncStorage.getItem('item1')
'nice value!'
> RNAsyncStorage.getAllKeys()
[ 'reduxPersist:timeline',
  'item1',
  'reduxPersist:auth',
  'reduxPersist:nav' ]

Example

example

API

AsyncStorage APIs

AsyncStorageREPL provides RNAsyncStorage on your node REPL as a global object. You can access AsyncStorage's all APIs via this object.

  • getAllKeys(): string[]
  • getItem(key: string)
  • setItem(key: string, value: string)
  • removeItem(key: string)
  • mergeItem(key: string, value: string)
  • clear()
  • flushGetRequests()
  • multiGet(keys: string[])
  • multiSet(keyValuePairs: string[][])
  • multiRemove(keys: string[])
  • multiMerge(keyValuePairs: string[][])

AsyncStorageREPL's methods args are guaranteed type-safe by flow-runtime.

> RNAsyncStorage.getItem(1)
RuntimeTypeError: key must be a string

Expected: string

Actual: number

dump & load

You can save & load RN Application AsyncStorage data.

dump() provides you getting dump. load(string[][]) provides you loading dump.

> const data = RNAsyncStorage.dump()
undefined
> data
[ [ 'comments', '["foo","bar","baz"]' ] ]
> fs.writeSync('./dump1.txt', JSON.stringify(data))
> const data = JSON.parse(fs.readSync('./dump1.txt'))
> RNAsyncStorage.load(data)
null

Advanced Usage

ReactNative side

AsyncStorageREPL() accepts an object with a host and port key. Port key must be matched REPL side. You don't need specify a host in case of running on a simulator. but in case of runnning on a real device, specify your computer host.

AsyncStorageREPL({ host: 'localhost', port: 8080 }) // default
  .connect();

REPL side

You can specify portNo --port option.

async-storage-repl --port 8080

FAQs

Package last updated on 14 Dec 2017

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