@parrotjs/supports-color
v2.1.0
Published
a util package that detect whether a terminal supports color
Downloads
19
Readme
可以得出终端/浏览器支持多少颜色
一、支持环境
支持node环境和浏览器环境
二、类库作用
//index.js
import supportsColor from '@parrotjs/supports-color';
...
...
...
const supportsColor = require('supports-color');
if (supportsColor.stdout) {
console.log('Terminal stdout supports color');
}
if (supportsColor.stdout.has256) {
console.log('Terminal stdout supports 256 colors');
}
if (supportsColor.stderr.has16m) {
console.log('Terminal stderr supports 16 million colors (truecolor)');
}
//index.html
<script src="https://unpkg.com/@parrotjs/[email protected]/browser.js"></script>
<script>
console.log(supportsColor)
</script>
三、使用npm安装
1.执行命令:
npm install --save-dev @parrotjs/supports-color
2.使用import引入:
import merge from '@parrotjs/supports-color';
3.使用require引入:
const merge =require('@parrotjs/supports-color');
四、使用upk在线cdn
https://unpkg.com/@parrotjs/[email protected]/browser.js
五、使用jsdelivr在线cdn
https://cdn.jsdelivr.net/npm/@parrotjs/[email protected]/browser.js
六、github源码地址
https://github.com/parrot-design/parrot-utils/tree/main/supports-color
七、版本变更记录
- 1.6.0 初始化目录
- 1.7.0 修改MD说明文件
- 1.8.0 修改package.json
- 1.9.0 修改package.json