{"id":24774220,"url":"https://github.com/flex-development/colors","last_synced_at":"2025-04-09T20:33:39.647Z","repository":{"id":274250301,"uuid":"922311997","full_name":"flex-development/colors","owner":"flex-development","description":":rainbow: a small library for coloring and styling messages","archived":false,"fork":false,"pushed_at":"2025-04-07T11:33:41.000Z","size":2566,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T11:36:36.481Z","etag":null,"topics":["ansi","browser","cli","color","console","node","terminal"],"latest_commit_sha":null,"homepage":"https://github.com/flex-development/colors","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flex-development.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["flex-development"]}},"created_at":"2025-01-25T21:34:23.000Z","updated_at":"2025-04-07T10:59:54.000Z","dependencies_parsed_at":"2025-01-26T02:29:59.669Z","dependency_job_id":"c5f2e2fc-aaea-412c-bd30-ba8cf62cd4fc","html_url":"https://github.com/flex-development/colors","commit_stats":null,"previous_names":["flex-development/colors"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fcolors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fcolors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fcolors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fcolors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flex-development","download_url":"https://codeload.github.com/flex-development/colors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107835,"owners_count":21049015,"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":["ansi","browser","cli","color","console","node","terminal"],"created_at":"2025-01-29T05:35:56.033Z","updated_at":"2025-04-09T20:33:39.628Z","avatar_url":"https://github.com/flex-development.png","language":"TypeScript","funding_links":["https://github.com/sponsors/flex-development"],"categories":[],"sub_categories":[],"readme":"# \\:rainbow: colors\n\n[![github release](https://img.shields.io/github/v/release/flex-development/colors.svg?include_prereleases\\\u0026sort=semver)](https://github.com/flex-development/colors/releases/latest)\n[![npm](https://img.shields.io/npm/v/@flex-development/colors.svg)](https://npmjs.com/package/@flex-development/colors)\n[![codecov](https://codecov.io/github/flex-development/colors/graph/badge.svg?token=n4qiZ2g5nb)](https://codecov.io/github/flex-development/colors)\n[![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)\n[![license](https://img.shields.io/github/license/flex-development/colors.svg)](LICENSE.md)\n[![conventional commits](https://img.shields.io/badge/-conventional%20commits-fe5196?logo=conventional-commits\\\u0026logoColor=ffffff)](https://conventionalcommits.org)\n[![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript\\\u0026logoColor=ffffff)](https://typescriptlang.org)\n[![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat\\\u0026logo=vitest\\\u0026logoColor=ffffff)](https://vitest.dev)\n[![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat\\\u0026logo=yarn\\\u0026logoColor=ffffff)](https://yarnpkg.com)\n\nColorize messages in the terminal and browser\n\n## Contents\n\n- [What is this?](#what-is-this)\n  - [Features](#features)\n- [Install](#install)\n- [Use](#use)\n- [API](#api)\n  - [`colors`](#colors)\n  - [`createColors([options])`](#createcolorsoptions)\n  - [`isColorSupported`](#iscolorsupported)\n  - [`stripAnsi(value[, toString])`](#stripansivalue-tostring)\n- [Types](#types)\n  - [`ColorConfig`](#colorconfig)\n  - [`ColorConfigs`](#colorconfigs)\n  - [`ColorFunction`](#colorfunction)\n  - [`ColorFunctions`](#colorfunctions)\n  - [`Color`](#color)\n  - [`ColorizerOptions`](#colorizeroptions)\n  - [`Colors`](#colors-1)\n  - [`ToString`](#tostring)\n- [Contribute](#contribute)\n\n## What is this?\n\nThis is a small, but useful, library for creating colorful messages in the terminal and browser consoles that\nsupport ANSI colors.\n\n### Features\n\n- `FORCE_COLOR`, [`NO_COLOR`][no-color], and `NODE_DISABLE_COLORS` friendly\n- automatic color support detection\n- no dependencies\n- [typescript][] support\n\n## Install\n\nThis package is [ESM only][esm].\n\nIn Node.js with [yarn][]:\n\n```sh\nyarn add @flex-development/colors\n```\n\n\u003cblockquote\u003e\n  \u003csmall\u003e\n    See \u003ca href='https://yarnpkg.com/protocol/git'\u003eGit - Protocols | Yarn\u003c/a\u003e\n    \u0026nbsp;for details regarding installing from Git.\n  \u003c/small\u003e\n\u003c/blockquote\u003e\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```ts\nimport { colors } from 'https://esm.sh/@flex-development/colors'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { createColors } from 'https://esm.sh/@flex-development/colors'\n\u003c/script\u003e\n```\n\n## Use\n\n```ts\nimport c from '@flex-development/colors'\n\nconsole.log(c.red(c.bold('Hello World!')))\n```\n\n## API\n\nThis package exports the following identifiers:\n\n- [`colors`](#colors)\n- [`createColors`](#createcolorsoptions)\n- [`isColorSupported`](#iscolorsupported)\n- [`stripAnsi`](#stripansivalue-tostring)\n\nThe default export is [`colors`](#colors).\n\n### `colors`\n\n([`Colors`](#colors-1)) The default colorizer.\n\n### `createColors([options])`\n\nCreate a colorizer.\n\n#### Parameters\n\n- `options` ([`ColorizerOptions`](#colorizeroptions) | `boolean`, optional) —\n  boolean indicating if color output should be enabled, or an options object to create a custom colorizer\n  - **default**: [`isColorSupported()`](#iscolorsupported)\n\n#### Returns\n\n([`Colors`](#colors-1)) Colorizer object\n\n### `isColorSupported`\n\nCheck if color output is supported.\n\n#### Returns\n\n(`boolean`) `true` if color output is supported, `false` otherwise\n\n### `stripAnsi(value[, toString])`\n\nRemove ANSI escape codes from `value`.\n\n#### Parameters\n\n- `value` (`unknown`) — the string or value to remove escape codes from\n- `toString` ([`ToString`](#tostring), optional) — convert `value` to a string\n  - **default**: `String`\n\n#### Returns\n\n(`string`) Stringified `value` with ANSI escape codes removed\n\n## Types\n\nThis package is fully typed with [TypeScript][].\n\n### `ColorConfig`\n\nList, where the first value is the numeric code for an ANSI escape sequence, and the second is the numeric code for the\nreset sequence. The last value is an optional replacement for the reset sequence (used in complex cases to nest styles\nwithout breaking existing color sequences).\n\n```ts\ntype ColorConfig = [\n  open: number,\n  close: number,\n  replace?: string | null | undefined\n]\n```\n\n### `ColorConfigs`\n\nRecord, where each key is a [`Color`](#color) and each value is the configuration for a color function.\n\n```ts\ntype ColorConfigs = Record\u003cColor, ColorConfig\u003e\n```\n\n### `ColorFunction`\n\nColorize `value` (TypeScript interface).\n\n#### Parameters\n\n- `value` (`unknown`) — the thing to colorize\n\n#### Properties\n\n- `close` (`string`) — reset sequence\n- `open` (`string`) — sequence used to set colors\n- `replace` (`string`, optional) — reset sequence replacement\n\n#### Returns\n\n(`string`) Colorized string `value`\n\n### `ColorFunctions`\n\nRegistry of color functions (TypeScript interface).\n\n### `Color`\n\nUnion of color names.\n\n```ts\ntype Color = keyof ColorFunctions\n```\n\nTo register custom colors, augment [`ColorFunctions`](#colorfunctions). They will be added to this union automatically.\n\n```ts\ndeclare module '@flex-development/colors' {\n interface ColorFunctions {\n   blink: ColorFunction\n }\n}\n```\n\n### `ColorizerOptions`\n\nOptions for creating a colorizer (TypeScript interface).\n\n#### Properties\n\n- `color` (`boolean`, optional) — color output enabled?\n- `colors` ([`Partial\u003cColorConfigs\u003e`](#colorconfigs), optional) — color function config map\n\n### `Colors`\n\n\u003e also exported as `Colorizer`\n\nA colorizer (TypeScript interface).\n\nColorizers contain [`Color`](#color) functions. Each function corresponds to a terminal color or style. The `color`\nproperty is an accessor that can be used to disable or enable color output.\n\n#### Extends\n\n- [`ColorFunctions`](#colorfunctions)\n\n#### Properties\n\n- `get color(): boolean` — color output enabled?\n- `set color(color: boolean | null | undefined)` - enable or disable color output\\\n  👉 **note**: color output will be disabled if not supported\n- `supported` (`boolean`) — color output supported? (`readonly`)\n\n### `ToString`\n\nConvert `value` to a string (TypeScript type).\n\n#### Parameters\n\n- `value` (`unknown`) — the thing to stringify\n\n#### Returns\n\n(`string`) Stringified `value`\n\n## Contribute\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md).\n\nThis project has a [code of conduct](./CODE_OF_CONDUCT.md). By interacting with this repository, organization, or\ncommunity you agree to abide by its terms.\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[no-color]: https://no-color.org\n\n[typescript]: https://www.typescriptlang.org\n\n[yarn]: https://yarnpkg.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Fcolors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflex-development%2Fcolors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Fcolors/lists"}