{"id":13515604,"url":"https://github.com/ai/nanocolors","last_synced_at":"2025-03-31T05:30:39.419Z","repository":{"id":45848929,"uuid":"408664831","full_name":"ai/nanocolors","owner":"ai","description":"Use picocolors instead. It is 3 times smaller and 50% faster.","archived":true,"fork":false,"pushed_at":"2021-10-09T12:14:47.000Z","size":1847,"stargazers_count":868,"open_issues_count":0,"forks_count":24,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-24T17:54:35.091Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-21T02:32:09.000Z","updated_at":"2024-10-29T21:41:51.000Z","dependencies_parsed_at":"2022-08-06T03:00:18.904Z","dependency_job_id":null,"html_url":"https://github.com/ai/nanocolors","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai%2Fnanocolors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai%2Fnanocolors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai%2Fnanocolors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai%2Fnanocolors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ai","download_url":"https://codeload.github.com/ai/nanocolors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244894323,"owners_count":20527677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T05:01:13.356Z","updated_at":"2025-03-31T05:30:38.953Z","avatar_url":"https://github.com/ai.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# Deprecated\n\n**DEPRECATED:** Use\n**[`picocolors`](https://github.com/alexeyraspopov/picocolors)** instead.\nIt is 3 times smaller and 50% faster.\n\nThe space in node_modules including sub-dependencies:\n\n```diff\n- nanocolors   16 kB\n+ picocolors    7 kB\n```\n\nLibrary loading time:\n\n```diff\n- nanocolors     0.885 ms\n+ picocolors     0.470 ms\n```\n\nBenchmark for complex use cases:\n\n```diff\n- nanocolors     1,088,193 ops/sec\n+ picocolors     1,772,265 ops/sec\n```\n\n## Old docs\n\n\u003cimg align=\"right\" width=\"128\" height=\"120\"\n     src=\"./img/logo.svg\"\n     title=\"Nano Colors logo by Roman Shamin\"\u003e\n\nA tiny and fast Node.js library to ANSI colors to terminal output.\n\n```js\nimport { green, bold } from 'nanocolors'\n\nconsole.log(\n  green(`Task ${bold('1')} was finished`)\n)\n```\n\n\u003eStarted as a fork\n\u003e of [**@jorgebucaran**](https://github.com/jorgebucaran/)’s\n\u003e [`colorette`](https://github.com/jorgebucaran/colorette) with hacks\n\u003e from [**@lukeed**](https://github.com/lukeed/)’s\n\u003e [`kleur`](https://github.com/lukeed/kleur).\n\u003e See [changes](https://github.com/ai/nanocolors/wiki/Colorette-Changes)\n\u003e between Nano Colors and `colorette`.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./img/example.png\" alt=\"Nano Colors output\" width=\"600\"\u003e\n\u003c/p\u003e\n\n\u003ca href=\"https://evilmartians.com/?utm_source=nanocolors\"\u003e\n  \u003cimg src=\"https://evilmartians.com/badges/sponsored-by-evil-martians.svg\"\n       alt=\"Sponsored by Evil Martians\" width=\"236\" height=\"54\"\u003e\n\u003c/a\u003e\n\n[ESM]: https://github.com/ai/nanocolors/blob/main/index.js\n[CJS]: https://github.com/ai/nanocolors/blob/main/index.cjs\n\n\n## Replacing `chalk`\n\n1. Replace import and use named exports:\n\n   ```diff\n   - import chalk from 'chalk'\n   + import { red, bold } from 'nanocolors'\n   ```\n\n2. Unprefix calls:\n\n   ```diff\n   - chalk.red(text)\n   + red(text)\n   ```\n\n3. Replace chains to nested calls:\n\n   ```diff\n   - chalk.red.bold(text)\n   + red(bold(text))\n   ```\n\n4. If you used template tag, then use\n   the [`nanocolors-template`](https://github.com/usmanyunusov/nanocolors-template):\n\n   ```diff\n   - import chalk from 'chalk'\n   + import { colorize } from 'nanocolors-template'\n\n   - chalk.yellow.bold`yellow {red ${\"text\"}}`\n   + colorize`{yellow.bold yellow {red ${\"text\"}}}`\n   ```\n\nAbove changes can be applied automatically using\n[codemod](https://gist.github.com/gavrix/ff051941ad9a19c8ea3224f38c30bc9a):\n\n```sh\nnpx jscodeshift FILES -t https://gist.githubusercontent.com/gavrix/ff051941ad9a19c8ea3224f38c30bc9a/raw/09d81e93f880ecbc8f52dcf7819816c81e2ba340/chalk_nanocolors_transform.js\n```\n\n## API\n\n### Individual Colors\n\nNano Colors exports functions:\n\n| Colors    | Background Colors   | Modifiers         |\n| --------- | ------------------- | ----------------- |\n| `black`   | `bgBlack`           | dim               |\n| `red`     | `bgRed`             | **bold**          |\n| `green`   | `bgGreen`           | hidden            |\n| `yellow`  | `bgYellow`          | _italic_          |\n| `blue`    | `bgBlue`            | \u003cu\u003eunderline\u003c/u\u003e  |\n| `magenta` | `bgMagenta`         | ~~strikethrough~~ |\n| `cyan`    | `bgCyan`            | reset             |\n| `white`   | `bgWhite`           |                   |\n| `gray`    |                     |                   |\n\nFunctions are not chainable. You need to wrap it inside each other:\n\n```js\nimport { black, bgYellow } from 'nanocolors'\n\nconsole.log(bgYellow(black(' WARN ')))\n```\n\nFunctions will use colors only if Nano Colors auto-detect that current\nenvironment supports colors.\n\nYou can get support level in `isColorSupported`:\n\n```js\nimport { isColorSupported } from 'nanocolors'\n\nif (isColorSupported) {\n  console.log('With colors')\n}\n```\n\n\n### Conditional Support\n\nYou can manually switch colors on/off and override color support auto-detection:\n\n```js\nimport { createColors } from 'nanocolors'\n\nconst { red } = createColors(options.enableColors)\n```\n\nOn `undefined` argument, `createColors` will use value\nfrom color support auto-detection.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fai%2Fnanocolors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fai%2Fnanocolors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fai%2Fnanocolors/lists"}