1.1.8 • Published 1 year ago

strcolorize v1.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

🖍️ strcolorize

strcolorize is a simple and practical library for terminal output colorization that utilizes ANSI and hexadecimal codes for its operation. The way strcolorize operates is different, using inline formatting for its functionality.

Inline Formatting

Allows adding colors directly to text using codes (Hexadecimal and ANSI) around desired portions. This provides a simple way to highlight important information without compromising the text's structure. With strcolorize, this approach enables precise customization of text colors and styles.

📦 Installation

You can install this library using npm or yarn

npm install strcolorize@latest
yarn install strcolorize@latest

📌 How to usage

To utilize this library, first install it in your project and then import it into your file like this:

// Importing using es6
import colorize from 'strcolorize';

// Importing using commonjs
const colorize = require('strcolorize');

// Note: in place of 'colorize' you can set any name you want

After that, you can use it to colorize your strings like this:

// putting a text in bold and yellow
colorize('#bold yellow[The sun sets. Stars twinkle. Dreams awaken.
]');

// you can print to the console using the function itself
colorize('#bold yellow[The sun sets. Stars twinkle. Dreams awaken.
]', true);

// There's the possibility of nesting styles
colorize('#bold[The sun sets. #yellow[Stars twinkle]. Dreams awaken.
]');

// How to use hexadecimal codes to colorize your strings
colorize('#bold[The sun sets. #ff0[Stars twinkle]. Dreams awaken.
]');

📝 Method

colorize(text: string, terminal: boolean = false): string | void

  • text: The text to be colorized.
  • terminal: A boolean flag indicating whether to print the colorized text directly to the terminal.
  • return: is true, prints the colorized text to the terminal and returns void. Otherwise, returns the colorized text as a string.

💖 Contribuition

Your contributions are highly valued! Feel free to enhance this project by opening an issue to report any problems or submitting a pull request with your proposed changes.

Ansi Styles

NamesTypesDescription
resetmodifierReset the current style
boldmodifierMake the text bold
italicmodifierMake the text italic
dimmodifierMake the text have lower opacity
inversemodifierInvert background and foreground colors
underlinemodifierPut a horizontal line below the text
hiddenmodifierPrint the text but make it invisible
strikethroughmodifierPuts a horizontal line through the center of the text
overlinemodifierPut a horizontal line above the text
blackcolorMake the text turn black
redcolorMake the text turn red
greencolorMake the text turn green
yellowcolorMake the text turn yellow
bluecolorMake the text turn blue
magentacolorMake the text turn magenta
cyancolorMake the text turn cyan
whitecolorMake the text turn white
blackBrightcolorMake the text turn black bright
redBrightcolorMake the text turn red bright
greenBrightcolorMake the text turn green bright
yellowBrightcolorMake the text turn yellow bright
blueBrightcolorMake the text turn blue bright
magentaBrightcolorMake the text turn magenta bright
cyanBrightcolorMake the text turn cyan bright
whiteBrightcolorMake the text turn white bright
bgBlackbackgroundMake the background of the text black
bgRedbackgroundMake the background of the text red
bgGreenbackgroundMake the background of the text green
bgYellowbackgroundMake the background of the text yellow
bgBluebackgroundMake the background of the text blue
bgMagentabackgroundMake the background of the text magenta
bgCyanbackgroundMake the background of the text cyan
bgWhitebackgroundMake the background of the text white
bgBlackBrightbackgroundMake the background of the text black bright
bgRedBrightbackgroundMake the background of the text red bright
bgGreenBrightbackgroundMake the background of the text green bright
bgYellowBrightbackgroundMake the background of the text yellow bright
bgBlueBrightbackgroundMake the background of the text blue bright
bgMagentaBrightbackgroundMake the background of the text magenta bright
bgCyanBrightbackgroundMake the background of the text cyan bright
bgWhiteBrightbackgroundMake the background of the text white bright
1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.5-beta.1

1 year ago

1.1.5-beta.3

1 year ago

1.1.5-beta.2

1 year ago

1.1.5-beta.4

1 year ago

1.1.1

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1-beta.2

1 year ago

1.1.1-beta.1

1 year ago

1.1.0

2 years ago

1.0.9

2 years ago

1.1.0-beta.1

2 years ago

1.0.8

2 years ago

1.0.5-c

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.5-b

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago