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

@herrevilkitten/telnet

v1.0.3

Published

A small, modern library for creating Telnet clients and servers using asynchronous generators, providing a clean and intuitive way to handle Telnet connections.

Readme

@herrevilkitten/telnet

A small, modern library for creating Telnet clients and servers using asynchronous generators, providing a clean and intuitive way to handle Telnet connections.

npm version

Features

  • Asynchronous by Design: Built with async generators for handling events, eliminating the need for complex callback structures.
  • Simple and Intuitive API: The library is designed to be easy to use, with a straightforward API for both clients and servers.
  • Lightweight with Minimal Dependencies: @herrevilkitten/telnet is a small library with only one external dependency, making it easy to integrate into any project.
  • TLS Support: In addition to raw TCP connections, the library also supports TLS-encrypted connections for both clients and servers.
  • TypeScript Support: Written in TypeScript, providing strong typing and improved developer experience.

Installation

You can install the package using your favorite package manager.

pnpm:

pnpm add @herrevilkitten/telnet

npm:

npm install @herrevilkitten/telnet

yarn:

yarn add @herrevilkitten/telnet

Usage

ESM (import)

import { TelnetConnection, TelnetServer } from '@herrevilkitten/telnet';

CommonJS (require)

const { Telnet } = require('@herrevilkitten/telnet');

Telnet Server

Here's a simple example of a Telnet server that sends the current date and time to any client that connects:

import { TelnetConnection, TelnetServer } from '@herrevilkitten/telnet';

async function daytime(conn: TelnetConnection) {
  const remote = conn.name;
  console.log(`${remote}: connected`);
  conn.sendln(new Date().toString());
  conn.disconnect();
  console.log(`${remote}: disconnected`);
}

(async () => {
  const server = new TelnetServer({ port: 9999, host: '127.0.0.1' });

  console.log('Starting daytime server on port 9999');
  for await (const event of server.listen()) {
    if (event.type === 'connect') {
      daytime(event.connection);
    }
  }
})();

Telnet Client

Here's a client that connects to a daytime server and prints the received data:

import { TelnetClient } from '@herrevilkitten/telnet';

(async () => {
  const client = new TelnetClient({ host: 'localhost', port: 9999 });

  console.log('Connecting to daytime server');
  const connection = client.connect();
  for await (const event of connection.receive()) {
    if (event.type === 'data') {
      console.log(event.data);
    } else if (event.type === 'error') {
      console.error(event.error);
      break;
    }
  }
})();

TLS Support

The library also supports TLS-encrypted connections for both clients and servers.

TLS Server

import { TLSTelnetServer, TelnetConnection } from '@herrevilkitten/telnet';
import { readFileSync } from 'fs';

const options = {
  key: readFileSync('server-key.pem'),
  cert: readFileSync('server-cert.pem'),
  port: 9998,
  host: '127.0.0.1',
};

async function secureDaytime(conn: TelnetConnection) {
  const remote = conn.name;
  console.log(`${remote}: connected securely`);
  conn.sendln(new Date().toString());
  conn.disconnect();
  console.log(`${remote}: disconnected`);
}

(async () => {
  const server = new TLSTelnetServer(options);

  console.log('Starting secure daytime server on port 9998');
  for await (const event of server.listen()) {
    if (event.type === 'connect') {
      secureDaytime(event.connection);
    }
  }
})();

TLS Client

import { TLSTelnetClient } from '@herrevilkitten/telnet';

(async () => {
  const client = new TLSTelnetClient({
    host: 'localhost',
    port: 9998,
    rejectUnauthorized: false, // For self-signed certificates
  });

  console.log('Connecting to secure daytime server');
  const connection = client.connect();
  for await (const event of connection.receive()) {
    if (event.type === 'data') {
      console.log(event.data);
    } else if (event.type === 'error') {
      console.error(event.error);
      break;
    }
  }
})();

Description

@herrevilkitten/telnet is a lightweight and modern library for building Telnet-like clients and servers. It leverages ECMAScript generator functions and asynchronous iterators to provide a clean and intuitive way to handle Telnet events, avoiding the complexity of traditional callback-based approaches.

Examples

Check the examples directory for more detailed examples of different Telnet clients and servers.

See Also

  • telnet-rxjs - A similar library that uses RxJS for handling Telnet events.

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for more details.