Socket
Socket
Sign inDemoInstall

chalk

Package Overview
Dependencies
0
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.1 to 5.1.0

9

package.json
{
"name": "chalk",
"version": "5.0.1",
"version": "5.1.0",
"description": "Terminal string styling done right",

@@ -61,3 +61,3 @@ "license": "MIT",

"tsd": "^0.19.0",
"xo": "^0.47.0",
"xo": "^0.52.4",
"yoctodelay": "^2.0.0"

@@ -67,3 +67,6 @@ },

"rules": {
"unicorn/prefer-string-slice": "off"
"unicorn/prefer-string-slice": "off",
"@typescript-eslint/consistent-type-imports": "off",
"@typescript-eslint/consistent-type-exports": "off",
"@typescript-eslint/consistent-type-definitions": "off"
}

@@ -70,0 +73,0 @@ },

@@ -13,7 +13,7 @@ <h1 align="center">

[![Coverage Status](https://codecov.io/gh/chalk/chalk/branch/main/graph/badge.svg)](https://codecov.io/gh/chalk/chalk)
[![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)
[![run on repl.it](https://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk)
[![Support Chalk on DEV](https://badge.devprotocol.xyz/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15/descriptive)](https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15)
[![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)
[![run on repl.it](https://img.shields.io/badge/Run_on_Replit-130f26?logo=replit&logoColor=white)](https://repl.it/github/chalk/chalk)
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
![](media/screenshot.png)

@@ -28,3 +28,3 @@ <br>

<sup>
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a> and <a href="https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15">Dev</a>
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a>
</sup>

@@ -36,3 +36,3 @@ </p>

<a href="https://standardresume.co/tech">
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160"/>
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160">
</a>

@@ -42,3 +42,3 @@ <br>

<a href="https://retool.com/?utm_campaign=sindresorhus">
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230"/>
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230">
</a>

@@ -68,2 +68,12 @@ <br>

</a>
<br>
<br>
<a href="https://www.stackaid.us/?utm_campaign=sindre">
<div>
<img src="https://sindresorhus.com/assets/thanks/stackaid-logo.png" width="230" alt="StackAid">
</div>
<b>Fund your open source dependencies</b>
</a>
<br>
<br>
</p>

@@ -87,3 +97,3 @@ </div>

- Actively maintained
- [Used by ~76,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 26, 2021
- [Used by ~86,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 4, 2022

@@ -209,2 +219,18 @@ ## Install

### modifiers, foregroundColors, backgroundColors, and colors
All supported style strings are exposed as an array of strings for convenience. `colors` is the combination of `foregroundColors` and `backgroundColors`.
This can be useful if you wrap Chalk and need to validate input:
```js
import {modifiers, foregroundColors} from 'chalk';
console.log(modifiers.includes('bold'));
//=> true
console.log(foregroundColors.includes('pink'));
//=> false
```
## Styles

@@ -297,8 +323,2 @@

## chalk for enterprise
Available as part of the Tidelift Subscription.
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## Related

@@ -305,0 +325,0 @@

@@ -5,2 +5,6 @@ // TODO: Make it this when TS suports that.

type BasicColor = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white';
type BrightColor = `${BasicColor}Bright`;
type Grey = 'gray' | 'grey';
/**

@@ -11,22 +15,5 @@ Basic foreground colors.

*/
export type ForegroundColor =
| 'black'
| 'red'
| 'green'
| 'yellow'
| 'blue'
| 'magenta'
| 'cyan'
| 'white'
| 'gray'
| 'grey'
| 'blackBright'
| 'redBright'
| 'greenBright'
| 'yellowBright'
| 'blueBright'
| 'magentaBright'
| 'cyanBright'
| 'whiteBright';
export type ForegroundColor = BasicColor | BrightColor | Grey;
/**

@@ -37,21 +24,3 @@ Basic background colors.

*/
export type BackgroundColor =
| 'bgBlack'
| 'bgRed'
| 'bgGreen'
| 'bgYellow'
| 'bgBlue'
| 'bgMagenta'
| 'bgCyan'
| 'bgWhite'
| 'bgGray'
| 'bgGrey'
| 'bgBlackBright'
| 'bgRedBright'
| 'bgGreenBright'
| 'bgYellowBright'
| 'bgBlueBright'
| 'bgMagentaBright'
| 'bgCyanBright'
| 'bgWhiteBright';
export type BackgroundColor = `bg${Capitalize<ForegroundColor>}`;

@@ -321,2 +290,7 @@ /**

export const modifiers: readonly Modifiers[];
export const foregroundColors: readonly ForegroundColor[];
export const backgroundColors: readonly BackgroundColor[];
export const colors: readonly Color[];
export default chalk;

@@ -212,2 +212,7 @@ import ansiStyles from '#ansi-styles';

export const modifiers = Object.keys(ansiStyles.modifier);
export const foregroundColors = Object.keys(ansiStyles.color);
export const backgroundColors = Object.keys(ansiStyles.bgColor);
export const colors = [...foregroundColors, ...backgroundColors];
export default chalk;

@@ -12,3 +12,3 @@ // TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.

do {
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
returnValue += string.slice(endIndex, index) + substring + replacer;
endIndex = index + substringLength;

@@ -27,3 +27,3 @@ index = string.indexOf(substring, endIndex);

const gotCR = string[index - 1] === '\r';
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
endIndex = index + 1;

@@ -30,0 +30,0 @@ index = string.indexOf('\n', endIndex);

@@ -108,3 +108,3 @@ const ANSI_BACKGROUND_OFFSET = 10;

rgbToAnsi256: {
value: (red, green, blue) => {
value(red, green, blue) {
// We use the extended greyscale palette here, with the exception of

@@ -132,3 +132,3 @@ // black and white. normal palette only has 4 greyscale shades.

hexToRgb: {
value: hex => {
value(hex) {
const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));

@@ -162,3 +162,3 @@ if (!matches) {

ansi256ToAnsi: {
value: code => {
value(code) {
if (code < 8) {

@@ -165,0 +165,0 @@ return 30 + code;

/* eslint-env browser */
const isBlinkBasedBrowser = /\b(Chrome|Chromium)\//.test(navigator.userAgent);
const isBlinkBasedBrowser = navigator.userAgentData
? navigator.userAgentData.brands.some(({brand}) => brand === 'Chromium')
: /\b(Chrome|Chromium)\//.test(navigator.userAgent);

@@ -5,0 +7,0 @@ const colorSupport = isBlinkBasedBrowser ? {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc