{"id":16556306,"url":"https://github.com/miraclx/stringd-colors","last_synced_at":"2025-10-28T20:30:24.798Z","repository":{"id":43040543,"uuid":"171755942","full_name":"miraclx/stringd-colors","owner":"miraclx","description":"ANSI colors for stringd formatting","archived":false,"fork":false,"pushed_at":"2022-07-06T06:25:00.000Z","size":482,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-14T11:43:52.930Z","etag":null,"topics":["ansi","colors","format","formatting","output","parser","print","printf","string","stringd"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miraclx.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-02-20T22:00:14.000Z","updated_at":"2023-03-07T16:45:41.000Z","dependencies_parsed_at":"2022-09-16T11:50:23.008Z","dependency_job_id":null,"html_url":"https://github.com/miraclx/stringd-colors","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miraclx%2Fstringd-colors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miraclx%2Fstringd-colors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miraclx%2Fstringd-colors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miraclx%2Fstringd-colors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miraclx","download_url":"https://codeload.github.com/miraclx/stringd-colors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219858902,"owners_count":16556039,"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","colors","format","formatting","output","parser","print","printf","string","stringd"],"created_at":"2024-10-11T20:04:09.112Z","updated_at":"2025-10-28T20:30:22.425Z","avatar_url":"https://github.com/miraclx.png","language":"JavaScript","readme":"# stringd-colors\n\n\u003e Extends a [stringd][stringd] object with [ansi styles][ansi-styles]\n\n## Features\n\n- Supports [stringd][stringd] parsing functionality\n- Extends any object with styles defined [here](#styles)\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n\n[![NPM][npm-image-url]][npm-url]\n\n## Installing\n\nVia [NPM][npm]:\n\n``` bash\nnpm install stringd-colors\n```\n\n## Usage\n\n``` javascript\nimport cStringd from 'stringd-colors';\n\ncStringd(\n  ':{bgcolor(green)}:{color(red)}:{greeting}:{color:close(red)}:{bgcolor:close(green)}',\n  { greeting: 'Hello, World' }\n);\n```\n\n### Result\n\n![StringD Colors][stringd-result]\n\n## API\n\n### cStringd(template[, objects])\n\n- `template`: \u0026lt;[string][]\u0026gt;\n- `objects`: \u0026lt;[object][]\u0026gt;\n- Returns: \u0026lt;[string][]\u0026gt;\n\nParse the `template` with the colors in [cStringd.raw](#cstringdraw) and variables in `objects` if provided\n\n``` javascript\ncStringd(':{color(green)}Hi There:{color:close(green)}');\n// '\\u001b[32mHi There\\u001b[39m'\n```\n\n### cStringd.extend([objects])\n\n- `objects`: \u0026lt;[object][]\u0026gt;\n- Returns: \u0026lt;[string][]\u0026gt;\n\nReturn an extension of `object` with [cStringd.raw](#cstringdraw), hence appending the ansi colors to the `object`, the absence of `object` would return [cStringd.raw](#cstringdraw)\n\n``` javascript\nconst stringd = require('stringd');\nconst cStringd = require('stringd-colors');\nstringd(':{color(green)}:{name}:{color:close(green)}', cStringd.extend({name: 'Jon Bellion'}));\n// '\\u001b[32mJon Bellion\\u001b[39m'\n```\n\n### cStringd.raw\n\nAn object for stringd parsing of ansi styles defined [here](#styles)\n\n## Handles\n\n### `color`\n\nThis handle, without a specific style specification, selects a random foreground color or modifier.\n\n``` text\n\":{color}\" // Random color\n\":{color(red)}\" // Specifically the color red\n\":{color(underline)}\" // Underline\n\":{color(green, bold)}\" // Green foreground and underline\n```\n\n### `color:close`\n\nThis handle, without a specific style specification, defaults to closing all foreground colors\n\n``` text\n\":{color:close}\" // Close foreground colors\n\":{color:close(yellow)}\" // Close the active yellow style\n\":{color:close(hidden)}\" // Close the hidden modifier\n```\n\n### `bgcolor`\n\nThis handle, without a specific style specification, selects a random background color or modifier.\n\n``` text\n\":{bgcolor}\" // Random background color\n\":{bgcolor(cyan)}\" // Specifically the color cyan\n\":{bgcolor(bold)}\" // bold\n\":{bgcolor(yellow, underline)}\" // Yellow background and underline\n```\n\n### `bgcolor:close`\n\nThis handle, without a specific style specification, defaults to closing all background colors\n\n``` text\n\":{bgcolor:close}\" // Close background colors\n\":{bgcolor:close(magenta)}\" // Close the active magenta style\n\":{bgcolor:close(strikethrough)}\" // Close the strikethrough modifier\n```\n\n### `color:reset`\n\nThis special handle, closes all ANSI manipulations.\n\n## Styles\n\nANSI style documentation [here][ansi-styles]\n\n### Modifiers\n\n- `color(bold)`\n- `color(dim)`\n- `color(italic)`\n- `color(underline)`\n- `color(inverse)`\n- `color(hidden)`\n- `color(strikethrough)`\n- `color(visible)`\n\nModifiers are also accessible on `bgcolor:`\n\n### Colors\n\n- `color(black)`\n- `color(red)`\n- `color(green)`\n- `color(yellow)`\n- `color(blue)`\n- `color(magenta)`\n- `color(cyan)`\n- `color(white)`\n- `color(gray)`\n- `color(redBright)`\n- `color(greenBright)`\n- `color(yellowBright)`\n- `color(blueBright)`\n- `color(magentaBright)`\n- `color(cyanBright)`\n- `color(whiteBright)`\n\n### Background colors\n\n- `bgcolor(black)`\n- `bgcolor(red)`\n- `bgcolor(green)`\n- `bgcolor(yellow)`\n- `bgcolor(blue)`\n- `bgcolor(magenta)`\n- `bgcolor(cyan)`\n- `bgcolor(white)`\n- `bgcolor(blackBright)`\n- `bgcolor(redBright)`\n- `bgcolor(greenBright)`\n- `bgcolor(yellowBright)`\n- `bgcolor(blueBright)`\n- `bgcolor(magentaBright)`\n- `bgcolor(cyanBright)`\n- `bgcolor(whiteBright)`\n\n## Development\n\n### Building\n\nFeel free to clone, use in adherance to the [license](#license). Pull requests are very much welcome.\n\n``` bash\ngit clone https://github.com/miraclx/stringd-colors.git\ncd stringd-colors\nnpm install\n# hack on code\nnpm test\n```\n\n### Testing\n\nTests are executed with [Jest][jest]. To use it, simple run `npm install`, it will install\nJest and its dependencies in your project's `node_modules` directory followed by `npm test`.\n\nTo run the tests:\n\n``` bash\nnpm install\nnpm test\n```\n\n## License\n\n[Apache 2.0][license] © **Miraculous Owonubi** ([@miraclx][author-url]) \u0026lt;omiraculous@gmail.com\u0026gt;\n\n[npm]:  https://github.com/npm/cli \"The Node Package Manager\"\n[jest]:  https://github.com/facebook/jest \"Delightful JavaScript Testing\"\n[license]:  LICENSE \"Apache 2.0 License\"\n[stringd]:  https://github.com/miraclx/stringd \"NodeJS String Variable Parser\"\n[author-url]: https://github.com/miraclx\n[ansi-styles]:  https://github.com/chalk/ansi-styles \"ANSI escape codes for styling strings in the terminal\"\n[stringd-result]: https://raw.githubusercontent.com/miraclx/stringd-colors/master/screenshots/colors.png \"StringD Colors Example\"\n\n[npm-url]: https://npmjs.org/package/stringd-colors\n[npm-image]: https://badgen.net/npm/node/stringd-colors\n[npm-image-url]: https://nodei.co/npm/stringd-colors.png?stars\u0026downloads\n[downloads-url]: https://npmjs.org/package/stringd-colors\n[downloads-image]: https://badgen.net/npm/dm/stringd-colors\n\n[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\n[object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiraclx%2Fstringd-colors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiraclx%2Fstringd-colors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiraclx%2Fstringd-colors/lists"}