@stzhu/console-style-tag
v1.0.1
Published
Package for styling console logs in developer tools.
Downloads
2
Readme
Package for styling console logs in developer tools.
Usage
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'}.`
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)