1.0.4 • Published 3 years ago

use-color v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

use-color

Detects if an environment supports colorful output and also if a user likely prefers color based on various CLI flags and environment variables.

tslint: Slick code style: Prettier npm semantic-release License

Install

$ npm install use-color

Usage

Node.js / CommonJS:

const { UseColor } = require('use-color')

ESNext / TypeScript:

import { UseColor } from 'use-color'
const stdErrColor = useColor.stderr() // Color support + preference for stderr.
const stdOutColor = useColor.stdout() // Color support + preference for stdout.
const otherStreamColor = useColor.check(ANY_STREAM_VALUE)

Each method above will return one of the two following shapes:

  1. Color is NOT supported.
{
  supported: false
}
  1. Color is supported:
{
  supported: true
  supports256: boolean
  supportsTrueColor: boolean // Supports 16 million colors
}

Maintainers

Sponsors

License

MIT

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago