@stzhu/console-style-tag

1.0.1 • Public • Published

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)

Readme

Keywords

none

Package Sidebar

Install

npm i @stzhu/console-style-tag

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

10.4 kB

Total Files

8

Last publish

Collaborators

  • stzhu