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

terminal-next

v1.2.2

Published

--- Next gen terminal helper, slim, extensible, easy to use. Fully promise based, callbacks are not a thing anymore. Some widgets do not support non-tty terminals.

Downloads

1

Readme

Terminal Next


Next gen terminal helper, slim, extensible, easy to use. Fully promise based, callbacks are not a thing anymore. Some widgets do not support non-tty terminals.

Zero dependencies.

npm node-current

Requirements

Node v14+, cannot run in browser


Docs

Read documentation here


Installation

For yarn:

yarn add terminal-next

For npm:

npm i terminal-next

Basic usage:

Examples can be found here

either compile them or use ts-node to execute immediately

import { Terminal }    from 'terminal-next';

// optionally pass stdin and/or stdout, if not provided
// process.stdin and process.stdout will be used
const t = new Terminal();

t.red('Red text').newline();

// fully customizable text output
t.text('Some text', {fg: 'cyan', bg: 'red', dim: true});

TextInput

Typical text input prompt

import { Terminal, TextInput }    from 'terminal-next';
const t = new Terminal();

// you can use promises instead of await
(async () => {
	const ti = new TextInput(t, 'Your name?');
	const answ = await ti.start();
	t.text(answ);
})();

Confirm

Simple yes/no confirmation

import { Terminal, Confirm }    from 'terminal-next';
const t = new Terminal();

(async () => {
	const ti = new Confirm(t, 'Super?');
	const answ = await ti.start();
	t.text(answ.toString()).newline();
})();

Select

Single option select widget

import { Terminal, Select }    from 'terminal-next';
const t = new Terminal();

(async () => {
	const options = [
		{title: 'Option 1', value: '111'},
		{title: 'Option 2', value: '222'},
		{title: 'Some other option', value: '333'},
	];
	const select = new Select(t, options);
	const result = await select.start();
	t.text('answer: ' + result);
})();

Spinner

Spinner with a text

import { Terminal, Spinner }    from 'terminal-next';

const t = new Terminal(process.stdout, process.stdin);

(async () => {
	const spinner = new Spinner(t, 'test');
	// you define tick rate yourself or just tick whenever a progress is made
	const itv = setInterval(async () => {
		await spinner.draw();
	}, 100);

	setTimeout(()=> {
		clearInterval(itv);
	}, 3000);
})();

ProgressBar

import { Terminal, ProgressBar }    from 'terminal-next';

const t = new Terminal();

(async () => {
	const pb = new ProgressBar(t, 100);
	await pb.draw();

	let prog = 0;
	const itv = setInterval(async () => {
		await pb.setProgress(prog);
		prog++;
		if (prog > 100) {
			clearInterval(itv);
			// important, in order to stop terminal from flickering, 
			// show cursor after this is done
			t.showCursor();
		}
	}, 50);
})();

Table

import { Terminal, Table }    from 'terminal-next';

const t = new Terminal();

(async () => {
	t.clear();

	const data = [
		['id', 'name', 'email', 'active', 'banned'],
		['1', 'Marian', '[email protected]', 'true', 'false'],
		['2', 'Adam', '[email protected]', 'true', 'true'],
		['3', 'Gertruda', '[email protected]', 'false', 'false']
	];
	const table = new Table(t);
	table.setData(data);
	table.draw();
})();

More widgets?

You can either construct them yourself or make PR if you think there is a widget that is really important to have. Either way, create issue in this project.