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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tomato-sauce

v1.0.0

Published

"Telnet based drawing functions and renderers"

Downloads

4

Readme

tomato-sauce

Draw stuff via telnet

How to run

npm install and then run ``./bin/server.js`. It will listen on port 9999 by default.

Configuration variables

Tomato Sauce can be configured using env variables:

  • TOMATO_SAUCE_PORT: The port to listen on. Defauts to 9999.
  • TOMATO_SAUCE_FREQUENCY: How often it will send a screen in miliseconds. Defaults to 333.
  • TOMATO_SAUCE_MODULATION: How much the modulation counter will increase per round. Defaults to 5.
  • TOMATO_SAUCE_SCREEN_PATH: Path from which we will load screens. It defaults to {project_root}/lib/screens
  • TOMATO_SAUCE_RENDERER_PATH: Path from which we will load renderers. It defaults to {project_root}/lib/renderers

Make your own screens

A screen is a function that will receive a modulation value from 0-255, the width of the viewport, the height of the viewport, and a renderer function, and it returns a string that consists of the commands that will be sent to the socket.

  • TomatoSauce.IScreen(modulation <int>, width <int>, height <int>, renderer <TomatoSauce.IRenderer>) -> payload <string>

It should output the required commands that telnet needs to move the cursor and draw. For convenience, a renderer function is passed so calculating color should not be a part of the screen, just moving the cursor around and calling specific colors.

Make your own renderers

The included renderers are wrappers to some common ways of obtaining colors in the terminal: ANSI, 256 colors, 24-bit colors, and a fake color string that uses incorrect color strings to generate random variations.

You can build your own renderer by building a function that receives a red, green, and blue component from 0 to 255 and returns the escape codes to generate the color.

  • TomatoSauce.IRenderer(red <int>, green <int>, blue <int>) -> colorString <string>

Using as a library

The binary just serves as a wrapper to read configuration, and as a bridge to the console. It consumes lib/tomato_sauce. All configuration is optional, and should be passed as an object on instantiation. The instance is an event emitter that will emit a listening event with the server data, and an error event in case something goes wrong.

const TomatoSauce = require('tomato-sauce');

const tomatoSauce = new TomatoSauce(config);

tomatoSauce.on('listening', function () {
  const address = event.data.server.address();
  console.log(`Tomato Sauce listening on: ${address.address}:${address.port}`);
});

tomatoSauce.on('error', function (error) {
  console.error(error);
});

tomatoSauce.run();

Configuration Values

The config object should be a simple object with these keys (All are optional.)

  • port: The port to listen on (Defaults to 9999)
  • frequency: How often we'll send a new frame in milliseconds (Defaults to 333)
  • modulation: How fast the modulation counter will be increased (Defaults to 5)
  • screens: An array containing the screen functions (Defaults to [])
  • renderers: An array containing the renderer functions (Defaults to [])