npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

haspr-rndb

v1.1.11

Published

An Offline Database for React Native and Expo

Downloads

18

Readme

Haspr Offline Database for React Native and Expo

This package has been created by Haspr for use in their in-house projects. Others are free to use this package and leave their feedback for improvements

License - Copyright (c) 2022, Haspr. All rights reserved.

HASPR

Installation

Use the package manager yarn or npm to install haspr-rndb.

yarn add haspr-rndb

or

npm install haspr-rndb

Features

  • High Performance VM Storage
  • Offline Storage for instant access
  • CRUD Operations are a breeze
  • Works with Both React Native and Expo

Load Database

In order to use the database, you have to first declare it in your App.js file before the functions for best performance You only have to do this once at the top level of your React Native or Expo App, which will usually be App.js

import HasprDB from 'haspr-rndb'
import React from 'react'
import { View, Text } from 'react-native'

HasprDB() //` Start the Database

export default function App() {
  return (
    <View>
      <Text>Your App Here...</Text>
    </View>
  )
}

Performing CRUD Operations

You can use the build in operations create, read and remove to perform crud operations

1. create()

The create function can be used to create simple strings, Objects, Nested Objects, Arrays, and Booleans. The Create functions can also be used to update values as it creates new values and keeps the existing data intact.

import HasprDB, { create } from 'haspr-rndb'
import React from 'react'
import { View, Text, TouchableOpacity } from 'react-native'

HasprDB() //` Start the Database

export default function App() {
  const saveUser = () => {
    const OTP = 861245
    create('pin', OTP)
    const result = create('user.auth.name', 'The Rock')
    console.log(result)
    // result >>{ user: { auth: { name: "The Rock" } } }
    navigation.navigate('VerifyPin')
  }

  return (
    <View>
      <TouchableOpacity onPress={saveUser}>Save Pin</TouchableOpacity>
    </View>
  )
}

2. read()

The read function can be used to read simple strings, Objects, Nested Objects, Arrays, and Booleans using string path of objects connected with dots, e.g. , one may want to check if user is logged in from an object, read('user.auth.isLogin') if exists will return the value TRUE

import HasprDB, { read } from 'haspr-rndb'
import React from 'react'
import { View, Text, TouchableOpacity } from 'react-native'

HasprDB() //` Start the Database

export default function App() {
  const pin = read('pin')
  console.log(pin)
  // result >> 861245

  const user = read('user.auth')
  console.log(user)
  // result >> { name: "The Rock" }

  return (
    <View>
      <TouchableOpacity onPress={saveUser}>Save Pin</TouchableOpacity>
    </View>
  )
}

3. remove()

The remove function can be used to delete simple strings, Objects, Nested Objects, Arrays, and Booleans using string path of objects connected with dots.

import HasprDB, { remove } from 'haspr-rndb'
import React from 'react'
import { View, Text, TouchableOpacity } from 'react-native'

HasprDB() //` Start the Database

export default function App() {
  // Remove Single Data
  const deletePin = () => remove('pin')

  // Remove Nested Data
  const deleteName = () => remove('user.auth.name')

  // Remove Multiple Data
  const deleteMultiple = () => remove(['user.auth', 'theme'])

  // Clear All Data and Reset DB
  const deleteAllData = () => remove()

  return (
    <View>
      <TouchableOpacity onPress={deletePin}>Delete Pin</TouchableOpacity>
      <TouchableOpacity onPress={deleteName}>Delete Name</TouchableOpacity>
      <TouchableOpacity onPress={deleteMultiple}>Delete Multiple</TouchableOpacity>
      <TouchableOpacity onPress={deleteAllData}>Delete Everything</TouchableOpacity>
    </View>
  )
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Feedback

If you have any feedback, please reach out to us at [email protected]

🔗 Links

portfolio

facebook

instagram

twitter

linkedin

youtube

pinterest

behance

dribbble

github

Logo