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

dbfeazy

v1.0.6

Published

A small and light object oriented database

Readme

DBFeazy

GitHub license GitHub issues GitHub issues

What if a database was as cheap as a variable?

DBFeazy allows you to have a single, simple and small DB.

TODO

  • [ ] Async version with promise

Install and simple example

Installation: npm install dbfeazy

Example

npm start

Here is a small example of how to open, restore, add, get and save the new database state.

const DBFeazy = require("dbfeazy");

const db = new DBFeazy("users"); // Opens user.dbf and user.dbo files
db.Restore(); // Restores previous state

// Adding some values
db.Add("kursion.age", 27);
db.Add("kursion.lang", "en");

// Adding an object
const nellyInfo = { age: 29, lang: "fr" };
db.Add("nelly", nellyInfo);

// Deleting something
db.Add("kursion.sex", "small");
db.Del("kursion.sex");

// Updating a value if its key exists
if (db.Exists("kursion.age")) {
  db.Add("kursion.age", 18);
}

// Getting a value
db.Get("nelly"); // {age: 45, lang: 'fr'}
db.Get("kursion.sex"); // undefined (since we deleted it)
db.Get("kursion.age"); // 27
db.Get("olivier.age"); // 45

/**
 * Save the DB
 * NOTE: until now every operations are stored in the the operations file (check
 * futher for more information) and the memory.
 *
 * Since we finished to work on this database we can store the current state of
 * the database and clean the operation file.
 */
db.Save();

/**
 * Now the operations file (users.dbo) should be cleaned and the database object
 * should be stored into the database file (users.dbf) as a stringified JSON.
 */

What is it ?

DBFeazy uses two distinguish files that are using different mechanisms:

  • the operations file or oplog file (extension .dbo)
  • the database object file (extension .dbf

This section will present both of them.

The operations file

Operations are stored into an oplog (operations log) or operations file (both terms are the same). An operation of the oplog file is called an opline. Here is a sample of an operations file after the following few operations:

  1. adding keys with their values:
  • db.Add('kursion.age', 18)
  • db.Add('kursion.sex', 'm')
  1. deleting a key:
  • db.Del('kursion.age')
  1. updating an existing key and value
  • db.Add('kursion.age', 27)

And the users.op operations file:

...
+:kursion.age:18
+:kursion.sex:"m"
-:kursion.age
+:kursion.age:27
...

The database object

The database object is a simple JavaScript object, a hashmap. This object is stored into the DBF which stands for "database file" (eg: ./users.dbf). Its content is a stringified JSON object.

The state of the database can be manipulate through those functions:

  • Restore()
  • Save()

The database object can be manipulate with these operations:

  • Add(key, value)
  • Del(key)
  • Get(key)
  • Exists(key)

Keys and values

The key is a string, eg:

db.Get('kursion') # 'kursion' being a key

And it handles multiple string keys separated by a dot, eg:

db.Get('kursion.age') # 'kursion.age' being a multikey

It can store all JavaScript types as value:

  • strings
  • arrays
  • numbers
  • objects

Why ?

I wanted to have a simple DB module that is very easy to use and has no dependencies. The performance will, for sure, not be great. This DB is not for production. It was created for fast prototyping.


Operations

Example using operations

The constructor new DBFeazy(...) will automatically create the .dbf and .dbo files if the don't exist.

DBFeazy = require("dbfeazy")
db = new DBFeazy("user")
db.Restore()
... check below ...
db.Save()

Restore

Restore the DB (from the .dbf and .dbo files).

db.Restore()

Save

Saves the current state of the database. This will write the database object into the .dbf file and will clean the operation log file (.dbo).

db.Save()

Add

Adds or updates a key-value pair to the database object

db.Add(key, value)

Delete

Delete a key from the database object

db.Del(key)

Get

Get a key

db.Get(key)

Exists

Returns true if the key exists, or false if it doesn't exist.

db.Exists(key)

Terms

  • multikey: is a key that can have sub-keys separated by a dot. Eg: users.cool.kursion represents the sub-part of an object:
obj = {
  users: {
    cool: {
      kursion: { ... }
    }
  }
}
  • op: is an operation (that can be + add, - delete)

Performances

tests/test-massive.coffee: this test is looping every 1ms to db.Add() something in the DB. Each 10sec the DB is saved. Here are the results for 10mio of add operations:

performances

(i7, 16 GB, Surface Pro 4, Windows 10 / also tested on Archlinux)

NOTES

  • NodeJS
  • CoffeeScript