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

jamkv

v0.0.1

Published

libsql-based key-value store for Deno, Node.js and the browser

Downloads

89

Readme

jamkv

A lightweight, LibSQL-based Key-Value store for Node.js and Deno.

[!NOTE] Currently, @libsql/client-wasm is not supported, so browser usage is out of scope for now.

Installation

pnpm add jamkv

Usage

Initialization

import { createKV } from "jamkv";

const kv = await createKV({
  url: "libsql://your-database.turso.io",
  authToken: "your-auth-token",
});

Basic Operations

// Set a value
await kv.set("user:1", { name: "Alice", age: 30 });

// Get a value
const user = await kv.get("user:1");
console.log(user?.value);

// Delete a value
await kv.del("user:1");

Expiration

// Set a value that expires in 5 seconds
await kv.set("temp-key", "temp-value", { expireIn: 5000 });

Listing

// List all keys
const all = await kv.list();

// List with prefix
const users = await kv.list({ prefix: "user:" });

// Filter by JSON field (Simple)
const adults = await kv.list({
  where: {
    field: "age",
    operator: ">",
    value: 18,
  },
});

// Filter by JSON field (Complex)
const complex = await kv.list({
  where: ({ and, or, not }) =>
    and(
      { field: "role", operator: "=", value: "admin" },
      or(
        { field: "age", operator: ">", value: 25 },
        { field: "experience", operator: ">", value: 5 },
      ),
    ),
});

[!NOTE] The where option supports filtering JSON fields. You can use the callback syntax for complex logic (AND, OR, NOT).

Expiration & Cleanup

Keys with an expiration time are lazily deleted when accessed (via get or getMany) or when listing. However, to explicitly remove all expired keys from the database (e.g., via a cron job), you can use:

await kv.cleanupExpired();

Transactions

const tx = await kv.transaction();

try {
  await tx.set("key1", "value1");
  await tx.set("key2", "value2");

  // Read your writes within the transaction
  const val = await tx.get("key1");

  await tx.commit();
} catch (error_) {
  await tx.rollback();
  console.error("Transaction failed:", error_);
}

API

createKV(config: Config): Promise<LibSQLKV>

Creates and initializes the KV store. Config is the standard @libsql/client configuration object.

LibSQLKV

set<T>(key: string, value: KVValue, options?: SetOptions): Promise<void>

Sets a value for a key.

  • value: Can be string, number, boolean, JSON object/array, or Uint8Array.
  • options.expireIn: Time in milliseconds until the key expires.

get<T>(key: string): Promise<KVEntry<T> | null>

Retrieves a value by key. Returns null if not found or expired.

del<T>(key: string): Promise<void>

Deletes a key.

list<T>(options?: ListOptions): Promise<KVEntry<T>[]>

Lists keys matching the criteria.

  • options.prefix: Filter keys starting with this prefix.
  • options.limit: Max number of results.
  • options.cursor: (Not yet implemented)
  • options.where: Filter by JSON field value.
  • options.reverse: Reverse sort order.

transaction(mode?: "write" | "read" | "deferred"): Promise<KVTransaction>

Starts a new transaction. Returns a KVTransaction instance which has the same methods as LibSQLKV plus commit(), rollback(), and close().