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

@fav/cli.text-style

v0.2.0

Published

Decorate terminal text with ANSI escape code

Downloads

6

Readme

@fav/cli.text-style NPM MIT License Build Status Build Status Coverage status

Decorate terminal text with ANSI escape code.

"fav" is an abbreviation of "favorite" and also the acronym of "for all versions". This package is intended to support all Node.js versions as possible. At least, this package supports Node.js >= v0.10.

Install

To install from npm:

$ npm install --save @fav/cli.text-style

NOTE: npm < 2.7.0 does not support scoped package, but old version Node.js supports it. So when you use such older npm, you should download this package from github.com, and move it in node_modules/@fav/cli.text-style/ directory manually.

Usage

var textStyle = require('@fav/cli.text-style');

textStyle.underline('Hello!'); // => '\u001b[4mHello!\u001b[24m'
textStyle.red('Hello!'); // => '\u001b[31mHello!\u001b[39m'
textStyle.color(222)('Hello!'); // => '\u001b[38;222mHello!\u001b[39m' (256 colors)
textStyle.rgb(255,128,96)('Hello!'); // => '\u001b[38;2;255;128;96mHello!\u001b[39m' (16m colors)

API

textStyle.style(text) => string

Decorates text with the ANSI escape code corresponding to style. This automatically detects the color depth of the terminal and disables decorations which requires more color depth.

textStyle(colorDepth).style(text) => string

Decorates text with the ANSI escape code corresponding to style. This disables decorations which requires more color depth than the specified colorDepth.

textStyle(env).style(text) => string

Decorates text with the ANSI escape code corresponding to style. This determines the color depth with require('@fav/cli.get-color-depth')(env), and disables decorations which requires more color depth than the gotten colorDepth.

NOTE: On Windows, the combination of .bold and .faint/.dim makes disable to be off bold. Since .faint/.dim looks ineffective, this package adds no decoration for .faint/.dim on Windows.

Parameters:

| Parameter | Type | Description | |:-----------|:------:|:-------------------------------| | text | string | A text to be decorated. | | colorDepth | number | A color depth to be specified. | | env | object | An environment object to be used instead of process.env. |

Returns:

| Type | Description | |:------:|:--------------------| | string | A decorated string. |

Styles:

Modifiers

| Name | Effect | ANSI ESC code | |:------------------|:-------------------------------------------------|:--------------| | reset | Reset all styles | 0 | | bold | Increse intensity | 1 | | faint | Decrease intensity | 2 | | dim | Alias of faint (follow chalk) | 2 | | italic | Italic style | 3 | | underline | Draw underline | 4 | | slowBlink | Slow blink | 5 | | blink | Alias of slowBlink (follow chalk) | 5 | | reverse | Reverse foreground color and background color | 7 | | inverse | Alias of reverse (follow chalk) | 7 | | conceal | Hide text | 8 | | hidden | Alias of conceal (follow chalk) | 8 | | crossedOut | Draw strikethrough | 9 | | strikethrough | Alias of crossedOut (follow chalk)| 9 | | doublyUnderline | Draw doubly underline | 21 |

Foreground colors

| Name | Effect | ANSI ESC code | |:---------------|:----------------------------------------------------|:--------------| | black | Make foreground black | 30 | | red | Make foreground red | 31 | | green | Make foreground green | 32 | | yellow | Make foreground yellow | 33 | | blue | Make foreground blue | 34 | | magenta | Make foreground magenta | 35 | | cyan | Make foreground cyan | 36 | | white | Make foreground white | 37 | | brightBlack | Make foreground bright black | 90 | | blackBright | Alias of brightBlack (follow chalk) | 90 | | gray | Alias of brightBlack (follow chalk) | 90 | | grey | Alias of brightBlack (follow chalk) | 90 | | brightRed | Make foreground bright red | 91 | | redBright | Alias of brightRed (follow chalk) | 91 | | brightGreen | Make foreground bright green | 92 | | greenBright | Alias of brightGreen (follow chalk) | 92 | | brightYellow | Make foreground bright yellow | 93 | | yellowBright | Alias of brightYellow (follow chalk) | 93 | | brightBlue | Make foreground bright blue | 94 | | blueBright | Alias of brightBlue (follow chalk) | 94 | | brightMagenta| Make foreground bright magenta | 95 | | magentaBright| Alias of brightBlue (follow chalk) | 95 | | brightCyan | Make foreground bright cyan | 96 | | cyanBright | Alias of brightCyan (follow chalk) | 96 | | brightWhite | Make foreground bright white | 97 | | whiteBright | Alias of brightWhite (follow chalk) | 97 | | color(n) | Make foreground one of 256 colors (n = color code) | 38;n | | rgb(r,g,b) | Make foregournd one of 16m colors (r,g,b = intensity of red, green, and blue) | 38;2;r;g;b |

Background colors

| Name | Effect | ANSI ESC code | |:-----------------|:--------------------------------------------------|:--------------| | bgBlack | Make background black | 40 | | bgRed | Make background red | 41 | | bgGreen | Make background green | 42 | | bgYellow | Make background yellow | 43 | | bgBlue | Make background blue | 44 | | bgMagenta | Make background magenta | 45 | | bgCyan | Make background cyan | 46 | | bgWhite | Make background white | 47 | | bgBrightBlack | Make background bright black | 100 | | bgBlackBright | Alias of bgBrightBlack (follow chalk)| 100 | | bgGray | Alias of bgBrightBlack (follow chalk)| 100 | | bgGrey | Alias of bgBrightBlack (follow chalk)| 100 | | bgBrightRed | Make background bright red | 101 | | bgRedBright | Alias of bgBrightRed (follow chalk)| 101 | | bgBrightGreen | Make background bright green | 102 | | bgGreenBright | Alias of bgBrightGreen (follow chalk)| 102 | | bgBrightYellow | Make background bright yellow | 103 | | bgYellowBright | Alias of bgBrightYellow (follow chalk)| 103 | | bgBrightBlue | Make background bright blue | 104 | | bgBlueBright | Alias of bgBrightBlue (follow chalk) | 104 | | bgBrightMagenta| Make background bright magenta | 105 | | bgMagentaBright| Alias of bgBrightBlue (follow chalk) | 105 | | bgBrightCyan | Make background bright cyan | 106 | | bgCyanBright | Alias of bgBrightCyan (follow chalk) | 106 | | bgBrightWhite | Make background bright white | 107 | | bgWhiteBright | Alias of bgBrightWhite (follow chalk)| 107 | | bgColor(n) | Make background one of 256 colors (n = color code)| 48;n | | bgRgb(r,g,b) | Make background one of 16m colors (r,g,b = intensity of red, green, and blue) | 48;2;r;g;b |

References

Checked

Node.js (11〜12)

| Platform | 11 | 12 | |:---------:|:------:|:------:| | macOS |◯|◯| | Windows10 |◯|◯| | Linux |◯|◯|

Node.js (4〜10)

| Platform | 4 | 5 | 6 | 7 | 8 | 9 | 11 | |:---------:|:------:|:------:|:------:|:------:|:------:|:------:|:------:| | macOS |◯|◯|◯|◯|◯|◯|◯| | Windows10 |◯|◯|◯|◯|◯|◯|◯| | Linux |◯|◯|◯|◯|◯|◯|◯|

io.js (1〜3)

| Platform | 1 | 2 | 3 | |:---------:|:------:|:------:|:------:| | macOS |◯|◯|◯| | Windows10 |◯|◯|◯| | Linux |◯|◯|◯|

Node.js (〜0.12)

| Platform | 0.8 | 0.9 | 0.10 | 0.11 | 0.12 | |:---------:|:------:|:------:|:------:|:------:|:------:| | macOS |◯|◯|◯|◯|◯| | Windows10 |◯|◯|◯|◯|◯| | Linux |◯|◯|◯|◯|◯|

License

Copyright (C) 2019 Takayuki Sato

This program is free software under MIT License. See the file LICENSE in this distribution for more details.