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

neutron-db

v0.1.0

Published

Attempt to create a JSON db for lectron using typescript.

Readme

Neutron DB

A simple JSON database for TypeScript projects with both synchronous and asynchronous implementations.

How to use

The database is initialized with a schema:

interface Schema {
  tables: string[]; // names of the tables
  dbname: string; // base name of the JSON database file
  oneIndexed?: boolean; // if true, id generation starts at 1 instead of 0
  compressedJson?: boolean; // if true, the database file is written on a single line
  writeDebounceMs?: number; // async only: debounce delay before persisting changes
  autoSaveIntervalMs?: number; // async only: periodic flush interval
  location: string; // path to the database directory or exact JSON file
}

The stored objects must implement DbObject:

interface DbObject {
  id: number;
}

location can be either:

  • a directory path, in which case the database file is created as dbName.json
  • an exact file path, in which case that file is created directly

The library creates the directory and the database file automatically if they do not exist.

Usage

Sync database

import path from 'path';
import { Database } from 'neutron-db';

const db = new Database({
  tables: ['users', 'posts'],
  dbname: 'app-data',
  location: path.join(__dirname, 'data'),
  oneIndexed: true,
  compressedJson: false,
});

const alice = db.insert({ id: -1, name: 'Alice' }, 'users');
const users = db.getAll('users');

Async database

import path from 'path';
import { AsyncDatabase } from 'neutron-db';

const db = await AsyncDatabase.create({
  tables: ['users', 'posts'],
  dbname: 'app-data',
  location: path.join(__dirname, 'data'),
  oneIndexed: true,
  compressedJson: false,
  writeDebounceMs: 150,
  autoSaveIntervalMs: 5000,
});

const alice = await db.insert({ id: -1, name: 'Alice' }, 'users');
const users = await db.getAll('users');

API

Sync Database

insert<T extends DbObject>(row: T, tablename: string): T
update<T extends DbObject>(row: T, tablename: string): T
getAll<T extends DbObject>(tablename: string): T[]
get<T extends DbObject>(id: number, tablename: string): T | null
delete(id: number, tablename: string): void
clear(tablename: string): void
count(tablename: string): number

Async AsyncDatabase

static create(schema: Schema): Promise<AsyncDatabase>
insert<T extends DbObject>(row: T, tablename: string): Promise<T>
update<T extends DbObject>(row: T, tablename: string): Promise<T>
getAll<T extends DbObject>(tablename: string): Promise<T[]>
get<T extends DbObject>(id: number, tablename: string): Promise<T | null>
delete(id: number, tablename: string): Promise<void>
clear(tablename: string): Promise<void>
count(tablename: string): Promise<number>
dispose(): Promise<void>

Notes

  • The sync implementation performs immediate file writes.
  • The async implementation caches data in memory and flushes changes to disk with debounce and auto-save support.
  • Call dispose() on AsyncDatabase to flush any pending writes and stop internal timers.
  • The async implementation does not automatically reload changes made to the JSON file by external processes.
  • Table names must be declared in the schema.
  • Duplicate IDs are rejected when explicitly provided.
  • The file and parent directory are created automatically if needed.

Heavily inspired by electron-db