Comparing

chalk@4.0.0
npmjs.comunpkgBundlephobiaPackagephobia
...
chalk@4.1.0
npmjs.comunpkgBundlephobiaPackagephobia

Packagephobia

33.4 kB

105.0 kB

Publish

Install

Bundlephobia

npm diff

Options

files: **/!(*.map|*.min.js)

Showing 4 changed files with 20 additions and 5 deletions
SplitUnified

source/index.js +++8---1

View file

@@ -6,6 +6,8 @@

66 stringEncaseCRLFWithFirstIndex
77} = require('./util');
88
9const {isArray} = Array;
10
911// `supportsColor.level` → `ansiStyles.color[name]` mapping
1012const levelMapping = [
1113 'ansi',

@@ -135,6 +137,11 @@

135137
136138const createBuilder = (self, _styler, _isEmpty) => {
137139 const builder = (...arguments_) => {
140 if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
141 // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
142 return applyStyle(builder, chalkTag(builder, ...arguments_));
143 }
144
138145 // Single argument is hot path, implicit coercion is faster than anything
139146 // eslint-disable-next-line no-implicit-coercion
140147 return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));

@@ -189,7 +196,7 @@

189196const chalkTag = (chalk, ...strings) => {
190197 const [firstString] = strings;
191198
192 if (!Array.isArray(firstString)) {
199 if (!isArray(firstString) || !isArray(firstString.raw)) {
193200 // If chalk() was called by itself or with a string,
194201 // return the string itself as a string.
195202 return strings.join(' ');

package.json +++1---1

View file

@@ -1,6 +1,6 @@

11{
22 "name": "chalk",
3 "version": "4.0.0",
3 "version": "4.1.0",
44 "description": "Terminal string styling done right",
55 "license": "MIT",
66 "repository": "chalk/chalk",

readme.md +++4---3

View file

@@ -9,7 +9,7 @@

99
1010> Terminal string styling done right
1111
12[![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)
12[![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](https://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk)
1313
1414<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
1515

@@ -199,7 +199,7 @@

199199
200200## Tagged template literal
201201
202Chalk can be used as a [tagged template literal](http://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
202Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
203203
204204```js
205205const chalk = require('chalk');

@@ -215,10 +215,11 @@

215215
216216Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
217217
218Template styles are chained exactly like normal Chalk styles. The following two statements are equivalent:
218Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
219219
220220```js
221221console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
222console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
222223console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
223224```
224225

index.d.ts +++7---0

View file

@@ -137,6 +137,13 @@

137137 DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
138138 `);
139139 ```
140
141 @example
142 ```
143 import chalk = require('chalk');
144
145 log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
146 ```
140147 */
141148 (text: TemplateStringsArray, ...placeholders: unknown[]): string;