Giter Club home page Giter Club logo

asyncstorage-down's Introduction

asyncstorage-down

borrows very heavily and gratefully from localstorage-down

Implementation of leveldown for React's AsyncStorage

The idea is to be able to use the level stack in React Native

This project is intended for use with the level eco-system.

Install

npm install asyncstorage-down

Example

At the command prompt in your chosen directory :

npm install asyncstorage-down
npm install levelup

Create a file called index.js and enter the following:

import asyncstorageDown from 'asyncstorage-down'
import levelup from 'levelup'
// or whichever implementation you're using
import AsyncStorage from '@react-native-community/async-storage'

const db = levelup('/does/not/matter', {
  db: location => asyncstorageDown(location, { AsyncStorage })
})

db.put('name', 'Yuri Irsenovich Kim');
db.put('dob', '16 February 1941');
db.put('spouse', 'Kim Young-sook');
db.put('occupation', 'Clown');

db.readStream()
   .on('data', function (data) {
      if (typeof data.value !== 'undefined') {
         console.log(data.key, '=', data.value);
      }
   })
   .on('error', function (err) {
      console.log('Oh my!', err);
   })
   .on('close', function () {
      console.log('Stream closed');
   })
   .on('end', function () {
     console.log('Stream ended');
   });

Note

React Native's packager currently doesn't automatically inject browserified core node modules, like util, crypto, process, buffer, etc. Currently this module depends on several shims to mitigate the sadness. The alternative is to use react-native-webpack-server, which allows you to use browserified node core modules out of the box. Once React Native's packager allows the same functionality, this module's dependencies can be heavily pruned.

Alternatives

If you're willing to add native modules to your project, you may also be interested in react-native-leveldown, which implements native bindings to the original C++ implementation of LevelDB.

Related Projects

Contributors

Tradle, Inc. https://github.com/tradle

Mark Vayngrib https://github.com/mvayngrib

Ellen Katsnelson https://github.com/pgmemk

Andre Staltz https://github.com/staltz

localstorage-down Contributors

Anton Whalley https://github.com/no9

Adam Shih https://github.com/adamshih

Nolan Lawson https://github.com/nolanlawson

asyncstorage-down's People

Contributors

mvayngrib avatar staltz avatar mrtruongleo avatar andymatuschak avatar davidnpma avatar psychollama avatar sethvincent avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.