{"id":29395161,"url":"https://github.com/ThreeLetters/StyleMe","last_synced_at":"2025-07-10T11:15:04.825Z","repository":{"id":57373726,"uuid":"66398524","full_name":"ThreeLetters/StyleMe","owner":"ThreeLetters","description":"Print to the console in style. An utility that allows you to print colors to NodeJS console.","archived":false,"fork":false,"pushed_at":"2021-10-08T05:06:32.000Z","size":112,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-29T17:49:40.677Z","etag":null,"topics":["color","nodejs","npm-package","style"],"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/ThreeLetters.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":"2016-08-23T19:55:44.000Z","updated_at":"2022-09-17T07:06:09.000Z","dependencies_parsed_at":"2022-09-11T07:12:43.201Z","dependency_job_id":null,"html_url":"https://github.com/ThreeLetters/StyleMe","commit_stats":null,"previous_names":["ajs-development/styleme"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ThreeLetters/StyleMe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeLetters%2FStyleMe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeLetters%2FStyleMe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeLetters%2FStyleMe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeLetters%2FStyleMe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThreeLetters","download_url":"https://codeload.github.com/ThreeLetters/StyleMe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeLetters%2FStyleMe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264569514,"owners_count":23629607,"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":["color","nodejs","npm-package","style"],"created_at":"2025-07-10T11:15:03.757Z","updated_at":"2025-07-10T11:15:04.816Z","avatar_url":"https://github.com/ThreeLetters.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM](https://img.shields.io/badge/Module-Npm-blue.svg)](https://www.npmjs.com/package/styleme)\n![styleme](https://cloud.githubusercontent.com/assets/13282284/23569635/392200ec-002e-11e7-9fd8-28ba768fcca4.png)\n\nPrint to the console in style.\n\n## Installation\n\n\u003e npm install styleme@3\n\n## Usage\n\n```js\nconst StyleMe = require('styleme')\n\n// It is recommended to extend the `String` prototype methods for convenience.\nStyleMe.extend()\n```\n\nThere are four methods to use this module\n\n### 1. Chaining properties/methods\n\n```js\nconsole.log(StyleMe.red(\"a string\"))\nconsole.log(StyleMe.red.bgBlue(\"another string\"))\n```\n\n### 2. The StyleMe Method\n\n```js\nconsole.log(StyleMe.styleMe(\"some text\",\"red,bgBlue\")) // red text with blue background\nconsole.log(StyleMe.styleMe(\"same text\",[\"red\", \"bgBlue\"])) // also red text with blue background\n```\n\n### 3. The Inline StyleMe Method\n\n```js\nconsole.log(StyleMe.styleMe(\"This is normal [red]{this is red [blue]{this is blue} back to red}\"))\nconsole.log(StyleMe.styleMe(\"[blue,bgRed]{This is blue with a red background}\"))\n```\n\n### 4. `String.prototype` extensions\n\n```js\n// Chaining\nconsole.log(\"a string\".red())\nconsole.log(\"another string\".red().bgBlue())\n\n// StyleMe\nconsole.log(\"some text\".styleMe(\"red,bgBlue\"))\n\n// Inline StyleMe\nconsole.log(\"This is normal [red]{this is red [blue]{this is blue} back to red}\".styleMe())\n```\n\n## Color Codes\n\nThese color codes are available for use:\n\n| Color Code    |\n| :------------ |\n| reset         |\n| bright        |\n| dim           |\n| underline     |\n| strikethrough |\n| blink         |\n| reverse       |\n| hidden        |\n| black         |\n| red           |\n| green         |\n| yellow        |\n| blue          |\n| magenta       |\n| cyan          |\n| white         |\n| bgBlack       |\n| bgRed         |\n| bgGreen       |\n| bgYellow      |\n| bgBlue        |\n| bgMagenta     |\n| bgCyan        |\n| bgWhite       |\n| clear         |\n\nSpecial Codes (from [Colors.js](https://github.com/Marak/colors.js)) are also supported\n\n| Stye Code   |\n| :---------- |\n| america     |\n| rainbow     |\n| random      |\n| blacknwhite |\n\n## Adding Colors\n\n### StyleMe.addStyle(code, style)\n\nYou can add your own colors using this function. Example:\n\n```js\nStyleMe.addStyle(\"lol\",\"\\x1b[5m\");\n```\n\n## Adding Special Styles\n\n### StyleMe.addSpecial(code,function)\n\nYou can add your own special styles using this function. Example:\n\n```js\nStyleMe.addStyle(\"rednblue\", (char, index, colors) =\u003e { // colors =\u003e a object where you can get colors without using ansi codes\n    switch (index % 2) { // Red and blue inverse pattern\n        case 0:\n            return colors.bgBlue + colors.red + char;\n        case 1:\n            return colors.bgRed + colors.blue + char\n    }\n});\n```\n\nPlease note that you cannot use `colors[index]`. You must use `colors.colorcode` instead\n\n## Adding Themes\n\nThemes allow you to use multiple colors/aliases at the same.\n\n```js\n// Set the theme\nStyleMe.setTheme({\n    rnb: [\"red\", \"bgBlue\"], // red and blue background\n    ynr: [\"yellow\", \"bgMagenta\"], // yellow and magenta background\n})\n\n// Can use it now!\nconsole.log(StyleMe.rnb(\"test\"))\n```\n\n# API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### Table of Contents\n\n*   [StyleMe](#styleme)\n    *   [style](#style)\n        *   [Parameters](#parameters)\n    *   [styleInline](#styleinline)\n        *   [Parameters](#parameters-1)\n    *   [styleMe](#styleme-1)\n        *   [Parameters](#parameters-2)\n    *   [extend](#extend)\n    *   [flattenStyle](#flattenstyle)\n        *   [Parameters](#parameters-3)\n    *   [addStyle](#addstyle)\n        *   [Parameters](#parameters-4)\n    *   [setTheme](#settheme)\n        *   [Parameters](#parameters-5)\n*   [code](#code)\n*   [styleMe](#styleme-2)\n    *   [Parameters](#parameters-6)\n*   [styleCode](#stylecode)\n*   [SpecialStyleFn](#specialstylefn)\n    *   [Parameters](#parameters-7)\n*   [recursiveProxy](#recursiveproxy)\n    *   [Parameters](#parameters-8)\n*   [Styles](#styles)\n\n## StyleMe\n\n[src/StyleMe.js:10-303](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L10-L303 \"Source code on GitHub\")\n\nStyleMe\n\nStatic class that is used to easily add colors to console outputs.\n\n### style\n\n[src/StyleMe.js:19-53](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L19-L53 \"Source code on GitHub\")\n\nStyles the given string according to the given style codes.\n\n#### Parameters\n\n*   `str` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** String to style\n*   `styleCodes` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** Comma seperated list (or array) of style codes.\n\n\u003c!----\u003e\n\n*   Throws **any** Will throw error if an invalid style code is provided.\n\nReturns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Styled output\n\n### styleInline\n\n[src/StyleMe.js:62-177](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L62-L177 \"Source code on GitHub\")\n\nStyles a string with inline style markers\n\n#### Parameters\n\n*   `str` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** String to style with inline style markers\n\n\u003c!----\u003e\n\n*   Throws **any** Will give error if braces are mismatched.\n\nReturns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Returns the styled string\n\n### styleMe\n\n[src/StyleMe.js:187-193](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L187-L193 \"Source code on GitHub\")\n\nStyles the given string according to the given style codes if given and uses inline style markers otherwise.\n\n#### Parameters\n\n*   `str` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** String to style\n*   `styleCodes` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))?** Optional comma seperated list (or array) of style codes.\n\n\u003c!----\u003e\n\n*   Throws **any** Will throw error if an invalid style code is provided or if braces are mismatched.\n\nReturns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Styled output\n\n### extend\n\n[src/StyleMe.js:198-223](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L198-L223 \"Source code on GitHub\")\n\nExtends String.prototype with helper methods that can be used to easily style a string\n\n### flattenStyle\n\n[src/StyleMe.js:232-256](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L232-L256 \"Source code on GitHub\")\n\nFlattens an array style into a single array\n\n#### Parameters\n\n*   `style` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) | [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function))** \n*   `arr` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)?** \n\n\u003c!----\u003e\n\n*   Throws **any** Error if style code not found or if invalid\n\nReturns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Flattened array\n\n### addStyle\n\n[src/StyleMe.js:272-292](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L272-L292 \"Source code on GitHub\")\n\nAdds a style\n\n#### Parameters\n\n*   `styleCode` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** style code string (alphabetical string, no spaces)\n*   `style` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [SpecialStyleFn](#specialstylefn))** Style string or function\n\n### setTheme\n\n[src/StyleMe.js:298-302](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L298-L302 \"Source code on GitHub\")\n\nSets a theme\n\n#### Parameters\n\n*   `theme` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** \n\n## code\n\n[src/StyleMe.js:207-209](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L207-L209 \"Source code on GitHub\")\n\nStyles the string according to the method's code\n\nReturns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n## styleMe\n\n[src/StyleMe.js:220-222](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L220-L222 \"Source code on GitHub\")\n\nStyles the string according to the given style codes if given and uses inline style markers otherwise.\n\n### Parameters\n\n*   `styleCodes` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))?** \n\n\u003c!----\u003e\n\n*   Throws **any** Will throw error if an invalid style code is provided or if braces are mismatched.\n\nReturns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Styled string\n\n## styleCode\n\n[src/StyleMe.js:288-290](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L288-L290 \"Source code on GitHub\")\n\nStyles the string according to the method's code\n\nReturns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n## SpecialStyleFn\n\n[src/StyleMe.js:272-292](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L258-L265 \"Source code on GitHub\")\n\nA function that adds styling to individual characters\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n### Parameters\n\n*   `char` **char** Character involved\n*   `index` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Index of the character\n*   `styles` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the styles as properties.\n\nReturns **any** Should return the styled character.\n\n## recursiveProxy\n\n[src/StyleMe.js:311-328](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/src/StyleMe.js#L311-L328 \"Source code on GitHub\")\n\nWraps objects with a Proxy for code chaining\n\n### Parameters\n\n*   `target` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** \n*   `styles` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** \n\n## Styles\n\n[styles/Styles.js:6-36](https://andrews54757@github.com/ThreeLetters/StyleMe/blob/c24e7e14a2cb00d2f742a91331117b517c8e0285/styles/Styles.js#L6-L36 \"Source code on GitHub\")\n\nThe colors/styles defined. ASCII codes reference: \u003chttps://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797\u003e\n\nCan be a string or function.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThreeLetters%2FStyleMe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FThreeLetters%2FStyleMe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThreeLetters%2FStyleMe/lists"}