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

@yaireo/console-colors

v1.2.0

Published

Colorize your browser's console logs

Downloads

12

Readme


  • Mind that styling of console logs only works for primitive types
  • The use of this utility is for modern browsers only
  • I advise to carefully include this script in development env and not in production

npm i @yaireo/console-colors --save

Or use it as a script from one of the following CDN:

  • https://cdn.jsdelivr.net/npm/@yaireo/console-colors
  • https://unpkg.com/@yaireo/console-colors

Usage

One way to use "console-colors" is by creating a logger which will be glovally available

import consoleColor from '@yaireo/console-colors';

window.log = consoleColor()
log.red.bgWhite.bold.log("so nice", "I think so")()

Another way, is to extend window.console:

import consoleColor from '@yaireo/console-colors';

consoleColor( window.console )
console.big.bold.silver.log(1,2,3)()

Live Playground

API

Styles

bold, big, italic, capitalize, shadow

Colors

These are methods for text colors

console.blue.log("blue text")()

Each of the below colors can be used as background color as well:

console.bgBlue.white("white text over blue background")()

white, black, silver, gray, red, green, blue, gold, yellow, pink, cyan

Special

  • random - picks a random text color
  • bg - picks a random background color

Be aware that I did not include any code which tests colors contrast because such additional code will bload this tiny package


Drawbacks

Unfortunately the empty parenthesis at the end are a must to be able to keep the real file/line which the console was invoked at, otherwise it would show it as index.js (this lib), which is unhelpful.