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

storm-test

v0.0.3

Published

StormyDB is a tiny, lightweight, 0 dependency, easy-to-use JSON-based database for NodeJS, the browser or Electron. Being reuploaded and maintaned by A_c3y, originally created by Tom - https://github.com/TomPrograms

Downloads

6

Readme

Usage

Basic usage with NodeJS:

const Stormydb = require("stormydb");

// start db with "./db.Stormydb" storage location
const engine = new Stormydb.localFileEngine("./db.Stormydb");
const db = new Stormydb(engine);

// set default db value if db is empty
db.default({ users: [], stats: {} });

// add new users entry
db.get("users").push({ name: "tom" });

// update username of first user
db.get("users")
  .get(0)
  .get("name")
  .set("jeff");

// save changes to db
db.save();


// you can also use it all in one like this
db.set("game","starting").save();

var gameState = db.get("game").value()

// will return "starting"
console.log(gameState)

Features

  • 🏎️ Blazingly Fast Speeds - Fast read and write speeds, even when handling large data.
  • 📦 Tiny Size - Tiny source code size allows for blazingly fast loading when speed matters.
  • ⚡️ Versatile - Can be used with NodeJS, in the browser or in Electron.

Stormydb is designed to be flexible, and can be used in NodeJS, the browser or even Electron with very small adaptations to the code. Examples usages can be seen below:

Installation

Install Stormydb through NPM:

$ npm i stormydb

Typescript Usage:

import Stormydb from "stormydb";

// start db with "./db.stormdb" storage location
const engine = new Stormydb.localFileEngine("./db.stormydb");
const db = new Stormydb(engine);

Engine API

For expanding functionality, each database initialized can be expanded with the following options, in the format new Engine(path, options);.

  • serialize - function to serialize data before writing it to the database.
  • deserialize - function to deserialize data from the database.

Database Operations Examples

Change Value of Key in Database:

db.get("old").set("newData");
// before: {"old": "oldData"}
// after: {"old": "newData"}

Return the Raw Value of a Selected Property:

// before {"list": [1, 2, 3]}
db.get("list").value(); // returns [1, 2, 3]

Set Key-Value Pair on Dictionary Property:

db.set("key", "value").save();
// before: {}
// after: {"key": "value"}

Delete Value:

db.get("key").delete();
// before: {'key': 'value', 'key2': 'value2'}
// after: {'key2': 'value2'}

If you delete a value from a list, it will leave a null value in the place of the deleted data:

db.get("key").get(1).delete();
// before: {'key': [1, 2, 3]}
// after: {'key2': [1, null, 3]}

If you don't want this behaviour, you can pass in true to the .delete() function to not leave a null value in place of the deleted data:

db.get("key").get(1).delete(true);
// before: {'key': [1, 2, 3]}
// after: {'key2': [1, 3]}

Set Key-Value Pair on Dictionary with Shorthand Syntax:

db.set("key.key2", "value").save();
// before: {}
// after: {"key": {"key2": "value"}}

Set Default Data for Empty Database:

db.default({ name: "tom" });

// actual db: {}
console.log(db.get("name")); // prints "tom"

Push Item to Array Property:

db.get("list")
  .push(1)
  .save();

// before: {'list': []}
// after: {'list': [1]}

Filter Out All Elements under 5:

// before = {'list': [1,2,6,1]}
// output = {'list': [6]}

db.get("list").filter(i => i >= 5);

// save db
db.save();

Change Element with Highest Value:

// before = {'users': [{value: 10}, {value: 5}, {value: 6}]}
// after = {'users': [{value: "changed"}, {value: 6}, {value: 5}]}

db.get("users").sort((a, b) => b.value - a.value);

// change value of highest element
db.get("users")
  .get(0)
  .get("value")
  .set("changed");

// save db
db.save();

Map List, Squaring Each Number in List:

// before = {'data': [1,2,3,4,5]}
// after = {'data': [1,4,9,16,25]}

// square each number in the list
db.get("data").map(x => x ** 2);

// save db
db.save();

Reduce List, Finding Value of All Values in List Summed:

// before = {'data': [1,2,3,4,5]}
// after = {'data': 15}

// find value of all numbers in list summed together
db.get("data").reduce(
  (accumulator, currentValue) => accumulator + currentValue
);

// save db
db.save();

Leverage Serialize and Deserialize functions to encrypt and decrypt data:

const engine = new Stormydb.localFileEngine("./db.stormydb", {
  serialize: data => {
    // encrypt and serialize data
    return encrypt(JSON.stringify(data));
  },
  deserialize: data => {
    // decrypt and deserialize data
    return JSON.parse(decrypt(data));
  }
});
const db = new Stormydb(engine);

Changelog

  • Fixed Credits
  • Upgraded all packages, aka webpack, webpack cli
  • Added read(), write() as alternatives to save(), value()

Credit

Author: Tom Contributer - Republisher: Minlegoe - A_c3y

License

MIT