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

lavastore

v1.2.4

Published

LavaStore is a flexible and scalable local database for the web.

Downloads

17

Readme

About

LavaStore is a flexible and scalable local database for web development. It uses a document-oriented data model to store persistent data safely with our built-in powerful storage structure.

Features

  • Easy to learn
  • Intuitive data modeling structure inspired from Firestore (Firebase)
  • Simple and readable API
  • TypeScript types Support

Third-party extensions

  • Query Language Support
  • ~~Asynchronous~~ (in-progress)

Install

LavaStore can be installed using npm (or directly downloaded from the official GitHub repo).

npm i lavastore

View the project on NPM or GitHub.

Usage

Documents contains sub-collections and fields (data), and Collections contains sub-documents.

Always start with creating a new LavaStore('my_store') class and give it a unique ID. The next step is to either setup a store document and collection structure using either the InsurePath() method, or chained Add() methods. Alternatively, use SetPath() if you already have data to store in a specific subdocument.

The image below is an example of an Firestore structure which is easily replicable locally using LavaStore.

Structure

Here, spotify is a document containing no data but a users collection, where user-related data might be stored between sessions.

Data model

The way we store data using LavaStore is heavily inspired by the Cloud Firestore data model.

Unlike a SQL database, there are no tables or rows. Instead, you store data in documents, which are organized into collections.

Each document contains a set of key-value pairs. Cloud Firestore is optimized for storing large collections of small documents.

All documents must be stored in collections. Documents can contain subcollections and nested objects, both of which can include primitive fields like strings or complex objects like lists.

Read more about structuring data and data modeling from the Firebase documentation.

Examples

The code below initializes a new LavaStore document root called app. When first running this code in the browser, we'll see a empty object being logged, but after a reload it contains the data { value: "Test" }.

// TypeScript
import { LavaStore } from "lavastore";

const AppDocument = new LavaStore("app");

console.log(AppDocument.Get());

AppDocument.Set({
    value: "Test"
});

The true power of

Specification

| Description | Value | | ------------ | ----- | | Package Size | 24 kB | | Semi-colons | ~80 |

Public API

LavaStore

This is a regular LSDocument with the only exception that it strictly must be root of a Document/Collection tree.

LSDocument

class LSDocument {
    id: string;
    parent: LSCollection | undefined;
    Collection(id: string): LSCollection | undefined;
    Contains(id: string): boolean;
    Add(collection: LSCollection): void;
    Remove(id: string): void;
    InsurePath(path: string | string[]): void;
    Load(): void;
    Save(): void;
    Set(data: object): void;
    Get(): object;
    HasData(): boolean;
    SetPath(path: string | string[], data: object): void;
    GetPath(path: string | string[]): object;
    CollectionPath(path: string | string[]): LSCollection;
    DocumentPath(path: string | string[]): LSDocument;
    PassTo(callback: ((data: object) => any)): void;
}

LSCollection

class LSCollection {
    id: string;
    parent: LSDocument | undefined;
    Contains(id: string): boolean;
    Document(id: string): LSDocument | undefined;
    Add(document: LSDocument): void;
    Remove(id: string): void;
}

Want to help?

All help is very much appreciated! You can fork the repo right now and start building your own modified version right away, and if you happen to create something interesting and useful, don't hesitate to file a pull request!

Sponsor this project

You can also help by supporting the project financially, all gifts are appreciated with great reverence and gratitude.

Developer: paypal.me/williamragstad