包详细信息

colorize-template

usmanyunusov2.5kMIT1.0.0

Tagged template literal for ANSI colors.

colors, console, formatting, terminal

自述文件

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 }.

更新日志

Change Log

This project adheres to Semantic Versioning.

1.0.0

  • Replace project name nanocolors-template to colorize-template
  • Replace jest to node assert
  • New API

0.1.1

  • Added browser support

0.1.0

  • Refactoring
  • Added test
  • Support for nested calls
  • Added TS support
  • Add ESM support

0.0.5

  • Added coverage to .npmignore

0.0.4

  • Publish with clean-publish

0.0.3

  • Added clean-publish

0.0.2

  • Added repository to package.json

0.0.1

  • Initial release.