Permalink
Browse files

cleanup #15

  • Loading branch information...
1 parent eced210 commit 2fbcad5964fcf0736b3c88cf0e17680ddf342ec7 @sindresorhus sindresorhus committed Jul 15, 2015
Showing with 22 additions and 13 deletions.
  1. +7 −6 index.js
  2. +15 −7 readme.md
View
@@ -5,12 +5,13 @@ var support = function (level) {
if (level === 0) {
return false;
}
- var result = {};
- result.level = level;
- result.hasBasic = true;
- result.has256 = level >= 2;
- result.has16m = level >= 3;
- return result;
+
+ return {
+ level: level,
+ hasBasic: true,
+ has256: level >= 2,
+ has16m: level >= 3
+ };
};
var supportLevel = (function () {
View
@@ -11,13 +11,6 @@ $ npm install --save supports-color
## Usage
-supports-color exports an object with color information, or `null` if color is not supported.
-
-The returned object specifies a level of support for color through a `.level` property and a corresponding flag:
-
-- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
-- `.level = 2` and `.has256 = true`: 256 color support
-- `.level = 3` and `.has16m = true`: 16 million (truecolor) support
```js
var supportsColor = require('supports-color');
@@ -35,12 +28,27 @@ if (supportsColor.has16m) {
}
```
+
+## API
+
+Returns an `object`, or `false` if color is not supported.
+
+The returned object specifies a level of support for color through a `.level` property and a corresponding flag:
+
+- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
+- `.level = 2` and `.has256 = true`: 256 color support
+- `.level = 3` and `.has16m = true`: 16 million (truecolor) support
+
+
+## Info
+
It obeys the `--color` and `--no-color` CLI flags.
For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
Explicit 256/truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
+
## Related
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module

0 comments on commit 2fbcad5

Please sign in to comment.