[go: nahoru, domu]

colorize-template
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Colorize Template

Tagged template literal for ANSI colors.

  • No dependencies.
  • Node.js v6+ & browsers support. Support both CJS and ESM projects.
  • TypeScript type declarations included.

You need to provides an object which includes a variety of text coloring and formatting functions. You can use ready-made projects: Picocolors, Colorette, Kleur, Colors.js, Chalk

import { createColorize } from 'colorize-template'
import * as picocolors from 'picocolors'
import * as colorette from 'colorette'

let colorize = createColorize({
  ...picocolors,
  success: picocolors.green,
  error: colorette.red
})

console.log(
  colorize`Is red {red color} text`,
  colorize`Run {yellow.bgRed ${'yellow'} test}`,
  colorize`Is red {error error and success {success green text}}`,
)

Blocks are delimited by an opening curly brace {, a style, some content, and a closing curly brace }.

Package Sidebar

Install

npm i colorize-template

Weekly Downloads

621

Version

1.0.0

License

MIT

Unpacked Size

4.87 kB

Total Files

7

Last publish

Collaborators

  • usmanyunusov