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

gaia.db-lite

v0.0.1-alpha6

Published

A lite version of Gaia.DB.

Downloads

5

Readme

Gaia.DB-Lite

A lite version of Gaia.DB.

Examples

Singlethreaded

const { Database } = require(`gaia.db-lite`);
const db = new Database;

(async () => {
    await db.setup();
    db.set(0, "hi");
    console.log(db.data, db.get("hi"));
    await db.save();
})();

Multithreaded

index.js

const { Master } = require(`${__dirname}/../src/index.js`);
const master = new Master;

setImmediate(async () => {
    await master.setup();
    await master.fork(`${__dirname}/child.js`);
});

child.js

console.log(`[${process.pid}] Here!`);
setImmediate(async () => {
    await $set(true, process.pid.toString());
    console.log(`[${process.pid}] ${await $get(process.pid.toString())}`);
    await $save();
});

Methods

Singlethreaded

new Database(folderPath?: String = "./database")

  • folderPath Database's folder path. Create new database instance.

Database#save(maxSizePerFile?: Number = 1024) -> Promise<Database#read()>

  • maxSizePerFile Max buffer size per db file in bytes. Save the database. Note: Stored in multiple files.

Database#read() -> Promise<this>

Read the database files and refresh cache (database object).

Database#setup() -> Promise<this>

Create the database folder if it's not exist and do other stuffs.

Database#set(value: Any, path?: String) -> this

Change path's value of database object. If path is a falsy value, it will change the database object and the value must be an object.

Database#get(path?) -> Any

Get path's value of database object. If path is a falsy value, it will returns the database object.

Database#delete(path?) -> Any

Unset path's value of database object. If path is a falsy value, it will set database object's value to a blank object.

Database#data

Database object.

Database#folderPath

Database's folder path.

Multithreaded

new Master(folderPath?: String = "./database", childFilePath?: String)

  • folderPath Database's folder path.
  • childFilePath Default child's file path for Master#spawn. Master class have same properties and methods with Database and EventEmitter.

Master#fork(childFilePath?: String) -> Promise<ChildProcess>

Fork a file to create new child.

Child

global.$set(value: Any, path?: String) -> Promise<this>

A copy of Database#set.

global.$get(value: Any) -> Promise<Any>

A copy of Database#get.

global.$delete(path?: String) -> Promise<this>

A copy of Database#delete.

global.$save(maxSizePerFile?: Number = 1024) -> Promise<this>

A copy of Database#save.

global.$folderPath

Database's folder path.

Support Us

PayPal

Developer

Discord: Ganora Mirush#9524 NPM: nekomaru76 GitHub: NekoMaru76