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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jijel

v1.0.3

Published

A lightweight TypeScript database library

Readme

Jijel

A lightweight TypeScript database library with multiple storage options and type-safe queries.

Features

  • Multiple Storage Options: In-memory, file system (with B-tree indexing), and browser storage
  • Type Safety: Built with TypeScript and Zod for schema validation
  • Fluent Query API: Build queries with a clean, chainable interface
  • Extensible: Designed to be easily extended with plugins

Installation

npm install jijel zod

Quick Start

import { Database, Schema } from "jijel";
import { z } from "zod";

// Define a schema
const userSchema = new Schema({
  name: z.string(),
  email: z.string().email(),
  age: z.number().min(0).optional(),
});

async function main() {
  // Initialize the database
  const db = new Database({
    name: "my-app",
    storage: "memory", // Options: 'memory', 'file', 'browser'
  });

  await db.connect();

  // Create a table
  const userTable = db.table("users", userSchema);

  // Insert a record
  const user = await db.query(userTable).create({
    name: "John Doe",
    email: "[email protected]",
    age: 30,
  });

  console.log("Created user:", user);

  // Query records
  const adults = await db.query(userTable).where("age", "gte", 18).find();

  console.log("Adult users:", adults);

  // Update a record
  await db.query(userTable).updateOne(user.id, { age: 31 });

  // Close the connection
  await db.close();
}

main().catch(console.error);

Storage Options

In-Memory Storage

Best for testing or small applications:

const db = new Database({
  name: "my-app",
  storage: "memory",
});

File Storage

Persists data to the file system using a B-tree for efficient indexing:

const db = new Database({
  name: "my-app",
  storage: "file",
  path: "./data",
});

Browser Storage

Uses localStorage or sessionStorage in browser environments:

const db = new Database({
  name: "my-app",
  storage: "browser",
});

API Reference

Database

  • new Database(options): Create a new database instance
  • connect(): Initialize the database connection
  • table(name, schema): Define a table with the given schema
  • query(table): Create a query builder for the table
  • close(): Close the database connection

Query Builder

  • where(field, operator, value): Add a filter condition
  • limit(count): Limit the number of results
  • skip(count): Skip the first N results
  • sort(field, order): Sort the results
  • find(): Execute the query and return all matching records
  • findOne(): Execute the query and return the first matching record
  • count(): Count matching records
  • create(data): Insert a new record
  • update(data): Update all matching records
  • updateOne(id, data): Update a specific record
  • delete(): Delete all matching records
  • deleteOne(id): Delete a specific record

Supported Operators

  • eq: Equal
  • neq: Not equal
  • gt: Greater than
  • gte: Greater than or equal
  • lt: Less than
  • lte: Less than or equal
  • in: In array
  • nin: Not in array
  • contains: String contains

Extending Jijel

Jijel is designed to be extensible. Here's an example of creating a plugin:

// Custom plugin for encryption
import { StorageAdapter } from "jijel";

class EncryptionPlugin {
  constructor(secretKey) {
    this.secretKey = secretKey;
  }

  wrapStorage(storage: StorageAdapter): StorageAdapter {
    // Return a wrapped storage adapter with encryption
    return {
      // Implement the StorageAdapter interface with encryption
      // ...
    };
  }
}

// Using the plugin
const storage = new MemoryStorageAdapter();
const plugin = new EncryptionPlugin("secret-key");
const encryptedStorage = plugin.wrapStorage(storage);

const db = new Database({
  name: "secure-db",
  storage: "memory",
  _storage: encryptedStorage, // Use the wrapped storage
});

License

MIT