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 🙏

© 2026 – Pkg Stats / Ryan Hefner

neudb

v1.1.1

Published

A simple in-memory database

Readme

NeuDB

A simple in-memory database

NeuDb is a simple in-memory database package I made as I needed it in some of my projects, it works very well with Electron, but it also works in any other application, it would not be ideal as a proper database, most likely just as local storage alternative.

I released it publicly for feedback, and for fun. hope helps!

documentation is WIP
read example.js for specifics.

Basic example

Setup

const NeuDB = require('neudb');

const template = {
    name: "",
    last_name: "Doe",//set default value
    age: 0,
    location: {
        continent: "",
        house_number: 0
    },
    notes: []
};

const db = new NeuDB({
    data: template, //set up template data for expected data
});

//OR
const db = new NeuDB({
    data: {//shorten version for readability
        name: "",
        last_name: "Doe",
        notes: []
    },
});

Get Data

db.get('name');

Set Data

db.set('name','John');

Chaining Data

you can also chain most basic functions (get, set, put) ex.

db.get('location').set('house_number', 5);
//or
db.get('location').get('house_number');

When chaining you will (should) receive the last object accessed.

Constructor Properties

data

  • required
  • default: {}
  • Data is a required property used to set the base data for the database, this is useful if you always expect a certain dataset for your database.

autoSave

  • default: true
  • Autosave is if it automatically saves the database on any change.

asBinary

  • default: false
  • asBinary is if it will save as a readable json file. or unreadable (sortof) binary file.

filePath

  • default: __dirname + "/db" (+ file extension) //not ideal path, but it works

  • filepath is the path of the data file it will write the data to (without the file extension).

  • cache

  • default: false

  • with cache set to true, the data will never be stored to disk (unless you call db.save()), it can still load the data if the file exists this will overwrite the value for autoSave to false.

  • customParser

  • details

Functions

Get

Get is the basic function to get data from the database. you can use it very straight forward like:

db.get('property_name');

This function is chainable to get embedded property values.

Set

Set is the basic function to set data on the database. you can use it like:

db.set('property_name', property_value);

This function is also chainable to set embedded property values.

Put (previously push)

Put is the basic function to put data into an array property. If a property is an array, you can put an object onto it using put ex.

db.put('notes', "make readme file");

Put is also chainable to put onto embedded properties. in this case you do not need to add the property name. ex.

//template: {user: {name: "John", notes: []}}

db.get('user').put( "Make readme file")

put does not allow duplicates by default, you can force put a value into the array using the 3rd property force, like so:

db.put('notes', "make readme file", true);

Force is false by default.

Save

Save is needed to save the data, this will be done automatically if you enable autosave, so in that case you don't need to worry about this. Otherwise, you can call it like this:

db.save(); //returns db object (for chaining)

Load

Load is used to load the data on initialization, you can always call it. This could be useful if you want to undo changes and you haven't saved the changes yet (with autosave off).

You use it like:

db.load(); //returns db object for chaining

This will automatically set the data to the loaded data, and return the db object.

Reset

Reset is an advanced function to reset the database structure

You use it like:

db.load(template);

it needs the parameter to be an object with the same properties as the original, otherwise it will throw an error you can overwrite this with a second parameter like this:

db.load({newObject: "this is an example"}, true);

this would overwrite the template to the new structure.

you can do an unsafe reset using:

db.load(db.get());

but this is not recommended

Custom parser

Using the custom parser object you can save and load using custom functions. for example if you want to serialize to a different format as json (ex. yaml)

There's a few properties that come with this function

  • enabled

  • default: false
  • enable the custom parser
  • resetOnError

  • default: true
  • will reset the db if the parser errors (ex. old parser is yaml and you use json parser)
  • stringify

  • default: null
  • function that returns stringified data to write to disk ex: (t)=>{return JSON.stringify(t, null, 4)}
  • parser

  • default: null
  • function that returns parsed object from string (t)=>{return JSON.parse(t)}
  • ext

  • default: 'cst'
  • file extension to save to

Example:

example using the js-yaml library to save as yaml

const NeuDB = require('neudb');
const yaml = require('js-yaml');

const db = new NeuDB({
    data: { sample:true },
    customParser: {
        enabled: true,
        stringify: yaml.dump,
        parser: yaml.load,
        ext: 'yaml'
    }
});