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

@mip-client/ts

v1.0.2

Published

TypeScript client for the MIP (MSIP) protocol - handles connections, events, errors, and auto-reconnection

Downloads

327

Readme

MIP-Client-ts

npm version License: MIT

TypeScript client for the MIP (MSIP) protocol - handles connections, events, errors, and auto-reconnection.

Server implementation: MIP Server

Part of the MIP Client family:

Installation

npm install mip-client-ts

Usage

Basic Connection

import { MIPClient } from "mip-client-ts";

const client = new MIPClient({
  host: "127.0.0.1",
  port: 9000,
  clientId: "my_client_123",
});

// Events
client.on("connect", () => {
  console.log("Connected to server");
});

client.on("disconnect", () => {
  console.log("Disconnected");
});

client.on("error", (err) => {
  console.error("Error:", err.message);
});

client.on("message", (msg) => {
  console.log(`[${msg.topic}] ${msg.message}`);
});

// Connect
await client.connect();

Subscribe / Publish

// Subscribe to a topic
client.subscribe("my-topic");

// Listen for messages
client.on("message", (msg) => {
  console.log(`Topic: ${msg.topic}`);
  console.log(`Message: ${msg.message}`);
});

// Publish a message
client.publish("my-topic", "Hello World!");

Advanced Options

import { MIPClient, Flags } from "mip-client-ts";

const client = new MIPClient({
  host: "127.0.0.1",
  port: 9000,
  clientId: "my_client_123",  // Optional client identifier
  autoReconnect: true,        // Auto-reconnect (default: true)
  reconnectDelay: 3000,       // Delay between reconnections (default: 3000ms)
  maxReconnectAttempts: 10,   // Max attempts (0 = infinite)
  pingInterval: 5000,         // Automatic ping (0 = disabled)
});

// Publish with flags
client.publish("urgent-topic", "Important!", Flags.URGENT | Flags.ACK_REQUIRED);

// Listen for ACKs
client.on("ack", (msgId) => {
  console.log("ACK received for:", msgId.toString());
});

// Manual ping
client.ping();
client.on("pong", () => {
  console.log("Pong received!");
});

Auto-Reconnection

client.on("reconnecting", (attempt) => {
  console.log(`Reconnection attempt #${attempt}...`);
});

client.on("connect", () => {
  // Re-subscribe after reconnection
  client.subscribe("my-topic");
});

Factory Function

import { createClient } from "mip-client-ts";

const client = createClient("127.0.0.1", 9000, {
  autoReconnect: true,
  pingInterval: 10000,
});

API

MIPClient

Constructor Options

| Option | Type | Default | Description | | ---------------------- | --------- | ------- | -------------------------------------- | | clientId | string | "" | Client identifier (sent in HELLO frame)| | host | string | - | Server address | | port | number | - | Server port | | autoReconnect | boolean | true | Auto-reconnect on disconnect | | reconnectDelay | number | 3000 | Delay between reconnections (ms) | | maxReconnectAttempts | number | 10 |Max reconnection attempts (0 = infinite)| | pingInterval | number | 0 | Ping interval (0 = disabled) |

Methods

  • connect(): Promise<void> - Connect to server
  • disconnect(): void - Disconnect from server
  • subscribe(topic: string, requireAck?: boolean): bigint - Subscribe to a topic
  • unsubscribe(topic: string, requireAck?: boolean): bigint - Unsubscribe from a topic
  • publish(topic: string, message: string | Buffer, flags?: number): bigint - Publish a message
  • ping(): bigint - Send a ping

Events

  • connect - Connection established
  • disconnect - Disconnected
  • reconnecting(attempt) - Reconnection attempt
  • message(msg) - Message received (PUBLISH or EVENT)
  • event(msg) - Event received (EVENT only)
  • ack(msgId) - ACK received
  • pong - Pong received
  • error(error) - Error occurred
  • frame(header, payload) - Raw frame (advanced usage)

Constants

import { FrameType, Flags } from "mip-client-ts";

// Frame types
FrameType.HELLO       // 0x0001
FrameType.SUBSCRIBE   // 0x0002
FrameType.UNSUBSCRIBE // 0x0003
FrameType.PUBLISH     // 0x0004
FrameType.EVENT       // 0x0005
FrameType.ACK         // 0x0006
FrameType.ERROR       // 0x0007
FrameType.PING        // 0x0008
FrameType.PONG        // 0x0009
FrameType.CLOSE       // 0x000A

// Flags
Flags.NONE         // 0b00000000
Flags.ACK_REQUIRED // 0b00000001
Flags.COMPRESSED   // 0b00000010
Flags.URGENT       // 0b00000100

License

MIT License