terminal-string

1.1.1 • Public • Published

Convenient syntax for adding color effects to text for the terminal

license

Description

When using the terminal, you can highlight text by changing the font color, background color, or assigning special effects.

Example

The simple syntax makes it clear and convenient.

Installation

$ npm i terminal-string

Usage

const Tstring = require('terminal-string');

const line = new Tstring()
  .bg.red('2024/03/22').reset(' ')
  .normal('Example for ')
  .bg.green().bright(' Node.js ').reset()
  .normal(' project with ')
  .reverse(' terminal-string ').reset()
  .normal(' package.')
  .toString();
console.log(line);

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Specification

  • Text Effects
    • normal(): continue shows text without setting color effects;
    • reset(): clears all formatting. Sure that you call it at the end of using the terminal;
    • bright(): displays text with the bright effect;
    • dim(): displays text with the dim effect;
    • underscore(): display text with underscore;
    • blink(): displays text with the blink effect;
    • reverse(): changes background and foreground colors to opposite ones;
    • hidden(): displays text with the hidden effect;
  • Foreground (text) colors
    • fg.black()
    • fg.red()
    • fg.green()
    • fg.yellow()
    • fg.blue()
    • fg.magenta()
    • fg.cyan()
    • fg.white()
    • fg.crimson()
  • Background colors
    • bg.black()
    • bg.red()
    • bg.green()
    • bg.yellow()
    • bg.blue()
    • bg.magenta()
    • bg.cyan()
    • bg.white()
    • bg.crimson()

History

  • v1.0.0: Implemented the project.
  • v1.1.0: Unnecessary packages has been removed. Added project and author links. Improved the documentation.

License

MIT

/terminal-string/

    Package Sidebar

    Install

    npm i terminal-string

    Weekly Downloads

    6

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    22.3 kB

    Total Files

    11

    Last publish

    Collaborators

    • pi1igrim