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

two-pack

v1.0.1

Published

Original: TwoPack (Java) Library rewritten using TypeScript/JavaScript.

Readme

TLS Packet Server & Client Library for Javascript & Typescript projects

Setup TLS fast, secure and easy with TwoPack. This library is for communication between clients and servers using TLS encryption.

2Pack is currently tied to NestJS/common for its logger, but will soon have a version of its own.

Packet

What is a packet? 2Pack is a packet library that allows you to send and receive packets over a network. A packet is a message that is sent over a network. It contains data and metadata that is used to identify the sender and receiver of the packet. 2Pack uses TLS encryption to secure the communication between clients and servers.

Setup

npm install two-pack

Usage

import { Packet } from 'two-pack';

export class SPacketPing extends Packet {
    timestamp: number = 0;
    
    read(reader: PacketReader) {
        this.timestamp = reader.readDouble();
    }
    
    write(writer: PacketWriter) {
        writer.writeDouble(this.timestamp);
    }
    
    handle(client: PacketClient) {
        client.send(new SPacketPong(this.timestamp));
    }

}

export class SPacketPong extends Packet {
    timstamp: number = 0;
    
    read(reader: PacketReader) {
        this.timestamp = reader.readDouble();
    }
    
    write(writer: PacketWriter) {
        writer.writeDouble(this.timestamp);
    }
    
    handle(client: PacketClient) {
        const now = Date.now();
        const diff = now - this.timestamp;
        this.log(`Response time: ${diff}ms (~${diff / 2}ms to client)`);   
    }
}

Packet Codec

Packet Reader

The PacketReader is responsible for reading the packet data from the buffer.

Packet Writer

The PacketWriter is responsible for writing the packet data to the buffer.

Packet Buffer

A Buffer is a wrapper around a Uint8Array that provides a more convenient interface for reading and writing data. The PacketBuffer class is responsible for reading and writing data from the buffer.

Packet Client

The PacketClient class is responsible for sending and receiving packets over the network. This class would be used on the client side.

Setup

npm install @two-pack/packet-client
import { PacketClient, PacketRegistry, TLSClientOptions } from 'two-pack';
import { SPacketPing } from './SPacketPing';

export class Client extends PacketClient {
    constructor(options: TLSClientOptions) {
        const registry = new PacketRegistry();
        registry.register(SPacketPing);
        super(options, registry)
    }
}

Packet Server

The PacketServer class is responsible for handling incoming packets and sending responses. This class would be used on the server side.

Setup

npm install @two-pack/packet-server
import { PacketServer, TLSServerOptions } from '@two-pack/packet-server';
import { SPacketPing } from './SPacketPing';
import { SPacketPong } from './SPacketPong';
import { PacketRegistry, PacketLogger, PacketBuffer } from '@two-pack/packet';

export class Server extends PacketServer {
    constructor(options: TLSClientOptions) {
        const registry = new PacketRegistry();
        registry.register(SPacketPing);
        registry.register(SPacketPong);
        super(options, registry)
    }
}

Packet Registry

The PacketRegistry class is responsible for registering and managing packet classes. It is used to map packet IDs to packet classes.