1.0.4 • Published 3 years ago
use-color v1.0.4
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.
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:
- Color is NOT supported.
{
supported: false
}
- Color is supported:
{
supported: true
supports256: boolean
supportsTrueColor: boolean // Supports 16 million colors
}