npm.io
1.0.1 • Published 7 years ago

@stzhu/console-style-tag

Licence
MIT
Version
1.0.1
Deps
0
Size
10 kB
Vulns
0
Weekly
0

npm GitHub Build Status Coverage Status devDependencies Status

Package for styling console logs in developer tools.

Usage

  1. Styling

    The styles can be given as an object. Each key matches the index of the interpolated variable. In the following case, the style would apply to the word 'text'.

    consoleStyle({ 1: 'color: red' })`This is some ${'styled'} ${'text'}.`

    Styles can also be given as an array. Each index matches the index of the interpolated variable.

    consoleStyle(['color: blue', 'color: red'])`This is some ${'styled'} ${'text'}.`

    Falsy styles are ignored.

    consoleStyle([ undefined, 'color: red' ])`This is some ${'styled'} ${'text'}.`
  2. The output can then be passed to console.log using the spread operator.

    const output = consoleStyle([ undefined, 'color: red' ])`This is some ${'styled'} ${'text'}.`
    console.log(...output)