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

evansofts-memdb

v0.0.2

Published

An in-memory database for nodejs

Downloads

3

Readme

MEMDB ika (meowDB)

Build Status

A simple, fast and pure Javascript key-value in memory database for Node JS.

Introduction

This lightweight engine can be used in place of things like LevelDB, Redis while keeping things light and very simple. Internaly, memdb uses json as storage format with an opt-in support for encryption. In order to achieve performance, memdb keeps things in a staging area for fast access. No worries, all the booking is handled for you :). We are developers too, thus we hate keeping tract of things.

Synopsis

  const MemDB = require('memdb')
  const db = new MemDB('_starwars', {encryptionKey: 'secret'}) 

  db.put('skywalker', {
      force: 'light',
      name: 'Luke Skywalker'
  }).then((status) => {
    console.log(status) // => true
  })
  
  db.get('skywalker').then((rsp) => {
    console.log(rps) // => [Object skywalker...]
  })

Installation

  $ npm install evansofts-memdb

API

MemDB's API is pretty simple and straigth forward. Some api methods return a promise.

  • version(): Get MemDB current version
  • revision(): Get the current database revision
  • options(): Get the database instance options
  • put(keychain, value, loose): Save data in the database
  • get(keychain, defaultValue): Get data from the database
  • all(): Get all data fron the database
  • delete(keychain): Delete data from the database

NB: What the heck is keychain ? keychain is a concatenation of multiple object keys to obtain a path for accessing an object property in a deep level. This is a convenient way of puting/getting deeply nested object properties. The following keychain server.dev.host means accessing the host property form dev object which in turn is available in the server object as a property.

Creating or Opening a database

  /*
    By default, the databse is not encrypted and the stagging 
    operation size limit is 600 operations; of course you can move it up or down
  */
  const db = new MemDB('db_file_path', {
      stagingSize: 600, // maximum staging operation size before flushing the data 
      encryptionKey: null // optional if you need to encypt your data
  })

Saving data

put(keychain, value, loose)

| Parameters | Description | |--------------|--------------| | keychain| Path where the data should be stored | | value | The value to be stored | | loose | Will create internal object of the chain if non existant, default to false |

  db.put('server.dev.host', 'https://dev.alex.com', true).then((status) => {
    console.log(status) // => true
  })

Retrieving data

get(keychain, defaultValue)

| Parameters | Description | |--------------|--------------| | keychain | Path where the data should be retrieved | | defaultValue | The default value to be returned if not found |

  db.get('server.dev.host', 'https://dev.alex.com').then((rsp) => {
    console.log(rsp) // => https://dev.alex.com
  })

all()

  db.all().then((rsp) => {
    console.log(rsp) // => whole database document
  })

Deleting data

delete(keychain)

| Parameters | Description | |-------------|-------------| | keychain | Path where the data should be deleted |

  db.delete('server.dev.host').then((rsp) => {
    console.log(rsp) // => true
  })

Testing

After cloning the repo and installing all dependencies (using npm install) you can run all tests using mocha:

$ npm test