Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

concolor

Package Overview
Dependencies
Maintainers
4
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

concolor

Console colors for strings templates in node.js

  • 0.1.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
54
decreased by-53.85%
Maintainers
4
Weekly downloads
 
Created
Source

Concolor

TravisCI Codacy Badge NPM Version NPM Downloads/Month NPM Downloads

Concolor is a simple library for Node.js for coloring templated strings using tags with annotations

Usage

  • Install: npm install concolor
  • Require: const concolor = require('concolor');
  • Now you have 4 use cases:

String tag

console.log(concolor`text ${expression}(styles)`);

Examples:

console.log(concolor`Hello ${'World'}(blue) blue`);
console.log(concolor`Hello ${'World'}(/red) on red`);
console.log(concolor`Hello ${'World'}(white/yellow,b) bold white on yellow`);
console.log(concolor`Hello ${'World'}(b) bold`);
console.log(concolor`Hello ${'World'}(b,/blue) bold on blue`);
console.log(concolor`Hello ${'World'}(b,u,yellow) bold underline yellow`);
console.log(concolor`Hello ${'World'}(blue,u) blue underline`);
console.log(concolor`Hello ${'World'}(b,black/green) bold black on green`);

console.log(concolor`
  Client on ${'192.168.1.1'}(black/green)
  connected to ${'SERVER'}(b,red)
  at ${new Date().toUTCString()}(b,blue)
`);

Tag factory

const tag = concolor(styles);
console.log(tag`text`);

Examples:

const warn = concolor('b,yellow');
const err = concolor('b,yellow/red');
const inf = concolor('i,white');

console.log(warn`test1 ${'text2'} text3`);
console.log(err`test4 ${'text5'} text6`);
console.log(inf`test7 ${'text8'} text9`);

Style function

const style = concolor(styles);
console.log(style('text'));

Examples:

const warn = concolor('b,yellow');
const err = concolor('b,yellow/red');
const inf = concolor('i,white');

console.log(warn(`test1 ${'text2'} text3`));
console.log(err(`test4 ${'text5'} text6`));
console.log(inf(`test7 ${'text8'} text9`));

Themes

const theme = concolor({
  caption: 'b,white',
  text: 'green',
  link: 'u,yellow'
});

const caption = 'Caption';
const text = 'Here is a text';
const link = 'http://metarhia.com';

console.log(theme`  ${{ caption }}
  ${{ text }}
  ${{ link }}`
);

Themes as functions

const theme = concolor({
  caption: 'b,white',
  text: 'green',
  link: 'u,yellow'
});

console.log(theme.caption('Caption example'));

Contributors

Copyright (c) 2017 concolor contributors

Keywords

FAQs

Package last updated on 28 Jun 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