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

ylg

v1.1.1

Published

Simple and complete list of colors and styles for console.log()

Downloads

95

Readme

About

Simple and complete list of colors and styles for console.log()

log

let log = require('ylg')
log() // similar to console.log
log.test() // will output all available colors and styles in terminal for you to choose
log.black()
log.bgblack()
log.red('a') // ouput red color "a" in terminal
log.bgred()
log.green('a', 'b', ...) // supports multiple arguments
log.bggreen()
log.yellow('a', array, object) // supports array and object
log.bgyellow()
log.blue()
log.bgblue() // background blue color
log.magenta()
log.bgmagenta()
log.cyan()
log.bgcyan()
log.white()
log.bgwhite()
log.dark()
log.bgdark()
// shorthand
log.r() // shorthand for log.red()
log.bgr()
log.g()
log.bgg()
log.y()
log.bgy()
log.b()
log.bgb()
log.m()
log.bgm()
log.c()
log.bgc()
log.w()
log.bgw()

// styles
log.reset()
log.bold() // apply bold style
log.dim()
log.italize()
log.underline()
log.blink()
log.none()
log.reverse()
log.hidden()
// shorthands
log.R()
log.B() // shorthand for bold style
log.D()
log.i()
log.u()
log.rv()
log.h()
log.inline() // doesn't break into next line
log.lg() // shorthand for inline

// extra
log.error()
log.err()
log.er()
log.E()
log.e()
log.W()
log.warn()
log.warning()

// special
log.out() // same as process.stdout.write()

log.depth() // similar to console.log(util.inspect(1, null)), default depth is null (fully expand), default console.log only has depth 1 ( { k: { k2: [Object] } } )
log.depth0() // depth: 0
log.depth[0-9]() // depth from 0-9
log.d() // shorthand for log.depth()
log.d0()
log.d[0-9]()

lg (inline of log)

let {lg} = require('ylg')
lg.test() // output all available inline colors and styles in terminal
lg.red('a') // ouput red color "a" inline (no line break) in terminal
lg.bgred()
lg.green()
... // all methods same as log above

custom combo

log('a', ['red','bold']) // combine bold and red together
log.red('a', ['bold']) // alternative way
lg.bold('a', ['red']) // inline + bold + red

All elements in the last array must fully match the color and styles, else will show the array instead.

additional

let {err, warn} = require('ylg')
err('a') // log error, shorthand for log.bgred (background red)
warn('a') // warning, shorthand for log.yellow
debug('a) // same as log.cyan

/// shorthands
// e = E = er = err = error = log.e = log.E = log.er = log.err = log.error = log.bgr;
// W = warn = warning = log.W = log.warn = log.warning = log.y;

/// inline
// lg.e = lg.E = lg.er = lg.err = lg.error = lg.bgr;
// lg.W = lg.warn = lg.warning = lg.y;

/// special
let {out, inspect} = require('ylg')
out // same as process.stdout.write()
inspect(v, depth=null) // same as util.inspect() //  can use log.inspect() as well
// shorthand
let {insp, isp, ip} = require('ylg')
insp() // same as inspect; can use log.insp() as well
isp() // same
ip() // same

// to color code
let { toc } = require('ylg') // alt: log.toc
toc.red('AA') // \x1b[31mAA\x1b0m // to insert inside log()
toc.red() // \x1b[31m // to insert inside log() (open)
toc.R() // \x1b[0m // reset all colors and styles (close)
... // has all color and style methods as log() above

global

require('ylg').gb()
log(1)
log.r(1)

Available globally: log, lg, out, inspect, W, warn, warning, E, err, error, toc.

require('ylg').gb.main()
log()
lg()

require('ylg').gb.abbr() // abreviation, shorthand
out() // shorthand for process.stdout.write()
inspect(ob[, depth=null]) // shorthand for console.log(util.inspect(ob, 1, depth, 1))
insp() // abbr for inspect

require('ylg').gb.warn()
W()
warn()
warning()

require('ylg').gb.err()
E()
er()
err()
error()

// you can also require separately as normal
const {warn, err} = require('ylg')

flaw

Careful when log last variable as array, if elements in array all match the colors and sytles AND there are more than 1 arguments provided, the array will be used to style and will NOT be output.

let arr=['red','bold']
log(v, arr) // arr will be used to style and will NOT be output
log(v, arr, '') // workaround: just pass in any or empty string as the last value

etc

ylg is just shorthand for Y log (Y is nickname, and lg (log) is console.log).