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 🙏

© 2025 – Pkg Stats / Ryan Hefner

simple-bdb

v1.0.2

Published

A lightweight, simple binary database for Node.js applications. SimpleBDB uses MsgPack encoding for efficient storage and fast access, making it perfect for small to medium-sized projects.

Readme

SimpleBDB

A lightweight, simple binary database for Node.js applications. SimpleBDB uses MsgPack encoding for efficient storage and fast access, making it perfect for small to medium-sized projects.

Features

  • 📦 Binary Storage: Stores data in an efficient binary format using MsgPack
  • 🔄 Auto-save: Automatically saves changes to disk (configurable)
  • 🔍 Nested Keys: Support for dot notation to access nested properties
  • 🛠️ Data Manipulation: Includes utility methods for common operations (add, subtract, push, pull)
  • 💾 Persistent Storage: Data persists between application restarts
  • 🚀 Simple API: Easy to learn and integrate

Installation

npm install simple-bdb
# or
yarn add simple-bdb

Usage

Basic Usage

// Import the database
const SimpleBDB = require('simple-bdb');
// or with ES modules
import SimpleBDB from 'simple-bdb';

// Create a new database instance
const db = new SimpleBDB({ filePath: './data/mydb.bdb' });

// Set a value
db.set('user.name', 'John');

// Get a value
const name = db.get('user.name'); // Returns 'John'

// Check if a key exists
const hasAge = db.has('user.age'); // Returns false

// Delete a key
db.delete('user.name'); // Returns true

Working with Numbers

// Add to a number
db.set('counter', 10);
db.add('counter', 5); // counter is now 15

// Subtract from a number
db.subtract('counter', 3); // counter is now 12

Working with Arrays

// Push to an array
db.set('users', ['Alice']);
db.push('users', 'Bob'); // users is now ['Alice', 'Bob']

// Remove elements from an array
db.pull('users', user => user === 'Alice'); // users is now ['Bob']

Advanced Usage

// Get all data
const allData = db.all();
// Returns: [{ ID: 'user', data: { name: 'John' }}, { ID: 'counter', data: 12 }]

// Clear database
db.clear();

API Documentation

Constructor

new SimpleBDB(options)

Options:

  • filePath (string, optional): Path to the database file. Default: 'database.bdb'
  • autoSave (boolean, optional): Whether to automatically save changes. Default: true
  • cachedData (boolean, optional): Whether to cache data for making less read request to your os. Default: true

Methods

set(key, value)

Sets a value in the database.

  • Returns: The value that was set

get(key, defaultValue = null)

Gets a value from the database.

  • Returns: The value or defaultValue if key doesn't exist

has(key)

Checks if a key exists.

  • Returns: Boolean

delete(key)

Deletes a key from the database.

  • Returns: Boolean (true if key was deleted)

add(key, amount)

Adds a number to a value.

  • Returns: The new value

subtract(key, amount)

Subtracts a number from a value.

  • Returns: The new value

push(key, value)

Pushes a value to an array.

  • Returns: The new array

pull(key, callback)

Removes elements from an array using a filter function.

  • Returns: The new array

all()

Gets all data from the database.

  • Returns: Array of objects with ID and data properties

save()

Manually saves data to the database file.

clear()

Clears all data from the database.