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

termic

v0.4.4

Published

Tools for CLI

Downloads

247

Readme

Downloads NPM Version NPM Downloads Install Size Npm Dependents

Highlights

  • Expressive API
  • Highly performant
  • No dependencies
  • Ability to nest styles
  • 256/Truecolor color support
  • Auto-detects color support
  • Doesn't extend String.prototype
  • Clean and focused
  • Actively maintained

Install

npm install termic

Usage

const { cli, colors, styler } = require("termic");

cli.println("Hello World");

cli.println(styler.color.red.background.green.italic.underline("Hello World"));

Termic comes with an easy to use composable API where you just chain and nest the styles you want.

const { cli, colors, styler } = require("termic");

const println = cli.println;

println("Hello World");

println(styler.background.blue.italic.underline("Hello World"));

Easily define your own themes:

const { cli, colors, styler } = require("termic");

const error = styler.color.red;
const warning = styler.color.orange;

cli.println(error("Error!"));
cli.println(warning("Warning!!!"));

Animations:

const fs = require("node:fs");
const termic = require("termic");

const styler = termic.styler;
const renderer = termic.renderer;
const animations = termic.animations;

const sourceFile = "example.txt";
const destFile = "example_copy.txt";

const progress_bar = renderer.progress(animations.animation1);
const progress_text = renderer.progress({ frames: ["Copying"] });
const progress_path_text = renderer.progress({ frames: [`${sourceFile} => ${destFile}`] });

const FAIL = styler.color.rgb([24, 24, 24]).background.red.bold(" FAIL ");
const DONE = styler.color.rgb([24, 24, 24]).background.green.bold(" DONE ");

fs.stat(sourceFile, function (err, stat) {
    const filesize = stat.size;
    let bytesCopied = 0;

    const readStream = fs.createReadStream(sourceFile)

    readStream.on('data', function (buffer) {
        bytesCopied += buffer.length;
        let porcentage = ((bytesCopied / filesize) * 100).toFixed(2);
        progress_bar.set(porcentage);
    });

    readStream.on('end', function () {
        progress_bar.end(DONE);
        progress_text.end(styler.color.rgb([86, 185, 127])("Copyed"));
        progress_path_text.end(styler.color.rgb([86, 185, 127])(`${sourceFile} => ${destFile}`));
    });

    readStream.on('error', function () {
        progress_bar.end(FAIL);
        progress_text.end(styler.color.red("Error"));
        progress_path_text.end(styler.color.red(`${sourceFile} => ${destFile}`));
    });

    readStream.pipe(fs.createWriteStream(destFile));
});

renderer.render([
    [styler.bold("Copying following files:")],
    [""],
    [" ", progress_bar, progress_path_text, progress_text, animations.simpleDots],
]);

Built-in console formatter for printing functions(like println and print):

const termic = require("termic");

const println = termic.cli.println;

const type_string = "Hello World!!";
const type_number = 12345;
const type_arrow_function = (bg) => { hello(); };
function type_function() { hello(); };
const type_object = {
    hello: type_arrow_function,
    hello2: {
        fw: "wfqf",
    }
}
const type_symbol = Symbol(type_string);
const type_null = null;
const type_undefined = void 0;
const type_bool = false;
const type_class = class Example {};


println(type_string);
console.log(type_string);

println(type_number);
console.log(type_number);

println(type_arrow_function);
console.log(type_arrow_function);

println(type_function);
console.log(type_function);

println(type_object);
console.log(type_object);

println(type_symbol);
console.log(type_symbol);

println(type_null);
console.log(type_null);

println(type_undefined);
console.log(type_undefined);

println(type_bool);
console.log(type_bool);

println(type_class);
console.log(type_class);

API

termic.styler.<style>[.<style>...](string)

Example: termic.styler.underline('Hello');

Example: termic.styler.italic('Hello');

termic.styler.color.<color>[.<style>...](string)

Example: termic.styler.color.red.underline('Hello');

termic.styler.background.<background>[.<style>...](string)

Example: termic.styler.background.red.underline('Hello');

termic.styler.color.<rgb | hex>[.<style>...](string)

Example: termic.styler.color.hex('#ffffff')('Hello');

Example: termic.styler.color.hex('#ffffff').bold('Hello');

Example: termic.styler.color.rgb([255, 255, 0])('Hello');

Example: termic.styler.color.rgb([255, 255, 0]).bold('Hello');

termic.styler.background.<rgb | hex>[.<style>...](string)

Example: termic.styler.background.hex('#ffffff')('Hello');

Example: termic.styler.background.hex('#ffffff').underline('Hello');

Example: termic.styler.background.rgb([255, 255, 0])('Hello');

Example: termic.styler.background.rgb([255, 255, 0]).underline('Hello');

Modifiers

  • reset - Reset the current style.
  • bold - Make the text bold.
  • dim - Make the text have lower opacity.
  • italic - Make the text italic. (Not widely supported)
  • underline - Put a horizontal line below the text. (Not widely supported)
  • doubleline - Put a double horizontal line below the text. (Not widely supported)
  • inverse- Invert background and foreground colors.
  • hidden - Print the text but make it invisible.
  • crossedout - Puts a horizontal line through the center of the text. (Not widely supported)
  • color - Set text color
  • background - Set background color

Colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • grey
  • orange

Browser support

There is currently no browser version, but we are working on it

Windows

If you're on Windows, do yourself a favor and use Windows Terminal instead of cmd.exe.

Maintainers