@fav/cli.get-color-depth
v0.1.1
Published
Determine what colors the terminal supports
Downloads
8
Maintainers
Readme
@fav/cli.get-color-depth
Determine what colors the terminal supports.
This module is created referencing tty.WriteStream#getColorDepth
of Node.js API.
"fav" is an abbreviation of "favorite" and also the acronym of "for all versions". This package is intended to support all Node.js versions as possible. At least, this package supports Node.js >= v0.10.
Install
To install from npm:
$ npm install --save @fav/cli.get-color-depth
NOTE: npm < 2.7.0 does not support scoped package, but old version Node.js supports it. So when you use such older npm, you should download this package from github.com, and move it in node_modules/@fav/cli.get-color-depth/
directory manually.
Usage
var getColorDepth = require('@fav/cli.get-color-depth');
getColorDepth() // => 1 or 4 or 8 or 24
API
getColorDepth([env]) : number
Detects color depth supported by this terminal or the environment indicated by env.
Parameters:
| Parameter | Type | Description |
|:----------|:------:|:--------------------------|
| env | object | An object containing the environment variables to check. Uses process.env
if not specified. (Optional) |
Returns:
| Type | Description | |:------:|:-----------------| | number | Color depth. (1:2 colors / 4:16 colors / 8:256 colors / 24: 16m colors) |
Checked
Node.js (4〜12)
| Platform | 11 | 12 | |:---------:|:------:|:------:| | macOS |◯|◯| | Windows10 |◯|◯| | Linux |◯|◯|
| Platform | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |:---------:|:------:|:------:|:------:|:------:|:------:|:------:|:------:| | macOS |◯|◯|◯|◯|◯|◯|◯| | Windows10 |◯|◯|◯|◯|◯|◯|◯| | Linux |◯|◯|◯|◯|◯|◯|◯|
io.js (1〜3)
| Platform | 1 | 2 | 3 | |:---------:|:------:|:------:|:------:| | macOS |◯|◯|◯| | Windows10 |◯|◯|◯| | Linux |◯|◯|◯|
Node.js (〜0.12)
| Platform | 0.8 | 0.9 | 0.10 | 0.11 | 0.12 | |:---------:|:------:|:------:|:------:|:------:|:------:| | macOS |◯|◯|◯|◯|◯| | Windows10 |◯|◯|◯|◯|◯| | Linux |◯|◯|◯|◯|◯|
License
Copyright (C) 2019 Takayuki Sato
This program is free software under MIT License. See the file LICENSE in this distribution for more details.