1.0.1 • Published 5 years ago

@stzhu/console-style-tag v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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)