{"_id":"@3rd/supports-color","name":"@3rd/supports-color","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@3rd/supports-color","version":"0.0.1","author":{"name":"scriptpower"},"description":"Detect whether a terminal supports color","keywords":["color","colour","colors","terminal","console","cli","ansi","styles","tty","rgb","256","shell","xterm","command-line","support","supports","capability","detect","truecolor","16m"],"type":"module","types":"index.d.ts","main":"index.js","module":"index.js","exports":{"default":"./index.js","node":"./index.js","import":"./index.js","require":"./index.cjs","types":"./index.d.ts"},"engine":{"node":">=18"},"license":"MIT","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_id":"@3rd/supports-color@0.0.1","gitHead":"5440d2a0d9e36422e130c49c4dd19ff4b0ac0725","_nodeVersion":"22.0.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-DH6EDxABzRSNKxb+Sf/fLk5bcTtb+MufN0tCxnDD3jQuuzocvkEVCVH/PESHaJeuii7W7JPRfjM27jaQ9StNRA==","shasum":"2b01f2dccacf4e6946c992bb4d9333f76033242e","tarball":"https://registry.npmjs.org/@3rd/supports-color/-/supports-color-0.0.1.tgz","fileCount":5,"unpackedSize":9146,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIChmbV5mYm0dcOj8UzQjP45m0OqJqgpmXVzowOohRFnvAiARznXiQprwu/aiDV3QL8nujwhGM4jYf5olycfwEQ2/qQ=="}]},"_npmUser":{"name":"scriptpower","email":"scriptpower@qq.com"},"directories":{},"maintainers":[{"name":"scriptpower","email":"scriptpower@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/supports-color_0.0.1_1717337418391_0.24956779200783674"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-02T14:10:18.262Z","0.0.1":"2024-06-02T14:10:18.575Z","modified":"2024-06-02T14:10:18.893Z"},"maintainers":[{"name":"scriptpower","email":"scriptpower@qq.com"}],"description":"Detect whether a terminal supports color","keywords":["color","colour","colors","terminal","console","cli","ansi","styles","tty","rgb","256","shell","xterm","command-line","support","supports","capability","detect","truecolor","16m"],"author":{"name":"scriptpower"},"license":"MIT","readme":"# @3rd/supports-color\n\n> Detect whether a terminal supports color\n\n## Install\n\n```sh\nnpm install @3rd/supports-color\n```\n\n## Usage\n\n```js\nimport supportsColor from '@3rd/supports-color';\n\nif (supportsColor.stdout) {\n\tconsole.log('Terminal stdout supports color');\n}\n\nif (supportsColor.stdout.has256) {\n\tconsole.log('Terminal stdout supports 256 colors');\n}\n\nif (supportsColor.stderr.has16m) {\n\tconsole.log('Terminal stderr supports 16 million colors (truecolor)');\n}\n```\n\n## API\n\nReturns an `object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.\n\nThe `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:\n\n- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)\n- `.level = 2` and `.has256 = true`: 256 color support\n- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)\n\n### Custom instance\n\nThe package also exposes the named export `createSupportColor` function that takes an arbitrary write stream (for example, `process.stdout`) and an optional options object to (re-)evaluate color support for an arbitrary stream.\n\n```js\nimport {createSupportsColor} from '@3rd/supports-color';\n\nconst stdoutSupportsColor = createSupportsColor(process.stdout);\n\nif (stdoutSupportsColor) {\n\tconsole.log('Terminal stdout supports color');\n}\n\n// `stdoutSupportsColor` is the same as `supportsColor.stdout`\n```\n\nThe options object supports a single boolean property `sniffFlags`. By default it is `true`, which instructs the detection to sniff `process.argv` for the multitude of `--color` flags (see _Info_ below). If `false`, then `process.argv` is not considered when determining color support.\n\n## Info\n\nIt obeys the `--color` and `--no-color` CLI flags.\n\nFor situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.\n\nExplicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.\n\n## Related\n\n- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module\n- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right\n- [is-unicode-supported](https://github.com/sindresorhus/is-unicode-supported) - Detect whether the terminal supports Unicode\n- [is-interactive](https://github.com/sindresorhus/is-interactive) - Check if stdout or stderr is interactive\n\n## Maintainers\n\n- [Sindre Sorhus](https://github.com/sindresorhus)\n- [Josh Junon](https://github.com/qix-)","readmeFilename":"README.md"}