yoctocolors
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -0,3 +1,8 @@ | ||
import tty from 'node:tty'; | ||
// TODO: Use a better method when it's added to Node.js (https://github.com/nodejs/node/pull/40240) | ||
const hasColors = tty.WriteStream.prototype.hasColors(); | ||
// Intentionally not using template literal for performance. | ||
const format = (startCode, endCode) => string => '\u001B[' + startCode + 'm' + string + '\u001B[' + endCode + 'm'; | ||
const format = (startCode, endCode) => hasColors ? string => '\u001B[' + startCode + 'm' + string + '\u001B[' + endCode + 'm' : string => string; | ||
@@ -4,0 +9,0 @@ export const reset = format(0, 0); |
{ | ||
"name": "yoctocolors", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "The smallest and fastest command-line coloring package on the internet. Trust me.", | ||
@@ -49,3 +49,8 @@ "license": "MIT", | ||
"xo": "^0.44.0" | ||
}, | ||
"ava": { | ||
"environmentVariables": { | ||
"FORCE_COLOR": "1" | ||
} | ||
} | ||
} |
@@ -32,3 +32,3 @@ <sup>yoctocolors 🌈</sup> | ||
*This package does not do color support detection. Check out [`supports-color`](https://github.com/chalk/supports-color) if you need that.* | ||
*This package supports [basic color detection](https://nodejs.org/api/tty.html#writestreamhascolorscount-env). Colors can be forcefully enabled by setting the `FORCE_COLOR` environment variable to `1` and can be forcefully disabled by setting `NO_COLOR` or `NODE_DISABLE_COLORS` to any value. [More info.](https://nodejs.org/api/tty.html#writestreamgetcolordepthenv)* | ||
@@ -88,4 +88,15 @@ ## Styles | ||
## Why? | ||
## FAQ | ||
### Why? | ||
See [this discussion](https://github.com/babel/babel/pull/13783). | ||
### What is yocto? | ||
[It's the smallest official unit prefix in the metric system.](https://en.wikipedia.org/wiki/Yocto-) Much smaller than nano. | ||
## Related | ||
- [yoctodelay](https://github.com/sindresorhus/yoctodelay) - Delay a promise a given amount of time | ||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6840
60
101