{"_id":"@aspectron/colors.ts","_rev":"1-69cb166e5cabe3c7d30bf5c9ddb3392d","name":"@aspectron/colors.ts","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@aspectron/colors.ts","version":"1.0.0","main":"dist/lib/colors.js","scripts":{"prepare":"rm -rf ./dist && tsc","start":"node ./build/sample/sample.js","test":"echo ===Sample1===&&node ./build/sample/sample.js &&echo ===Sample2===&&node ./build/sample/sample1.js&&echo ===Sample3===&&node ./build/sample/sample2.js"},"repository":{"type":"git","url":"git+https://github.com/xerysherry/colors.ts.git"},"keywords":["console","colors","typescript","ts"],"author":{"name":"xerysherry"},"license":"Apache-2.0","dependencies":{},"description":"Console colors dev by Typescript (customized not to interfere with other similar color libraries)","devDependencies":{"@types/node":"^9.3.0","typescript":"^2.6.2"},"typings":"lib/index.d.ts","bugs":{"url":"https://github.com/xerysherry/colors.ts/issues"},"homepage":"https://github.com/xerysherry/colors.ts#readme","gitHead":"86dc13d54f21fca364c9bdbe49719ecfb55fae63","_id":"@aspectron/colors.ts@1.0.0","_nodeVersion":"14.3.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-r9rsFhceOd3HwsQsWHHtDpfmtF1crJb/cdfmInG9/2h6QZckuHEzHz2Fhcnv4n1uNaL9NmblTZ7GUWoT3C4BCg==","shasum":"34de0ec9760e54c5b92bc3630d83060ef0f8b03e","tarball":"https://registry.npmjs.org/@aspectron/colors.ts/-/colors.ts-1.0.0.tgz","fileCount":20,"unpackedSize":118871,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgD0TOCRA9TVsSAnZWagAAAaAP/1Lj6905tKaID9x+rgqD\nCIAnRvRxnI9Oi4tpf0U6cUO+3UggliasyGE+Fqe9tkMv10Jk3mezOTMMBpLy\nEr0kiuKJbfunNi8llqpCYvNui8EfmWASf+9OXshTpqo70iJC8A5WiMf68oar\nVE5v4Cx74c60wtO3b8s0rk8fpGCkP5y8aRskT6yLHJu6iAUo27IrLSH/TpPR\nFsxLDKz2AsVuGacb8NSRX+c9kQe3k7Aw1q8Kaf8lqvnSVaWmQE0WR4XyU6l1\nmjm8rACqjx6IfAZDvjimQZiqcTibRmLT4wcvJ2XXUcuV3zyFdrkJo6GC3YkH\n6GYSJrijGbh9rBp2Z4umeh+dOX4kqTTM45RaiZlmO4g7uociMmsdu0fqNQiD\nmHj67zdBQWn2W9yFHl6B87pLfLIRdt9eRm7Xm7SEGy7qBpo9a02hok3NzZuZ\n89vXAS2NNU9q8knYVwij1WiWFiGTPjLExZDjCdVR7ZcB7EHEdgb3SD7TvQUF\nCMJ+OGyO4TH3aqJhw+OZlGrj0eXIhjZJ7ExcFl5MckkS6LFyjn3d6KS2Pun/\ndHopP8dil+m+OAqaBXOqCv7I4Vjn2p2NHzHirrtWWqhEQgMr4blAVjpewi6a\nIbD7yppVFH87kNPYs66uhir0KMck1QlKMj2dTdSvXUnUY3u6DSbDRvtaLFtE\ndPqq\r\n=4To4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDfmYJ9dg1+SdxbTglHBJpXIz5RYzCMo8VuOgD5QULNtAIhAMO2zUiE45fX5KCOrOXfznI1ze0i4s6hZle1xESMYdyS"}]},"_npmUser":{"name":"aspect","email":"anton.yemelyanov@gmail.com"},"directories":{},"maintainers":[{"name":"aspect","email":"anton.yemelyanov@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/colors.ts_1.0.0_1611613389723_0.06780522775041331"},"_hasShrinkwrap":false}},"time":{"created":"2021-01-25T22:23:09.525Z","1.0.0":"2021-01-25T22:23:10.019Z","modified":"2022-04-04T15:48:23.664Z"},"maintainers":[{"name":"aspect","email":"anton.yemelyanov@gmail.com"}],"description":"Console colors dev by Typescript (customized not to interfere with other similar color libraries)","homepage":"https://github.com/xerysherry/colors.ts#readme","keywords":["console","colors","typescript","ts"],"repository":{"type":"git","url":"git+https://github.com/xerysherry/colors.ts.git"},"author":{"name":"xerysherry"},"bugs":{"url":"https://github.com/xerysherry/colors.ts/issues"},"license":"Apache-2.0","readme":"Colors For Typescript\r\n================================\r\n\r\n![npm](https://nodei.co/npm/colors.ts.png)\r\n\r\nHow to get?\r\n---------\r\n\r\nfirst \r\n\r\n```\r\nnpm install colors.ts\r\n```\r\n\r\nor\r\n\r\n```\r\ngit clone https://github.com/xerysherry/colors.ts.git\r\n```\r\n\r\nor Download it in here [https://github.com/xerysherry/colors.ts](https://github.com/xerysherry/colors.ts).\r\n\r\nIf you clone or download, you need build it.\r\n\r\n```\r\nnpm install\r\nnpm run build\r\nnpm run test\r\n```\r\n\r\nHow to install?\r\n-----------\r\n\r\nIf you use **npm** install, it is installed!\r\n\r\nIf you clone or download project, Please copy lib/* to your project path, or your favourite.\r\n\r\nHow to use?\r\n-----------\r\n\r\nIt's very easy. \r\n\r\nIf you use **npm** install, import colors.ts it, like this:\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\n```\r\n\r\nIf you clone or download colors.ts, import colors.ts in your source, like this:\r\n\r\n```TypeScript \r\nimport Colors = require('./lib/colors');\r\n```\r\n\r\nor\r\n\r\n```TypeScript \r\nrequire('./lib/colors');\r\n```\r\n\r\nNext to use it.\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\n\r\nconsole.log(\"this is a red string\".red);\r\nColors.colors(\"red\", \"this is a red string too!\");\r\n```\r\n\r\nTheme\r\n-----\r\n\r\nYou can use a custom theme.\r\n\r\n```TypeScript \r\nColors.theme({error:\"red\"})\r\nconsole.log(\"this is a error\".error);\r\nColors.theme({error:[\"bg_red\", \"underline\"]})\r\nconsole.log(\"this is a error\".error);\r\n```\r\n\r\nTheme have 5 useful propertis(verbose, info, debug, warning, error) and 10 custom properties(custom0 ~ custom10).\r\n\r\nGray and 256 colors \r\n-------------------\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\nColors.enable();\r\n\r\n// range at [0, 25]\r\nconsole.log(\"gray\".gray(20));\r\nconsole.log(\"gray\".gray_bg(20));\r\n// range at [0, 255]\r\nconsole.log(\"256 colors\".color_at_256(194));\r\nconsole.log(\"256 colors\".color_bg_at_256(194));\r\n\r\n```\r\n\r\nWeb Safe colors\r\n---------------\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\nColors.enable();\r\n\r\nconsole.log(\"web safe colors\".colors(\"#336699\"));\r\nconsole.log(\"web safe colors\".colors(\"b#996633\"));\r\n```\r\n\r\nPaint\r\n-----\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\nColors.enable();\r\n\r\nlet ts = `class Greeter {\r\n    greeting: string;\r\n    constructor(message: string) {\r\n        this.greeting = message;\r\n    }\r\n    greet() {\r\n        return \"Hello, \" + this.greeting;\r\n    }\r\n}\r\n\r\nlet greeter = new Greeter(\"world\");\r\n\r\nlet button = document.createElement('button');\r\nbutton.textContent = \"Say Hello\";\r\nbutton.onclick = function() {\r\n    alert(greeter.greet());\r\n}\r\n\r\ndocument.body.appendChild(button);\r\n`;\r\n\r\nconsole.log(ts.paint([\r\n    {key:[\"let\", \"new\", \"alert\", \"class\"], colors:\"red\"},\r\n    {key:\"this\", colors:\"brightgreen\"},\r\n    {key:\"return\", colors:\"green\"},\r\n    {key:\"document\", colors:\"green\"},\r\n    {key:new RegExp(\"string|number|function\", \"g\"), colors:[\"#6600FF\", \"bold\"]},\r\n    {key:new RegExp(\"\\\\{|\\\\}\", \"g\"), colors:\"bold\"},\r\n    {key:new RegExp(\"\\\\(|\\\\)\", \"g\"), colors:\"bold\"},\r\n    {key:[/\"[^\"]*\"/g, /'[^']*'/g], colors:[\"brightyellow\", \"underline\"]},\r\n]))\r\n```\r\n\r\nAPI\r\n---\r\n\r\nColors.colors(color: string | string[], value: string, noreset?: boolean): string\r\n\r\n* return colorful value\r\n\r\nColors.enable(value: boolean = true): void\r\n    \r\n* enable/disable colors\r\n\r\nColors.theme(theme: { [key: string]: string | string[] }): void\r\n\r\n* set theme\r\n\r\nColors.paint(paint: Colors.Painter[], value: string): string\r\n\r\n* paint, Painter see [#define]\r\n\r\nColors.position(x:number, y:number): void\r\n\r\n* set input position\r\n\r\nColors.clear_screen(): void\r\n\r\n* clear screen\r\n\r\nColors.show_cursor(): void\r\n\r\n* show/hide cursor\r\n\r\nColors.support(support?: Colors.Support): Support\r\n\r\n* set support level, {DISABLE, BASE, ANSI256, ANSI24bits}\r\n\r\ninterface Colors.Painter define\r\n\r\n```TypeScript\r\ninterface Painter\r\n{\r\n    // match mode, string, regex, array of string, array of regex\r\n    key: string | string[] | RegExp | RegExp[];\r\n    // color style\r\n    // keyword, like \"underline\", \"bold\", \"red\", \"green\", \"bg_reg\", \"bg_green\"\r\n    // hexcode, like \"#ff00ff\", \"#337011\"\r\n    // hexcode for bg, like \"b#ff00ff\", \"b#337011\"\r\n    // graycode like \"g11\", \"g25\"\r\n    // graycode fro by like \"bg11, \"bg25\"\"\r\n    colors: string | string[];\r\n}\r\n```\r\n\r\nString Extend\r\n-------------\r\n\r\n```TypeScript \r\ndeclare global {\r\n    interface String {\r\n        reset: string;\r\n        bold: string;\r\n        dim: string;\r\n        italic: string;\r\n        underline: string;\r\n        inverse: string;\r\n        hidden: string;\r\n        strikethrough: string;\r\n\r\n        black: string;\r\n        red: string;\r\n        green: string;\r\n        yellow: string;\r\n        blue: string;\r\n        magenta: string;\r\n        cyan: string;\r\n        white: string;\r\n\r\n        bg_black: string;\r\n        bg_red: string;\r\n        bg_green: string;\r\n        bg_yellow: string;\r\n        bg_blue: string;\r\n        bg_magenta: string;\r\n        bg_cyan: string;\r\n        bg_white: string;\r\n\r\n        //theme\r\n        verbose: string;\r\n        info: string;\r\n        debug: string;\r\n        error: string;\r\n\r\n        custom0: string;\r\n        custom1: string;\r\n        custom2: string;\r\n        custom3: string;\r\n        custom4: string;\r\n        custom5: string;\r\n        custom6: string;\r\n        custom7: string;\r\n        custom8: string;\r\n        custom9: string;\r\n\r\n        //[0, 255]\r\n        color_at_256(idx:number):string;\r\n        color_bg_at_256(idx:number):string;\r\n        //[0, 25]\r\n        gray(level:number):string;\r\n        grey(level:number):string;\r\n        gray_bg(level:number):string;\r\n        grey_bg(level:number):string;\r\n        // [000000, ffffff]\r\n        hex(hex:string): string;\r\n        hex_bg(hex:string): string;\r\n        // [0, 255]\r\n        rgb(r:number, g:number, b:number): string;\r\n        rgb_bg(r:number, g:number, b:number): string;\r\n\r\n        // keyword, #000000, b#000000\r\n        colors(color:string|string[], noreset?:boolean):string;\r\n        paint(paint:Colors.Painter[]):string;\r\n\r\n        up(n?:number):string;\r\n        down(n?:number):string;\r\n        right(n?:number):string;\r\n        left(n?:number):string;\r\n        \r\n        next_line(n?:number):string;\r\n        prev_line(n?:number):string;\r\n        column(n:number):string;\r\n        position(x:number, y:number):string;\r\n        \r\n        save_position:string;\r\n        load_position:string;\r\n\r\n        clear_screen:string;\r\n        clear_line:string;\r\n    }\r\n}\r\n```\r\n\r\nSample\r\n------\r\n\r\nIn /sample/, you will found some sample. It is very easy and clear.\r\n\r\nScreenshot\r\n----------\r\n\r\n![windows_cmd](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/windows_cmd.png)\r\n![centos_console](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/centos_console.png)\r\n\r\nGray And 256 Colors\r\n\r\n![gray_and_256colors](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/gray_and_256colors.png)\r\n\r\nWeb Safe Colors\r\n\r\n![web_safe_colors](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/web_safe_colors.png)\r\n\r\nTypeScript Colorful\r\n\r\n![ts_paint](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/ts_paint.png)\r\n\r\nEnjoy it!\r\n\r\nTypeScript 命令行输出颜色库\r\n=========================\r\n\r\n如何获得？\r\n--------\r\n\r\n首先，可以使用npm安装\r\n\r\n```\r\nnpm install colors.ts\r\n```\r\n\r\n或者git克隆它\r\n\r\n```\r\ngit clone https://github.com/xerysherry/colors.ts.git\r\n```\r\n\r\n或者在[https://github.com/xerysherry/colors.ts](https://github.com/xerysherry/colors.ts)这里下载它\r\n\r\n如果你克隆或者下载，那么就需要build，如下\r\n\r\n```\r\nnpm install\r\nnpm run build\r\nnpm run test\r\n```\r\n\r\n如何安装？\r\n--------\r\n\r\n如果使用npm安装，请跳过\r\n\r\n拷贝lib到你的工程路径下, 或者任意你喜欢的地方。\r\n\r\n如何使用？\r\n--------\r\n\r\n如果通过npm安装，你可以如下引用它\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\n```\r\n\r\n如果通过克隆或者下载，可以用如下方式引用：\r\n\r\n```TypeScript \r\nimport {Colors} from './lib/colors'；\r\n```\r\n\r\n或者\r\n\r\n```TypeScript \r\nrequire('./lib/colors');\r\n```\r\n\r\n接着，就可以使用啦。\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\nColors.enable();\r\n\r\nconsole.log(\"this is a red string\".red);\r\nColors.colors(\"red\", \"this is a red string too!\");\r\n```\r\n\r\n主题\r\n----\r\n\r\n你可以使用自定义主题\r\n\r\n```TypeScript \r\nColors.theme({error:\"red\"})\r\nconsole.log(\"this is a error\".error);\r\nColors.theme({error:\"bgRed\"})\r\nconsole.log(\"this is a error\".error);\r\n```\r\n\r\n主题相关属性包括，verbose, info, debug, warning, error五个常用的，以及custom0~custom9十个自定义位置。\r\n\r\n灰度和256色 \r\n----------\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\nColors.enable();\r\n\r\n// range at [0, 25]\r\nconsole.log(\"gray\".gray(20));\r\nconsole.log(\"gray\".gray_bg(20));\r\n// range at [0, 255]\r\nconsole.log(\"256 colors\".color_at_256(194));\r\nconsole.log(\"256 colors\".color_bg_at_256(194));\r\n\r\n```\r\n\r\n网页安全色\r\n---------\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\nColors.enable();\r\n\r\nconsole.log(\"web safe colors\".colors(\"#336699\"));\r\nconsole.log(\"web safe colors\".colors(\"b#996633\"));\r\n```\r\n\r\n着色方案\r\n-------\r\n\r\n```TypeScript \r\nimport Colors = require('colors.ts');\r\nColors.enable();\r\n\r\nlet ts = `class Greeter {\r\n    greeting: string;\r\n    constructor(message: string) {\r\n        this.greeting = message;\r\n    }\r\n    greet() {\r\n        return \"Hello, \" + this.greeting;\r\n    }\r\n}\r\n\r\nlet greeter = new Greeter(\"world\");\r\n\r\nlet button = document.createElement('button');\r\nbutton.textContent = \"Say Hello\";\r\nbutton.onclick = function() {\r\n    alert(greeter.greet());\r\n}\r\n\r\ndocument.body.appendChild(button);\r\n`;\r\n\r\nconsole.log(ts.paint([\r\n    {key:[\"let\", \"new\", \"alert\", \"class\"], colors:\"red\"},\r\n    {key:\"this\", colors:\"brightgreen\"},\r\n    {key:\"return\", colors:\"green\"},\r\n    {key:\"document\", colors:\"green\"},\r\n    {key:new RegExp(\"string|number|function\", \"g\"), colors:[\"#6600FF\", \"bold\"]},\r\n    {key:new RegExp(\"\\\\{|\\\\}\", \"g\"), colors:\"bold\"},\r\n    {key:new RegExp(\"\\\\(|\\\\)\", \"g\"), colors:\"bold\"},\r\n    {key:[/\"[^\"]*\"/g, /'[^']*'/g], colors:[\"brightyellow\", \"underline\"]},\r\n]))\r\n```\r\n\r\nAPI\r\n---\r\n\r\nColors.colors(color: string | string[], value: string, noreset?: boolean): string\r\n\r\n* 返回颜色化的value\r\n\r\nColors.enable(value: boolean = true): void\r\n    \r\n* 是否启用颜色\r\n\r\nColors.theme(theme: { [key: string]: string | string[] }): void\r\n\r\n* 设置主题\r\n\r\nColors.paint(paint: Painter[], value: string): string\r\n\r\n* 着色, Painter结构参看定义\r\n\r\nColors.position(x:number, y:number): void\r\n\r\n* 设置光标位置\r\n\r\nColors.clear_screen(): void\r\n\r\n* 清空屏幕\r\n\r\nColors.show_cursor(): void\r\n\r\n* 显示/隐藏光标\r\n\r\nString扩展的属性与函数\r\n\r\nColors.support(support?: Colors.Support): Support\r\n\r\n* 支持颜色级别, {DISABLE, BASE, ANSI256, ANSI24bits}\r\n\r\n结构Colors.Painter定义\r\n\r\n```TypeScript\r\ninterface Painter\r\n{\r\n    // match mode, string, regex, array of string, array of regex\r\n    key: string | string[] | RegExp | RegExp[];\r\n    // color style\r\n    // keyword, like \"underline\", \"bold\", \"red\", \"green\", \"bg_reg\", \"bg_green\"\r\n    // hexcode, like \"#ff00ff\", \"#337011\"\r\n    // hexcode for bg, like \"b#ff00ff\", \"b#337011\"\r\n    // graycode like \"g11\", \"g25\"\r\n    // graycode fro by like \"bg11, \"bg25\"\"\r\n    colors: string | string[];\r\n}\r\n```\r\n\r\nString扩展定义\r\n-------------\r\n\r\n```TypeScript \r\ndeclare global {\r\n    interface String {\r\n        reset: string;\r\n        bold: string;\r\n        dim: string;\r\n        italic: string;\r\n        underline: string;\r\n        inverse: string;\r\n        hidden: string;\r\n        strikethrough: string;\r\n\r\n        black: string;\r\n        red: string;\r\n        green: string;\r\n        yellow: string;\r\n        blue: string;\r\n        magenta: string;\r\n        cyan: string;\r\n        white: string;\r\n\r\n        bg_black: string;\r\n        bg_red: string;\r\n        bg_green: string;\r\n        bg_yellow: string;\r\n        bg_blue: string;\r\n        bg_magenta: string;\r\n        bg_cyan: string;\r\n        bg_white: string;\r\n\r\n        //theme\r\n        verbose: string;\r\n        info: string;\r\n        debug: string;\r\n        error: string;\r\n\r\n        custom0: string;\r\n        custom1: string;\r\n        custom2: string;\r\n        custom3: string;\r\n        custom4: string;\r\n        custom5: string;\r\n        custom6: string;\r\n        custom7: string;\r\n        custom8: string;\r\n        custom9: string;\r\n\r\n        //[0, 255]\r\n        color_at_256(idx:number):string;\r\n        color_bg_at_256(idx:number):string;\r\n        //[0, 25]\r\n        gray(level:number):string;\r\n        grey(level:number):string;\r\n        gray_bg(level:number):string;\r\n        grey_bg(level:number):string;\r\n        // [000000, ffffff]\r\n        hex(hex:string): string;\r\n        hex_bg(hex:string): string;\r\n        // [0, 255]\r\n        rgb(r:number, g:number, b:number): string;\r\n        rgb_bg(r:number, g:number, b:number): string;\r\n\r\n        // keyword, #000000, b#000000\r\n        colors(color:string|string[], noreset?:boolean):string;\r\n        paint(paint:Colors.Painter[]):string;\r\n\r\n        up(n?:number):string;\r\n        down(n?:number):string;\r\n        right(n?:number):string;\r\n        left(n?:number):string;\r\n        \r\n        next_line(n?:number):string;\r\n        prev_line(n?:number):string;\r\n        column(n:number):string;\r\n        position(x:number, y:number):string;\r\n        save_position:string;\r\n        load_position:string;\r\n\r\n        clear_screen:string;\r\n        clear_line:string;\r\n    }\r\n}\r\n```\r\n\r\n例子\r\n----\r\n\r\n你可以在/Sample/下找到相关例子，它们都非常简单和清晰。\r\n\r\n截图\r\n----\r\n![windows_cmd](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/windows_cmd.png)\r\n![centos_console](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/centos_console.png)\r\n\r\n灰度与256色\r\n\r\n![gray_and_256colors](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/gray_and_256colors.png)\r\n\r\n网页安全色\r\n\r\n![web_safe_colors](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/web_safe_colors.png)\r\n\r\nTypeScript着色例子\r\n\r\n![ts_paint](https://raw.githubusercontent.com/xerysherry/colors.ts/master/screenshot/ts_paint.png)\r\n\r\n请使用它，希望你们喜欢！\r\n","readmeFilename":"README.md"}