Comparing

    npmjs.comunpkgBundlephobiaPackagephobia
    ...
      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 @@

      6 stringEncaseCRLFWithFirstIndex6 stringEncaseCRLFWithFirstIndex
      7} = require('./util');7} = require('./util');
      8 8
      9const {isArray} = Array;
      10
      9// `supportsColor.level` → `ansiStyles.color[name]` mapping11// `supportsColor.level` → `ansiStyles.color[name]` mapping
      10const levelMapping = [12const levelMapping = [
      11 'ansi',13 'ansi',

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

      135 137
      136const createBuilder = (self, _styler, _isEmpty) => {138const createBuilder = (self, _styler, _isEmpty) => {
      137 const builder = (...arguments_) => {139 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
      138 // Single argument is hot path, implicit coercion is faster than anything145 // Single argument is hot path, implicit coercion is faster than anything
      139 // eslint-disable-next-line no-implicit-coercion146 // eslint-disable-next-line no-implicit-coercion
      140 return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));147 return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));

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

      189const chalkTag = (chalk, ...strings) => {196const chalkTag = (chalk, ...strings) => {
      190 const [firstString] = strings;197 const [firstString] = strings;
      191 198
      192 if (!Array.isArray(firstString)) {199 if (!isArray(firstString) || !isArray(firstString.raw)) {
      193 // If chalk() was called by itself or with a string,200 // If chalk() was called by itself or with a string,
      194 // return the string itself as a string.201 // return the string itself as a string.
      195 return strings.join(' ');202 return strings.join(' ');

      package.json +++1---1

      View file

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

      1{1{
      2 "name": "chalk",2 "name": "chalk",
      3 "version": "4.0.0",3 "version": "4.1.0",
      4 "description": "Terminal string styling done right",4 "description": "Terminal string styling done right",
      5 "license": "MIT",5 "license": "MIT",
      6 "repository": "chalk/chalk",6 "repository": "chalk/chalk",

      readme.md +++4---3

      View file

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

      9 9
      10> Terminal string styling done right10> Terminal string styling done right
      11 11
      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)
      13 13
      14<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">14<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
      15 15

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

      199 199
      200## Tagged template literal200## Tagged template literal
      201 201
      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).
      203 203
      204```js204```js
      205const chalk = require('chalk');205const chalk = require('chalk');

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

      215 215
      216Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).216Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
      217 217
      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:
      219 219
      220```js220```js
      221console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));221console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
      222console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
      222console.log(chalk`{bold.rgb(10,100,200) Hello!}`);223console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
      223```224```
      224 225

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

      View file

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

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