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

charming-console

v1.0.9

Published

Bring color and symbols to your terminal easily!

Downloads

8

Readme

## charming-log

Enhance your console output with colors, styles, symbols, and more!

Installation

npm install charming-console

Why charming-log?

  • Why have multiple packages, when you can have one?
  • Get rid of chalk, cli-spinners, console.table, time-stamp, and many others. We have you covered.
  • This package is constantly growing in features! What you need, we have. And if we don't have it, email us at [email protected]

Usage

const {colorize, symbols, alignText, table, spin, createClickableLink, time} = require('charming-console');

// Colorize text
console.log(colorize('This is red text!', 'red'));
console.log(colorize('This is green text!', 'green'));
console.log(colorize('This is blue text!', 'blue'));

// Apply styles
console.log(applyStyle('Bold and italic text', 'bold,italic'));

// Display symbols
console.log(symbols.success, 'Operation successful!');
console.log(symbols.error, 'Error occurred!');
console.log(symbols.warning, 'Warning: proceed with caution!');
console.log(symbols.info, 'Information: check this out!');

// Align text
console.log(alignText('Right-aligned text', 'right'));
console.log(alignText('Center-aligned text', 'center'));

// Create a table
const data = [
  { name: 'John', age: 28, city: 'New York' },
  { name: 'Alice', age: 22, city: 'Los Angeles' },
  { name: 'Bob', age: 34, city: 'Chicago' },
];
console.log(table(data));

// Clickable link
console.log(createClickableLink('Click me!', 'https://example.com'));
console.log(createClickableLink('Click me!', 'https://example.com', 'green')); 
console.log(createClickableLink('Click me!', 'https://example.com', 'red', 'bold,underline'));
console.log(createClickableLink('Click me!', 'https://example.com', 'blue', 'white', 'bold,underline'));
console.log(createClickableLink('Click me!', 'https://example.com', '#FF0000', '#00FF00', 'bold,underline'));

//Spinners
//Spin forever
const forcast = spin('forcast');
//Spin for 5 seconds
const forcast = spin('forcast');
setTimeout(() => {
  clearInterval(forcast);
}, 5000);

//Timestamps
const formattedDate = time('YYYY-MM-DD HH:mm:ss', new Date());
console.log(formattedDate);
const timestamp = time();
console.log(timestamp);
const timestamputc = time.utc();
console.log(timestamputc);
const formattedUtcDate = time.utc('YYYY-MM-DD HH:mm:ss', new Date());
console.log(formattedUtcDate);

Features

Colorize

//Red Text
console.log(colorize('Red text', 'red'));
//Green text with a yellow background
console.log(colorize('Green text', 'green', 'yellow'));
console.log(colorize('Blue text', '#0000FF', '#FFFF00'));

Apply Styles

console.log(applyStyle('Bold and italic text', 'bold,italic'));
console.log(applyStyle('Underlined text', 'underline'));

Display Symbols

//Symbol Success `✓`
console.log(symbols.success, 'Operation successful!');
//Symbol Error `✗`
console.log(symbols.error, 'Error occurred!');
//Symbol Warning `⚠`
console.log(symbols.warning, 'Warning: proceed with caution!');
//Symbol Info `ℹ`
console.log(symbols.info, 'Information: check this out!');

Align Text

//Align Right
console.log(alignText('Right-aligned text', 'right'));
//Align Center
console.log(alignText('Center-aligned text', 'center'));

Create a Table

const data = [
  { name: 'John', age: 28, city: 'New York' },
  { name: 'Alice', age: 22, city: 'Los Angeles' },
  { name: 'Bob', age: 34, city: 'Chicago' },
];
console.log(table(data));

Interactive or clickable console output

// Basic usage, default color is blue
console.log(createClickableLink('Click me!', 'https://example.com'));

// Custom color and style
console.log(createClickableLink('Click me!', 'https://example.com', 'green', 'bold,underline'));

// Basic usage with text color and background color
console.log(createClickableLink('Click me!', 'https://example.com', 'blue', 'white', 'bold,underline,italic'));

// Custom text and background colors with style
console.log(createClickableLink('Click me!', 'https://example.com', '#FF0000', '#00FF00', 'bold,underline,italic'));

Spinners

//Spin Forever
const forcast = spin('forcast');
//Spin for 5 seconds
const forcast = spin('forcast');
setTimeout(() => {
  clearInterval(forcast);
}, 5000);

Timestamps

time(str, date, utc)

Formats a date object according to the provided format string.

  • str (string): The format string specifying how the date should be formatted.
  • date (Date, optional): The date object to format. Defaults to the current date.
  • utc (boolean, optional): If true, UTC time will be used. Defaults to false.

Returns: A formatted date string.

time.utc(str, date)

Same as time, but uses UTC time.


const formattedDate = time('YYYY-MM-DD HH:mm:ss', new Date());
console.log(formattedDate);

const formattedUtcDate = time.utc('YYYY-MM-DD HH:mm:ss', new Date());
console.log(formattedUtcDate);

Styles

Styles

| Style | Description | |----------------|------------------------------------------------| | RESET | Resets all styles. | | BRIGHT | Bright or bold text. | | DIM | Dim or faint text. | | UNDERLINE | Underlined text. | | BLINK | Blinking text. | | REVERSE | Reversed background and foreground colors. | | HIDDEN | Hidden or invisible text. | | ITALIC | Italicized text. |

Colors

| Color | Description | |----------------|------------------------------------------------| | BLACK | Black text. | | RED | Red text. | | GREEN | Green text. | | YELLOW | Yellow text. | | BLUE | Blue text. | | MAGENTA | Magenta (purple) text. | | CYAN | Cyan (blue-green) text. | | WHITE | White text. | | GRAY | Gray text. | | BRIGHT_RED | Bright or light red text. | | BRIGHT_GREEN| Bright or light green text. | | BRIGHT_YELLOW | Bright or light yellow text. | | BRIGHT_BLUE | Bright or light blue text. | | BRIGHT_MAGENTA | Bright or light magenta (pink) text. | | BRIGHT_CYAN | Bright or light cyan text. | | BRIGHT_WHITE | Bright or light white text. |

Background Color

| Background Color | Description | |-------------------|----------------------------------------------| | BG_BLACK | Black background. | | BG_RED | Red background. | | BG_GREEN | Green background. | | BG_YELLOW | Yellow background. | | BG_BLUE | Blue background. | | BG_MAGENTA | Magenta (purple) background. | | BG_CYAN | Cyan (blue-green) background. | | BG_WHITE | White background. | | BG_GRAY | Gray background. | | BG_BRIGHT_RED | Bright or light red background. | | BG_BRIGHT_GREEN | Bright or light green background. | | BG_BRIGHT_YELLOW | Bright or light yellow background. | | BG_BRIGHT_BLUE | Bright or light blue background. | | BG_BRIGHT_MAGENTA | Bright or light magenta (pink) background.| | BG_BRIGHT_CYAN | Bright or light cyan background. | | BG_BRIGHT_WHITE | Bright or light white background. |

Spinner Types

Explore a variety of spinners to add dynamic elements to your console output. Choose from the following spinner types:

| Spinner Type | Spinner Type | Spinner Type | Spinner Type | | -------------- | -------------- | -------------- | -------------- | | 1 | 2 | 3 | 4 | | 5 | 6 | 7 | 8 | | lines1 | lines2 | arrowPipe | lilDots | | scrollyDots| stary | xstars | waveFlip | | spongebob | upDown | leftRight | balloonPop | | balloonPop2| flash | cornerBounce| lineBounce | | triangle | binary | noahsArc | around | | squareCorners| circle25 | circle.5 | grid | | toggleLine | togglesmBox| togglebBox | togglesbBox| | toggleReq | target | eye | arrowRound | | arrowRight | reboundingBar| bounceBall| silly | | peekaBoo | love | time | earth | | moonPhase | trackStar | pingPong | babyShark | | forcast | santa | bomb | fingy | | booYah | soccer | crazy | colorPulse | | load | | | |

Choose the spinner that suits your console output style and adds a touch of creativity!

Time Format Options

The format string can include the following placeholders:

| Placeholder | Description | |-------------|--------------------------------------| | YYYY | Full year (4 digits). | | YY | Short year (2 digits). | | MM | Month (zero-padded). | | DD | Day of the month (zero-padded). | | HH | Hours (zero-padded). | | mm | Minutes (zero-padded). | | ss | Seconds (zero-padded). | | ms | Milliseconds. |

Questions, Comments, Support?

Send us an email at [email protected] to create a ticket! Or join our Discord https://discord.com/invite/wNfFXx7J8q

License

This project is licensed under the MIT License