Socket
Socket
Sign inDemoInstall

cmd-rainbow

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cmd-rainbow

Color printing or single line printing


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Install

npm install cmd-rainbow --save-dev 

Usage

// require('cmd-rainbow')
const { llog, log, c, slog, wlog, ilog, elog, clearLine, colors } = require('cmd-rainbow')

// llog(...arg): without '\n'
llog('llog(...arg): Without "\\n", ')
llog('Hello %s', 'world')

// log(...arg): with '\n'
log('')
log('--------------------')
log('log(...arg): With "\\n", ')
log('Hello %s', 'world')

// ilog(...arg): Green log()
ilog('--------------------')
ilog('ilog(...arg): Green log(), ')
ilog('Log %s', 'info')

// wlog(...arg): Yello log()
wlog('--------------------')
wlog('wlog(...arg): Yello log(), ')
wlog('Log %s', 'warnings')

// elog(...arg): Red log()
elog('--------------------')
elog('elog(...arg): Red log(), ')
elog('Log %s', 'errors')

/*
** c(obj, frontColor, backgroundColor): Set color
** frontColor and backgroundColor need Array like [R, G, B] or String like '#9ab' '#fab9c0'
*/
log('--------------------')
log('c(obj, frontColor, backgroundColor): Set color')
log('frontColor and backgroundColor need Array like [R, G, B] or String like "#9ab" "#fab9c0"')
log(c('Set color %s', '#f7982a'), '#f7982a')
log(c('Set color %s', [68, 123, 146]), '[68, 123, 146]')
log(c('Set color %s', [255, 123, 146], '#456'), '[255, 123, 146], #456')
log(c(['I', 'm', 'an Array'], '#456', '#f7982a'))

// custom log function
function mylog (...arg) {
  log(c(arg[0], '#f7982a'), ...arg.slice(1))
}
mylog('%s', 'custom log function mylog(...arg)')
log('--------------------')
log('slog(...arg): Single line log, without "\\n", use log("") to clear single line mode')

// slog(...arg): Single line log, without '\n', use log('') can clear single line mode
let n = 0
let t = setInterval(() => {
  slog(c('slog(...arg): Count: %d/5', '#91f822'), ++n)
  if (n >= 5) {
    clearInterval(t)
    log('')
    log('clear single line mode')
    log('--------------------')
    setTimeout(() => {
      clearLine(2)
      log('--------------------')
      llog('colors = ')
      log(colors)
    }, 2000)
  }
}, 1000)

License

  • MIT

Keywords

FAQs

Package last updated on 01 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc