chalk
Advanced tools
Comparing version 3.0.0 to 4.0.0
@@ -1,23 +0,1 @@ | ||
declare const enum LevelEnum { | ||
/** | ||
All colors disabled. | ||
*/ | ||
None = 0, | ||
/** | ||
Basic 16 colors support. | ||
*/ | ||
Basic = 1, | ||
/** | ||
ANSI 256 colors support. | ||
*/ | ||
Ansi256 = 2, | ||
/** | ||
Truecolor 16 million colors support. | ||
*/ | ||
TrueColor = 3 | ||
} | ||
/** | ||
@@ -92,3 +70,10 @@ Basic foreground colors. | ||
declare namespace chalk { | ||
type Level = LevelEnum; | ||
/** | ||
Levels: | ||
- `0` - All colors disabled. | ||
- `1` - Basic 16 colors support. | ||
- `2` - ANSI 256 colors support. | ||
- `3` - Truecolor 16 million colors support. | ||
*/ | ||
type Level = 0 | 1 | 2 | 3; | ||
@@ -98,3 +83,10 @@ interface Options { | ||
Specify the color support for Chalk. | ||
By default, color support is automatically detected based on the environment. | ||
Levels: | ||
- `0` - All colors disabled. | ||
- `1` - Basic 16 colors support. | ||
- `2` - ANSI 256 colors support. | ||
- `3` - Truecolor 16 million colors support. | ||
*/ | ||
@@ -104,8 +96,6 @@ level?: Level; | ||
interface Instance { | ||
/** | ||
Return a new Chalk instance. | ||
*/ | ||
new (options?: Options): Chalk; | ||
} | ||
/** | ||
Return a new Chalk instance. | ||
*/ | ||
type Instance = new (options?: Options) => Chalk; | ||
@@ -167,3 +157,10 @@ /** | ||
The color support for Chalk. | ||
By default, color support is automatically detected based on the environment. | ||
Levels: | ||
- `0` - All colors disabled. | ||
- `1` - Basic 16 colors support. | ||
- `2` - ANSI 256 colors support. | ||
- `3` - Truecolor 16 million colors support. | ||
*/ | ||
@@ -407,3 +404,3 @@ level: Level; | ||
supportsColor: chalk.ColorSupport | false; | ||
Level: typeof LevelEnum; | ||
Level: chalk.Level; | ||
Color: Color; | ||
@@ -410,0 +407,0 @@ ForegroundColor: ForegroundColor; |
{ | ||
"name": "chalk", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Terminal string styling done right", | ||
"license": "MIT", | ||
"repository": "chalk/chalk", | ||
"funding": "https://github.com/chalk/chalk?sponsor=1", | ||
"main": "source", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=10" | ||
}, | ||
@@ -49,9 +50,9 @@ "scripts": { | ||
"coveralls": "^3.0.7", | ||
"execa": "^3.2.0", | ||
"execa": "^4.0.0", | ||
"import-fresh": "^3.1.0", | ||
"matcha": "^0.7.0", | ||
"nyc": "^14.1.1", | ||
"nyc": "^15.0.0", | ||
"resolve-from": "^5.0.0", | ||
"tsd": "^0.7.4", | ||
"xo": "^0.25.3" | ||
"xo": "^0.28.2" | ||
}, | ||
@@ -61,5 +62,9 @@ "xo": { | ||
"unicorn/prefer-string-slice": "off", | ||
"unicorn/prefer-includes": "off" | ||
"unicorn/prefer-includes": "off", | ||
"@typescript-eslint/member-ordering": "off", | ||
"no-redeclare": "off", | ||
"unicorn/string-content": "off", | ||
"unicorn/better-regex": "off" | ||
} | ||
} | ||
} |
@@ -12,7 +12,6 @@ <h1 align="center"> | ||
[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) | ||
[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) [![run on repl.it](http://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk) | ||
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900"> | ||
## Highlights | ||
@@ -28,5 +27,4 @@ | ||
- Actively maintained | ||
- [Used by ~46,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 1, 2019 | ||
- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020 | ||
## Install | ||
@@ -38,3 +36,2 @@ | ||
## Usage | ||
@@ -113,3 +110,2 @@ | ||
## API | ||
@@ -156,3 +152,2 @@ | ||
## Styles | ||
@@ -210,3 +205,2 @@ | ||
## Tagged template literal | ||
@@ -241,3 +235,2 @@ | ||
## 256 and Truecolor color support | ||
@@ -272,3 +265,2 @@ | ||
## Windows | ||
@@ -278,3 +270,2 @@ | ||
## Origin story | ||
@@ -284,3 +275,2 @@ | ||
## chalk for enterprise | ||
@@ -292,3 +282,2 @@ | ||
## Related | ||
@@ -311,3 +300,2 @@ | ||
## Maintainers | ||
@@ -314,0 +302,0 @@ |
@@ -20,3 +20,3 @@ 'use strict'; | ||
const applyOptions = (object, options = {}) => { | ||
if (options.level > 3 || options.level < 0) { | ||
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { | ||
throw new Error('The `level` option should be an integer from 0 to 3'); | ||
@@ -32,2 +32,3 @@ } | ||
constructor(options) { | ||
// eslint-disable-next-line no-constructor-return | ||
return chalkFactory(options); | ||
@@ -144,5 +145,5 @@ } | ||
// `__proto__` is used because we must return a function, but there is | ||
// We alter the prototype because we must return a function, but there is | ||
// no way to create a function with a different prototype | ||
builder.__proto__ = proto; // eslint-disable-line no-proto | ||
Object.setPrototypeOf(builder, proto); | ||
@@ -224,14 +225,2 @@ builder._generator = self; | ||
// For TypeScript | ||
chalk.Level = { | ||
None: 0, | ||
Basic: 1, | ||
Ansi256: 2, | ||
TrueColor: 3, | ||
0: 'None', | ||
1: 'Basic', | ||
2: 'Ansi256', | ||
3: 'TrueColor' | ||
}; | ||
module.exports = chalk; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; | ||
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi; | ||
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi; | ||
@@ -130,4 +130,4 @@ const ESCAPES = new Map([ | ||
if (styles.length > 0) { | ||
const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; | ||
throw new Error(errMsg); | ||
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; | ||
throw new Error(errMessage); | ||
} | ||
@@ -134,0 +134,0 @@ |
33203
659
293