ansi-styles
Advanced tools
Comparing version 3.2.1 to 4.0.0
35
index.js
'use strict'; | ||
const colorConvert = require('color-convert'); | ||
const wrapAnsi16 = (fn, offset) => function () { | ||
const code = fn.apply(colorConvert, arguments); | ||
const wrapAnsi16 = (fn, offset) => (...args) => { | ||
const code = fn(...args); | ||
return `\u001B[${code + offset}m`; | ||
}; | ||
const wrapAnsi256 = (fn, offset) => function () { | ||
const code = fn.apply(colorConvert, arguments); | ||
const wrapAnsi256 = (fn, offset) => (...args) => { | ||
const code = fn(...args); | ||
return `\u001B[${38 + offset};5;${code}m`; | ||
}; | ||
const wrapAnsi16m = (fn, offset) => function () { | ||
const rgb = fn.apply(colorConvert, arguments); | ||
const wrapAnsi16m = (fn, offset) => (...args) => { | ||
const rgb = fn(...args); | ||
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; | ||
@@ -42,5 +42,5 @@ }; | ||
white: [37, 39], | ||
gray: [90, 39], | ||
// Bright color | ||
blackBright: [90, 39], | ||
redBright: [91, 39], | ||
@@ -76,11 +76,10 @@ greenBright: [92, 39], | ||
// Fix humans | ||
styles.color.grey = styles.color.gray; | ||
// Alias bright black as gray (and grey) | ||
styles.color.gray = styles.color.blackBright; | ||
styles.bgColor.bgGray = styles.bgColor.bgBlackBright; | ||
styles.color.grey = styles.color.blackBright; | ||
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright; | ||
for (const groupName of Object.keys(styles)) { | ||
const group = styles[groupName]; | ||
for (const styleName of Object.keys(group)) { | ||
const style = group[styleName]; | ||
for (const [groupName, group] of Object.entries(styles)) { | ||
for (const [styleName, style] of Object.entries(group)) { | ||
styles[styleName] = { | ||
@@ -133,9 +132,7 @@ open: `\u001B[${style[0]}m`, | ||
for (let key of Object.keys(colorConvert)) { | ||
if (typeof colorConvert[key] !== 'object') { | ||
for (let [key, suite] of Object.entries(colorConvert)) { | ||
if (typeof suite !== 'object') { | ||
continue; | ||
} | ||
const suite = colorConvert[key]; | ||
if (key === 'ansi16') { | ||
@@ -142,0 +139,0 @@ key = 'ansi'; |
{ | ||
"name": "ansi-styles", | ||
"version": "3.2.1", | ||
"version": "4.0.0", | ||
"description": "ANSI escape codes for styling strings in the terminal", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=8" | ||
}, | ||
@@ -46,13 +46,9 @@ "scripts": { | ||
"dependencies": { | ||
"color-convert": "^1.9.0" | ||
"color-convert": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"babel-polyfill": "^6.23.0", | ||
"ava": "^1.4.1", | ||
"svg-term-cli": "^2.1.1", | ||
"xo": "*" | ||
}, | ||
"ava": { | ||
"require": "babel-polyfill" | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -7,3 +7,3 @@ # ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles) | ||
<img src="https://cdn.rawgit.com/chalk/ansi-styles/8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900"> | ||
<img src="screenshot.svg" width="900"> | ||
@@ -64,3 +64,3 @@ | ||
- `white` | ||
- `gray` ("bright black") | ||
- `blackBright` (alias: `gray`, `grey`) | ||
- `redBright` | ||
@@ -84,3 +84,3 @@ - `greenBright` | ||
- `bgWhite` | ||
- `bgBlackBright` | ||
- `bgBlackBright` (alias: `bgGray`, `bgGrey`) | ||
- `bgRedBright` | ||
@@ -148,4 +148,12 @@ - `bgGreenBright` | ||
## License | ||
--- | ||
MIT | ||
<div align="center"> | ||
<b> | ||
<a href="https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
</b> | ||
<br> | ||
<sub> | ||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
</sub> | ||
</div> |
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
9741
3
156
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
Updatedcolor-convert@^2.0.0