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 🙏

© 2026 – Pkg Stats / Ryan Hefner

prithvi-js-sdk

v1.0.5

Published

A Node.js client for the Prithvi database server.

Downloads

30

Readme

Prithvi-JS-SDK: JavaScript SDK for Prithvi

A simple, fast, and easy-to-use Node.js client for interacting with the Prithvi in-memory database server over raw TCP. This SDK handles connection management, command execution, and automatic reconnection with optional authentication support.


🚀 Installation

npm i prithvi-js-sdk

🛠️ Usage

const PrithviClient = require("prithvi-js-sdk");

const client = new PrithviClient("127.0.0.1", 1902);

async function main() {
  try {
    await client.connect();
    console.log("Connected to Prithvi.");

    // Optional: Authenticate
    await client.auth("your-username");
    await client.token(); // Reuses stored token

    await client.set("mykey", "myvalue");
    const value = await client.get("mykey");
    console.log("GET response:", value);
  } catch (error) {
    console.error("Error:", error.message);
  } finally {
    client.close();
  }
}

main();

📚 API Reference

🔌 Connection

  • new PrithviClient(host, port) Initializes the client. Defaults: host = '127.0.0.1', port = 1902.

  • connect() Establishes TCP connection to the Prithvi server.

  • close() Closes the client connection.


🔐 Authentication

  • auth(username) Initiates authentication. Returns and stores a TOKEN <hash> internally.

  • token(hash?) Sends the stored token (from auth) or manually passed token to authenticate session.

  • getStoredToken() Returns the currently stored token hash.


🔑 Key Commands

  • set(key, value, expiry?) Sets a key with optional expiry (in seconds).

  • get(key) Retrieves value for a key.

  • del(key) Deletes a key.

  • exists(key) Checks existence of a key.

  • keys() Returns list of all keys.


📚 Set Commands

  • sadd(key, value) Adds a value to a set.

  • smembers(key) Returns all members of a set.

  • srem(key, value) Removes a value from a set.


📃 List Commands

  • lpush(key, value) Prepends value to a list.

  • rpush(key, value) Appends value to a list.

  • lpop(key) Removes and returns first element.

  • rpop(key) Removes and returns last element.

  • getList(key) Returns all elements in the list.


🖥️ Server Commands

  • flush(confirm) Clears all data. Pass true to confirm.

  • save() Persists data to disk.

  • load() Loads data from disk.

  • quit() Gracefully closes the server-side session.

  • help() Returns a list of supported server commands.


⚠️ Error Handling & Resilience

  • Auto-reconnect is built-in.
  • If the connection drops, the client retries 5 times before giving up.
  • Token is preserved across reconnects if previously authenticated.
  • All methods return Promises — use async/await or .then()/.catch().

🧪 Example with Full Flow

await client.connect();

await client.auth("sid");
await client.token();

await client.set("count", "1");
console.log(await client.get("count")); // Output: "1"

console.log("Stored token:", client.getStoredToken());

client.close();

📬 Contributing

Contributions welcome! Open issues, suggest features, or submit PRs.


📄 License

This project is licensed under the MIT License.