{"_id":"@3rd/picocolors","name":"@3rd/picocolors","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@3rd/picocolors","version":"0.0.1","description":"The tiniest and the fastest library for terminal output formatting with ANSI colors","keywords":["terminal","colors","formatting","cli","console"],"type":"module","types":"index.d.ts","main":"index.js","license":"ISC","module":"index.js","exports":{".":{"import":{"types":"./index.d.ts","default":"./index.js"},"require":{"types":"./index.d.ts","default":"./index.cjs"}}},"publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"_id":"@3rd/picocolors@0.0.1","gitHead":"2ec8fb5421cb76a9580ca266923a78bc8cae7dbc","_nodeVersion":"20.9.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-TvpF7RdbPxvVHPw3Qj9rVPMSNqTduXhJzjd8uck5W39C2td39bs7hbF2EWWbYwktFN1QcMuAPAjqbl2d2P0BFQ==","shasum":"55c428d4d947e2cebaa93e693f7a6dbd8ee23a1f","tarball":"https://registry.npmjs.org/@3rd/picocolors/-/picocolors-0.0.1.tgz","fileCount":5,"unpackedSize":9915,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHCMa/kNybE6Nw4Swc+2D0wHg29qoEd0sztR5dwlyuTcAiAIMkAvldqjymA0MKZXRcODd0OMjNOlmuQPd3Sd51XxNw=="}]},"_npmUser":{"name":"scriptpower","email":"scriptpower@qq.com"},"directories":{},"maintainers":[{"name":"scriptpower","email":"scriptpower@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/picocolors_0.0.1_1700984246831_0.34340463510418284"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-26T07:37:26.738Z","0.0.1":"2023-11-26T07:37:27.030Z","modified":"2023-11-26T07:37:27.381Z"},"maintainers":[{"name":"scriptpower","email":"scriptpower@qq.com"}],"description":"The tiniest and the fastest library for terminal output formatting with ANSI colors","keywords":["terminal","colors","formatting","cli","console"],"license":"ISC","readme":"# @3rd/picocolors\n\nThe tiniest and the fastest library for terminal output formatting with ANSI colors.\n\n```javascript\nimport { colors as pc } from \"@3rd/picocolors\"\n\nconsole.log(\n  pc.green(`How are ${pc.italic(`you`)} doing?`)\n)\n```\n\n## Motivation\n\nWith `@3rd/picocolors` we are trying to draw attention to the `node_modules` size\nproblem and promote performance-first culture.\n\n## Prior Art\n\nCredits go to the following projects:\n\n- [Nanocolors](https://github.com/ai/nanocolors) by [@ai](https://github.com/ai)\n- [Colorette](https://github.com/jorgebucaran/colorette) by [@jorgebucaran](https://github.com/jorgebucaran)\n- [Kleur](https://github.com/lukeed/kleur) by [@lukeed](https://github.com/lukeed)\n- [Colors.js](https://github.com/Marak/colors.js) by [@Marak](https://github.com/Marak)\n- [Chalk](https://github.com/chalk/chalk) by [@sindresorhus](https://github.com/sindresorhus)\n\n## Benchmarks\n\nThe space in node_modules including sub-dependencies:\n\n```diff\n$ node ./benchmarks/size.js\nData from packagephobia.com\n  chalk       101 kB\n  cli-color  1249 kB\n  ansi-colors  25 kB\n  kleur        21 kB\n  colorette    17 kB\n  nanocolors   16 kB\n+ picocolors    7 kB\n```\n\nLibrary loading time:\n\n```diff\n$ node ./benchmarks/loading.js\n  chalk          6.167 ms\n  cli-color     31.431 ms\n  ansi-colors    1.585 ms\n  kleur          2.008 ms\n  kleur/colors   0.773 ms\n  colorette      2.476 ms\n  nanocolors     0.833 ms\n+ picocolors     0.466 ms\n```\n\nBenchmark for simple use case:\n\n```diff\n$ node ./benchmarks/simple.js\n  chalk         24,066,342 ops/sec\n  cli-color        938,700 ops/sec\n  ansi-colors    4,532,542 ops/sec\n  kleur         20,343,122 ops/sec\n  kleur/colors  35,415,770 ops/sec\n  colorette     34,244,834 ops/sec\n  nanocolors    33,443,265 ops/sec\n+ picocolors    33,271,645 ops/sec\n```\n\nBenchmark for complex use cases:\n\n```diff\n$ node ./benchmarks/complex.js\n  chalk            969,915 ops/sec\n  cli-color        131,639 ops/sec\n  ansi-colors      342,250 ops/sec\n  kleur            611,880 ops/sec\n  kleur/colors   1,129,526 ops/sec\n  colorette      1,747,277 ops/sec\n  nanocolors     1,251,312 ops/sec\n+ picocolors     2,024,086 ops/sec\n```\n\n## Usage\n\nPicocolors provides an object which includes a variety of text coloring and formatting functions\n\n```javascript\nimport {colors as pc} from \"@3rd/picocolors\"\n```\n\nThe object includes following coloring functions: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`.\n\n```javascript\nconsole.log(`I see a ${pc.red(\"red door\")} and I want it painted ${pc.black(\"black\")}`)\n```\n\nThe object also includes following background color modifier functions: `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite`.\n\n```javascript\nconsole.log(\n  pc.bgBlack(\n    pc.white(`Tom appeared on the sidewalk with a bucket of whitewash and a long-handled brush.`)\n  )\n)\n```\n\nBesides colors, the object includes following formatting functions: `dim`, `bold`, `hidden`, `italic`, `underline`, `strikethrough`, `reset`, `inverse`.\n\n```javascript\nfor (let task of tasks) {\n  console.log(`${pc.bold(task.name)} ${pc.dim(task.durationMs + \"ms\")}`)\n}\n```\n\nThe library provides additional utilities to ensure the best results for the task:\n\n- `isColorSupported` — boolean, explicitly tells whether or not the colors or formatting appear on the screen\n\n  ```javascript\n  import { colors as pc } from \"@3rd/picocolors\"\n\n  if (pc.isColorSupported) {\n    console.log(\"Yay! This script can use colors and formatters\")\n  }\n  ```\n\n- `createColors(enabled)` — a function that returns a new API object with manually defined color support configuration\n\n  ```javascript\n  import { colors as pc } from \"@3rd/picocolors\"\n\n  let { red, bgWhite } = pc.createColors(options.enableColors)\n  ```\n\n## Replacing `chalk`\n\n1. Replace package name in import:\n\n   ```diff\n   - import chalk from 'chalk'\n   + import {colors as pc} from '@3rd/picocolors'\n   ```\n\n2. Replace variable:\n\n   ```diff\n   - chalk.red(text)\n   + pc.red(text)\n   ```\n\n3. Replace chains to nested calls:\n\n   ```diff\n   - chalk.red.bold(text)\n   + pc.red(pc.bold(text))\n   ```\n\n4. You can use [`colorize-template`](https://github.com/usmanyunusov/colorize-template)\n   to replace chalk’s tagged template literal.\n\n   ```diff\n   + import { createColorize } from 'colorize-template'\n\n   + let colorize = createColorize(pc)\n   - chalk.red.bold`full {yellow ${\"text\"}}`\n   + colorize`{red.bold full {yellow ${\"text\"}}}`\n   ```\n","readmeFilename":"README.md"}