{"_id":"chalk-cjs","_rev":"1646972","name":"chalk-cjs","description":"Terminal string styling done right","dist-tags":{"latest":"5.2.0"},"maintainers":[{"name":"juln","email":"1850021148@qq.com"}],"time":{"modified":"2026-10-27T16:14:07.000Z","created":"2023-01-30T02:36:36.884Z","5.2.0":"2023-01-30T02:36:36.884Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/chalk/chalk.git"},"versions":{"5.2.0":{"name":"chalk-cjs","version":"5.2.0","description":"Terminal string styling done right","license":"MIT","repository":{"type":"git","url":"git+https://github.com/chalk/chalk.git"},"funding":"https://github.com/chalk/chalk?sponsor=1","type":"commonjs","main":"./source/index.js","exports":"./source/index.js","imports":{"#ansi-styles":"./source/vendor/ansi-styles/index.js","#supports-color":{"node":"./source/vendor/supports-color/index.js","default":"./source/vendor/supports-color/browser.js"}},"types":"./source/index.d.ts","engines":{"node":"^12.17.0 || ^14.13 || >=16.0.0"},"scripts":{"test":"xo && c8 ava && tsd","bench":"matcha benchmark.js"},"keywords":["chalk","npm2cjs","color","colour","colors","terminal","console","cli","string","ansi","style","styles","tty","formatting","rgb","256","shell","xterm","log","logging","command-line","text","cjs"],"devDependencies":{"@types/node":"^16.11.10","ava":"^3.15.0","c8":"^7.10.0","color-convert":"^2.0.1","execa":"^6.0.0","log-update":"^5.0.0","matcha":"^0.7.0","tsd":"^0.19.0","xo":"^0.53.0","yoctodelay":"^2.0.0"},"xo":{"rules":{"unicorn/prefer-string-slice":"off","@typescript-eslint/consistent-type-imports":"off","@typescript-eslint/consistent-type-exports":"off","@typescript-eslint/consistent-type-definitions":"off"}},"c8":{"reporter":["text","lcov"],"exclude":["source/vendor"]},"generateFrom__timestamp__1675046195241":"npm2cjs(https://www.npmjs.com/package/npm2cjs)","publishConfig":{"access":"public"},"bugs":{"url":"https://github.com/chalk/chalk/issues"},"homepage":"https://github.com/chalk/chalk#readme","_id":"chalk-cjs@5.2.0","_nodeVersion":"16.13.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-GJ7MUEISBU0pglCMmAvpzRav0PN2ZZ33nYNOu07zoLymwY69EFwSqx+VK3wPFKi0dBCn/qgYcJmgPYbEaLynnQ==","shasum":"b1b01459462966324d1553accfa45b097cb2293f","tarball":"http://registry-npm.ywwl.com/chalk-cjs/download/chalk-cjs-5.2.0.tgz","fileCount":4,"unpackedSize":35307,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqaExB9RI1LFjnF1CnRg2W9OTbw2nEz4Rqx69DtuJeZAIgbKV1Ux4AgK6QxEkR/Ra8+zfGiswXkdZFm1333DzeSu0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj1y00ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq//A/+K9qTG3pVZpCIHgJWPcABdP5k+5+yl8kdvWmK5lNkzeqdjPk1\r\nK6aBTo+QTYFyGuSWy4slZHPfQrhjDPyqYCul6bS9zhN6SEJAjGnlbpBRjPfp\r\n4cuOlVrI7DgXL+3XZYI1p6qAPfwj1Z1J7XqY86eTNtOQERj1bhacmfpOUaQz\r\n1sMhqD5uOIcn0vZm4I6hO5HJq/M0C/oTHKQE7oC29n2ty83PDNdE78R+Ajuv\r\nV5krq+yMpZu1xnp5cKM2ZlOnc+TwkyoXzysYdBRQW1aJS6ya6XhxhgSYa2zS\r\nwXbpUE23lUmlUJ6iZ9LXD60IB+1pcR+QAeBGSjoayWY4Sf8kVk46/1ZsM5co\r\nzJfHCJS9SPNXRffgmFnDtQe4GxEX+0IAnVIu6QCovMdSs36RPzxKSkQD3dEq\r\nIbwyGpsbJoWh/9DcxsGi0BOnfr9Z3JSNXF+DlSnXu4HPRIPqjBcm5n8LZ/HS\r\nIGUdkd6Twd6suBc3qQG9/iD9xfa64KvGBJT+6DVvs7e9pAatqBlL+POAXjOw\r\nU+lOr+gJZVVryxY+wrIYePrGdMK74QV6JL+9oDw/KmSlGruVoMeNqIXZR/Ix\r\nbCRTxrwiANqsR2wZfvKzNFD3blPa5wsEvxi54o1MkgGjkhikuiQ1kbt9ia6d\r\nAth2e84X/L8Xmqc0vf7SaYx6ybo5A+zq2m0=\r\n=JNfu\r\n-----END PGP SIGNATURE-----\r\n","size":11681,"noattachment":false,"key":"/chalk-cjs/-/chalk-cjs-5.2.0.tgz"},"_npmUser":{"name":"juln","email":"1850021148@qq.com"},"directories":{},"maintainers":[{"name":"juln","email":"1850021148@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chalk-cjs_5.2.0_1675046196721_0.9674049807177487"},"_hasShrinkwrap":false,"publish_time":1675046196884,"_cnpm_publish_time":1675046196884}},"readme":"# chalk-cjs\n\n<div align='center'>\n\t<br/>\n\t<div style='border: 2px solid yellow; font-size: 20px; width: 60px; height: 60px; line-height: 30px; border-radius: 50%; transform: rotate(45deg);'>\n    <span style='position: relative; top: 2px;'>🌈&nbsp;<span style='display: inline-block; transform: rotate(-45deg);'>🌛</span></span>\n    <br />\n    <span style='position: relative; top: -2px;'><span style='display: inline-block; transform: rotate(-45deg);'>🌞</span>&nbsp;❄️</span>\n  </div>\n\t<br/>\n</div>\n\n该npm包由 [`npm2cjs`](https://www.npmjs.com/package/npm2cjs) 转译工具生成.\n\n原npm包: [`chalk`](https://www.npmjs.com/package/chalk)\n\n下面为原npm包的README内容\n\n<h1 align=\"center\">\n\t<br>\n\t<br>\n\t<img width=\"320\" src=\"media/logo.svg\" alt=\"Chalk\">\n\t<br>\n\t<br>\n\t<br>\n</h1>\n\n> Terminal string styling done right\n\n[![Coverage Status](https://codecov.io/gh/chalk/chalk/branch/main/graph/badge.svg)](https://codecov.io/gh/chalk/chalk)\n[![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents)\n[![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk)\n[![run on repl.it](https://img.shields.io/badge/Run_on_Replit-f26207?logo=replit&logoColor=white)](https://repl.it/github/chalk/chalk)\n\n![](media/screenshot.png)\n\n<br>\n\n---\n\n<div align=\"center\">\n\t<p>\n\t\t<p>\n\t\t\t<sup>\n\t\t\t\tSindre Sorhus' open source work is supported by the community on <a href=\"https://github.com/sponsors/sindresorhus\">GitHub Sponsors</a>\n\t\t\t</sup>\n\t\t</p>\n\t\t<sup>Special thanks to:</sup>\n\t\t<br>\n\t\t<br>\n\t\t<a href=\"https://standardresume.co/tech\">\n\t\t\t<img src=\"https://sindresorhus.com/assets/thanks/standard-resume-logo.svg\" width=\"160\">\n\t\t</a>\n\t\t<br>\n\t\t<br>\n\t\t<a href=\"https://retool.com/?utm_campaign=sindresorhus\">\n\t\t\t<img src=\"https://sindresorhus.com/assets/thanks/retool-logo.svg\" width=\"230\">\n\t\t</a>\n\t\t<br>\n\t\t<br>\n\t\t<a href=\"https://strapi.io/?ref=sindresorhus\">\n\t\t\t<div>\n\t\t\t\t<img src=\"https://sindresorhus.com/assets/thanks/strapi-logo-white-bg.png\" width=\"220\" alt=\"Strapi\">\n\t\t\t</div>\n\t\t\t<b>Strapi is the leading open-source headless CMS.</b>\n\t\t\t<div>\n\t\t\t\t<sup>It’s 100% JavaScript, fully customizable, and developer-first.</sup>\n\t\t\t</div>\n\t\t</a>\n\t\t<br>\n\t\t<br>\n\t\t<a href=\"https://www.stackaid.us/?utm_campaign=sindre\">\n\t\t\t<div>\n\t\t\t\t<img src=\"https://sindresorhus.com/assets/thanks/stackaid-logo.png\" width=\"230\" alt=\"StackAid\">\n\t\t\t</div>\n\t\t\t<b>Fund your open source dependencies</b>\n\t\t</a>\n\t\t<br>\n\t\t<br>\n\t</p>\n</div>\n\n---\n\n<br>\n\n## Highlights\n\n- Expressive API\n- Highly performant\n- No dependencies\n- Ability to nest styles\n- [256/Truecolor color support](#256-and-truecolor-color-support)\n- Auto-detects color support\n- Doesn't extend `String.prototype`\n- Clean and focused\n- Actively maintained\n- [Used by ~86,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 4, 2022\n\n## Install\n\n```sh\nnpm install chalk\n```\n\n**IMPORTANT:** Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now. [Read more.](https://github.com/chalk/chalk/releases/tag/v5.0.0)\n\n## Usage\n\n```js\nimport chalk from 'chalk';\n\nconsole.log(chalk.blue('Hello world!'));\n```\n\nChalk comes with an easy to use composable API where you just chain and nest the styles you want.\n\n```js\nimport chalk from 'chalk';\n\nconst log = console.log;\n\n// Combine styled and normal strings\nlog(chalk.blue('Hello') + ' World' + chalk.red('!'));\n\n// Compose multiple styles using the chainable API\nlog(chalk.blue.bgRed.bold('Hello world!'));\n\n// Pass in multiple arguments\nlog(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));\n\n// Nest styles\nlog(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));\n\n// Nest styles of the same type even (color, underline, background)\nlog(chalk.green(\n\t'I am a green line ' +\n\tchalk.blue.underline.bold('with a blue substring') +\n\t' that becomes green again!'\n));\n\n// ES2015 template literal\nlog(`\nCPU: ${chalk.red('90%')}\nRAM: ${chalk.green('40%')}\nDISK: ${chalk.yellow('70%')}\n`);\n\n// Use RGB colors in terminal emulators that support it.\nlog(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));\nlog(chalk.hex('#DEADED').bold('Bold gray!'));\n```\n\nEasily define your own themes:\n\n```js\nimport chalk from 'chalk';\n\nconst error = chalk.bold.red;\nconst warning = chalk.hex('#FFA500'); // Orange color\n\nconsole.log(error('Error!'));\nconsole.log(warning('Warning!'));\n```\n\nTake advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):\n\n```js\nimport chalk from 'chalk';\n\nconst name = 'Sindre';\nconsole.log(chalk.green('Hello %s'), name);\n//=> 'Hello Sindre'\n```\n\n## API\n\n### chalk.`<style>[.<style>...](string, [string...])`\n\nExample: `chalk.red.bold.underline('Hello', 'world');`\n\nChain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.\n\nMultiple arguments will be separated by space.\n\n### chalk.level\n\nSpecifies the level of color support.\n\nColor support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.\n\nIf you need to change this in a reusable module, create a new instance:\n\n```js\nimport {Chalk} from 'chalk';\n\nconst customChalk = new Chalk({level: 0});\n```\n\n| Level | Description |\n| :---: | :--- |\n| `0` | All colors disabled |\n| `1` | Basic color support (16 colors) |\n| `2` | 256 color support |\n| `3` | Truecolor support (16 million colors) |\n\n### supportsColor\n\nDetect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.\n\nCan be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.\n\nExplicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.\n\n### chalkStderr and supportsColorStderr\n\n`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `supportsColorStderr` is exposed for convenience.\n\n### modifierNames, foregroundColorNames, backgroundColorNames, and colorNames\n\nAll supported style strings are exposed as an array of strings for convenience. `colorNames` is the combination of `foregroundColorNames` and `backgroundColorNames`.\n\nThis can be useful if you wrap Chalk and need to validate input:\n\n```js\nimport {modifierNames, foregroundColorNames} from 'chalk';\n\nconsole.log(modifierNames.includes('bold'));\n//=> true\n\nconsole.log(foregroundColorNames.includes('pink'));\n//=> false\n```\n\n## Styles\n\n### Modifiers\n\n- `reset` - Reset the current style.\n- `bold` - Make the text bold.\n- `dim` - Make the text have lower opacity.\n- `italic` - Make the text italic. *(Not widely supported)*\n- `underline` - Put a horizontal line below the text. *(Not widely supported)*\n- `overline` - Put a horizontal line above the text. *(Not widely supported)*\n- `inverse`- Invert background and foreground colors.\n- `hidden` - Print the text but make it invisible.\n- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*\n- `visible`- Print the text only when Chalk has a color level above zero. Can be useful for things that are purely cosmetic.\n\n### Colors\n\n- `black`\n- `red`\n- `green`\n- `yellow`\n- `blue`\n- `magenta`\n- `cyan`\n- `white`\n- `blackBright` (alias: `gray`, `grey`)\n- `redBright`\n- `greenBright`\n- `yellowBright`\n- `blueBright`\n- `magentaBright`\n- `cyanBright`\n- `whiteBright`\n\n### Background colors\n\n- `bgBlack`\n- `bgRed`\n- `bgGreen`\n- `bgYellow`\n- `bgBlue`\n- `bgMagenta`\n- `bgCyan`\n- `bgWhite`\n- `bgBlackBright` (alias: `bgGray`, `bgGrey`)\n- `bgRedBright`\n- `bgGreenBright`\n- `bgYellowBright`\n- `bgBlueBright`\n- `bgMagentaBright`\n- `bgCyanBright`\n- `bgWhiteBright`\n\n## 256 and Truecolor color support\n\nChalk supports 256 colors and [Truecolor](https://github.com/termstandard/colors) (16 million colors) on supported terminal apps.\n\nColors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).\n\nExamples:\n\n- `chalk.hex('#DEADED').underline('Hello, world!')`\n- `chalk.rgb(15, 100, 204).inverse('Hello!')`\n\nBackground versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `hex` for foreground colors and `bgHex` for background colors).\n\n- `chalk.bgHex('#DEADED').underline('Hello, world!')`\n- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`\n\nThe following color models can be used:\n\n- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`\n- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`\n- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`\n\n## Browser support\n\nSince Chrome 69, ANSI escape codes are natively supported in the developer console.\n\n## Windows\n\nIf you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.\n\n## Origin story\n\n[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.\n\n## Related\n\n- [chalk-template](https://github.com/chalk/chalk-template) - [Tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) support for this module\n- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module\n- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal\n- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color\n- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes\n- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream\n- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes\n- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes\n- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes\n- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes\n- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models\n- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal\n- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings\n- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings\n- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal\n\n## Maintainers\n\n- [Sindre Sorhus](https://github.com/sindresorhus)\n- [Josh Junon](https://github.com/qix-)\n","_attachments":{},"homepage":"https://github.com/chalk/chalk#readme","bugs":{"url":"https://github.com/chalk/chalk/issues"},"license":"MIT"}