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

console-control-strings

v1.1.0

Published

A library of cross-platform tested terminal/console command strings for doing things like color and cursor positioning. This is a subset of both ansi and vt100. All control codes included work on both Windows & Unix-like OSes, except where noted.

Downloads

60,005,496

Readme

Console Control Strings

A library of cross-platform tested terminal/console command strings for doing things like color and cursor positioning. This is a subset of both ansi and vt100. All control codes included work on both Windows & Unix-like OSes, except where noted.

Usage

var consoleControl = require('console-control-strings')

console.log(consoleControl.color('blue','bgRed', 'bold') + 'hi there' + consoleControl.color('reset'))
process.stdout.write(consoleControl.goto(75, 10))

Why Another?

There are tons of libraries similar to this one. I wanted one that was:

  1. Very clear about compatibility goals.
  2. Could emit, for instance, a start color code without an end one.
  3. Returned strings w/o writing to streams.
  4. Was not weighed down with other unrelated baggage.

Functions

var code = consoleControl.up(num = 1)

Returns the escape sequence to move num lines up.

var code = consoleControl.down(num = 1)

Returns the escape sequence to move num lines down.

var code = consoleControl.forward(num = 1)

Returns the escape sequence to move num lines righ.

var code = consoleControl.back(num = 1)

Returns the escape sequence to move num lines left.

var code = consoleControl.nextLine(num = 1)

Returns the escape sequence to move num lines down and to the beginning of the line.

var code = consoleControl.previousLine(num = 1)

Returns the escape sequence to move num lines up and to the beginning of the line.

var code = consoleControl.eraseData()

Returns the escape sequence to erase everything from the current cursor position to the bottom right of the screen. This is line based, so it erases the remainder of the current line and all following lines.

var code = consoleControl.eraseLine()

Returns the escape sequence to erase to the end of the current line.

var code = consoleControl.goto(x, y)

Returns the escape sequence to move the cursor to the designated position. Note that the origin is 1, 1 not 0, 0.

var code = consoleControl.gotoSOL()

Returns the escape sequence to move the cursor to the beginning of the current line. (That is, it returns a carriage return, \r.)

var code = consoleControl.beep()

Returns the escape sequence to cause the termianl to beep. (That is, it returns unicode character \x0007, a Control-G.)

var code = consoleControl.hideCursor()

Returns the escape sequence to hide the cursor.

var code = consoleControl.showCursor()

Returns the escape sequence to show the cursor.

var code = consoleControl.color(colors = [])

var code = consoleControl.color(color1, color2, , colorn)

Returns the escape sequence to set the current terminal display attributes (mostly colors). Arguments can either be a list of attributes or an array of attributes. The difference between passing in an array or list of colors and calling .color separately for each one, is that in the former case a single escape sequence will be produced where as in the latter each change will have its own distinct escape sequence. Each attribute can be one of:

  • Reset:
    • reset – Reset all attributes to the terminal default.
  • Styles:
    • bold – Display text as bold. In some terminals this means using a bold font, in others this means changing the color. In some it means both.
    • italic – Display text as italic. This is not available in most Windows terminals.
    • underline – Underline text. This is not available in most Windows Terminals.
    • inverse – Invert the foreground and background colors.
    • stopBold – Do not display text as bold.
    • stopItalic – Do not display text as italic.
    • stopUnderline – Do not underline text.
    • stopInverse – Do not invert foreground and background.
  • Colors:
    • white
    • black
    • blue
    • cyan
    • green
    • magenta
    • red
    • yellow
    • grey / brightBlack
    • brightRed
    • brightGreen
    • brightYellow
    • brightBlue
    • brightMagenta
    • brightCyan
    • brightWhite
  • Background Colors:
    • bgWhite
    • bgBlack
    • bgBlue
    • bgCyan
    • bgGreen
    • bgMagenta
    • bgRed
    • bgYellow
    • bgGrey / bgBrightBlack
    • bgBrightRed
    • bgBrightGreen
    • bgBrightYellow
    • bgBrightBlue
    • bgBrightMagenta
    • bgBrightCyan
    • bgBrightWhite