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

jolt-js-api

v1.1.9

Published

JavaScript & Node.js client for the Jolt in-memory messaging broker

Readme

Jolt JavaScript API

npm version npm downloads

This repository is a JavaScript and Node.js client. This package provides direct access to the Jolt protocol, offering a lightweight, dependency-free interface for building real-time distributed applications, internal services, and event-driven systems.

Overview

The Jolt JavaScript API communicates with our Jolt broker using its native TCP protocol and newline-delimited JSON messaging format. The client exposes a Node.js EventEmitter interface and supports both callback-based and Promise-based usage.

This module intentionally relies only on Node.js core libraries to ensure low overhead, portability, and minimal setup requirements. TypeScript definitions are included for typed development environments.

Installation

npm install jolt-js-api

Installation from source:

git clone https://github.com/Jolt-Database/jolt-js-api.git
cd jolt-js-api
npm install

Usage Example

const JoltClient = require('jolt-js-api');

const client = new JoltClient({
  host: '127.0.0.1',
  port: 8080
});

client.on('connected', () => console.log('Connected to broker'));
client.on('message', (topic, data) => console.log(`[${topic}] ${data}`));
client.on('error', (error) => console.error('Error:', error));

async function main() {
  await client.connect();

  client.subscribe('chat.general');
  client.publish('chat.general', 'Hello, Jolt!');
  client.ping();

  await new Promise(resolve => setTimeout(resolve, 2000));
  client.close();
}

main();

API Summary

Constructor

const client = new JoltClient(config);

Configuration options:

  • host: Broker hostname (default: 127.0.0.1)
  • port: Broker port (default: 8080)

Connection Methods

  • connect() – Establishes a connection to the broker.
  • close() – Closes the client connection.
  • isConnected() – Returns connection state.

Messaging Methods

  • auth(username, password) – Performs broker authentication.
  • subscribe(topic) – Subscribes to a topic.
  • unsubscribe(topic) – Removes an existing subscription.
  • publish(topic, data) – Publishes a message to a topic.
  • ping() – Issues a protocol-level health check.

Event Interface

  • connected
  • ok
  • error
  • message
  • disconnected
  • socketError
  • parseError
  • unknown

These events provide full visibility into the broker communication, parsing results, socket behavior, and message routing.

Additional Examples

Simple Pub/Sub

await client.connect();
client.subscribe('chat.room1');
client.publish('chat.room1', 'Hello');

Multiple Topics

['news', 'sports', 'weather']
  .forEach(t => client.subscribe(t));

client.publish('news', 'Latest headline');

Promise-Based Wrapper Usage

await client.connect();
await client.subscribeAsync('chat.general');
await client.publishAsync('chat.general', 'Hello');

Error Handling Pattern

client.on('error', (err) => {
  console.error(err);
});

Testing

npm test
npm run test:watch
npm run example
npm run example:advanced

A running Jolt broker instance is required for full test execution.

Protocol Notes

Communication uses newline-delimited JSON over TCP.

Example request frames:

{"op": "auth", "user": "username", "pass": "password"}
{"op": "pub", "topic": "channel", "data": "message"}
{"op": "sub", "topic": "channel"}

Example response frames:

{"ok": true}
{"topic": "channel", "data": "message"}