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

database-2.js

v2.2.0

Published

A new database for big projects

Downloads

3

Readme

Database 2

Database 2 is a new modern nosql, file path based database.

It needs the same amount of ram for datas ranging from 1mb to 1e+75TB, no ram difference for data!

This package contains 2 separate classes Client and Server

Performance Server

This is the ClustedServer function inside the package. It creates multiple server instances but costs a lot of resources

const {ClustedServer} = require("database-2.js");

ClustedServer(instances, port, users, callback fn)

Instances

Number of instances to run (for eg. 800, min 1)

WARNING

Costs a lot of resources

port & users & callback fn

See constructor props

Server

The server is the backend of the database wrapper. It should be always 24/7 running in order for database to work.

Methods

All methods

Constructor

connect

shutdown

get

exists

set

add

subtract

delete

Constructor

Inputs

port

Number | String

users

    Array[]{
         name: string, 
         passsord: string, 
         role: "all" | "read" | "write" | "delete" | Array<"read" | "write" | "delete" | "all">
    }

Callback Fn (optional)

         function (event, ...args) {

         }
Event
              error (if any error occured)
                       > Error Stack
              ready
                       > Port
              blocked-request
                       > Request Object
                       > Response Object
                       > Status Code Sent
                       > Json Msg Sent
              allowed-request
                       > Request
                       > Response
              blocked-read
                       > Request 
                       > Response
              allowed-read
                       > Request
                       > Response
              blocked-write
                       > Request
                       > Response
              allowed-write
                       > Request
                       > Response
              blocked-delete
                       > Request
                       > Response
              allowed-delete
                       > Request
                       > Response
const {Server} = require("database-2.js");

const users = [
         {
                  name: "ahq", //It is used to identify the user
                  password: "1234", //It will be hashed and stored in RAM
                  role: "all" //read, write, delete
         }
];

const logFn = (event, ...args) => {
         console.log(`${event} occured with args: `, ...args);
}

const Database = new Server(3000, users, logsFn);

Connect

Connects the database

Database.connect();

Shutdown

Kills the process and shutdowns the database. (Cannot be done in the client side)

Database.shutdown();

get

Gets data with relative paths. Client Side Permission "read" required

Input

path > relative path (eg. "database/store", "database" is where the key "store" is located)

Output

String (JSON string)

console.log(JSON.parse(Database.get("myservice/accounts/account-a")));

exists

Check if file exists. Client side permission "read" required

Inputs

path > relative path

Output

Boolean (true/false)

console.log(Database.exists("keys/user1"));

set

Sets data to a relative path. Client side permission "write" required.

Inputs

path > relative path

data > JSON stringified data () > JSON.stringify(any)

Database.set("myservice/accounts/account-a", JSON.stringify({name: "AHQ"}));

add

Adds data to a relative path. Client side permission "write" required

WARNING

For numbers only

Inputs

path > relative path

number > Number to subtract

Database.add("some/value", 1);

subtract

Subtracts data to a relative path. Client side permission "write" required

WARNING

For numbers only

Inputs

path > relative path

number > Number to subtract

Database.add("some/value", 1);

delete

Deletes data from a relative path. Client side permission "delete" required

Inputs

path > relative path

Database.delete("some/value");

Client

Module coming soon!