{"id":27194786,"url":"https://github.com/openinf/openinf-util-text","last_synced_at":"2025-04-09T19:36:30.830Z","repository":{"id":38441849,"uuid":"333693648","full_name":"OpenINF/openinf-util-text","owner":"OpenINF","description":"Cross-platform terminal-friendly text utilities","archived":false,"fork":false,"pushed_at":"2025-04-05T01:41:45.000Z","size":388,"stargazers_count":4,"open_issues_count":30,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-05T02:28:38.195Z","etag":null,"topics":["color","commonjs","commonjs-module","commonjs-package","cross-platform","functional","helpers","helpers-library","javascript","javascript-library","nodejs","nodejs-module","npm-package","predicate","text","typescript","typescript-library","typescript-package","utilities"],"latest_commit_sha":null,"homepage":"https://github.com/OpenINF/openinf-util-text#readme","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenINF.png","metadata":{"funding":{"github":[]},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-28T08:27:19.000Z","updated_at":"2024-05-26T12:23:26.000Z","dependencies_parsed_at":"2023-10-16T09:00:12.231Z","dependency_job_id":"afdf6ea1-1a89-4653-8d93-c8a4dbc138fa","html_url":"https://github.com/OpenINF/openinf-util-text","commit_stats":null,"previous_names":["openinf/util-text"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-util-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-util-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-util-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-util-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenINF","download_url":"https://codeload.github.com/OpenINF/openinf-util-text/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248098512,"owners_count":21047455,"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","commonjs","commonjs-module","commonjs-package","cross-platform","functional","helpers","helpers-library","javascript","javascript-library","nodejs","nodejs-module","npm-package","predicate","text","typescript","typescript-library","typescript-package","utilities"],"created_at":"2025-04-09T19:36:29.598Z","updated_at":"2025-04-09T19:36:30.809Z","avatar_url":"https://github.com/OpenINF.png","language":"JavaScript","readme":"\u003ca href=\"https://open.inf.is\"\u003e\n  \u003cimg\n    src=\"https://open.inf.is/assets/img/svg/logogram-color.svg\"\n    alt=\"OpenINF logo\"\n    title=\"OpenINF\"\n    align=\"right\"\n    height=\"96\"\n    width=\"96\"\n  /\u003e\n\u003c/a\u003e\n\n\u003cdiv align=\"left\"\u003e\n\n## `@openinf/util-text`\n\n\u003e Essential cross-platform terminal-friendly text utilities\n\n\u003cbr /\u003e\n\n[!['View on npm'][npm-badge--shields]][npm-badge-url]\n[!['License: MIT/Apache-2.0'][license-badge--shields]][license-badge-url]\n\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\nThe high-level goal of `@openinf/util-text` is to serve as a Node.js package\ncontaining **essential cross-platform text utilities** that degrade gracefully\nwhen used in terminals lacking feature support. We are constantly working to\nimprove this repository, so please feel free to [contribute](#contributing) if\nyou notice any omissions or errors.\n\nThanks!\n\n\u003cbr /\u003e\n\n\u003cdetails id=\"platform--node-js-lts\"\u003e\n\t\u003csummary\u003e\n\t\t\u003ca\n\t\t\thref=\"#platform--node-js-lts\"\n\t\t\ttitle=\"Platform: Node.js LTS\"\n\t\t\u003e\n\t\t\t\u003cimg\n\t\t\t\tsrc=\"https://img.shields.io/badge/Node.js-LTS-black?logo=Node.js\u0026logoColor=lightgreen\u0026color=2a2a2a\u0026labelColor=black\"\n\t\t\t\talt=\"Platform: Node.js LTS\"\n\t\t\t/\u003e\n\t\t\u003c/a\u003e\n\t\u003c/summary\u003e\n\t\u003cdiv align=\"left\"\u003e\u003cbr /\u003e\n\t\t\u003ca\n\t\t\ttarget=\"_blank\"\n\t\t\ttitle=\"Node.js release schedule\"\n\t\t\thref=\"https://github.com/nodejs/release#release-schedule\"\n\t\t\u003e\n\t\t\t\u003cstrong\u003eSupported Node.js Environments\u003c/strong\u003e\n\t\t\u003c/a\u003e\u003cbr /\u003e\u003cbr /\u003e\n\n- [ ] v4：Argon (Ar)\n- [ ] v6：Boron (B)\n- [ ] v8：Carbon (C)\n- [ ] v10：Dubnium (Db)\n- [ ] v12：Erbium (Er)\n- [x] v14：Fermium (Fm)\n- [x] v16：Gallium (Ga)\n- [x] v18：Hydrogen (H)\n\u003c!-- TODO\n- [x] v20: Iron (Fe) --\u003e\n\n\u003c/div\u003e\u003c/details\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Code Style: Prettier][prettier-badge]][prettier-url]\n[![Commit Style: Conventional Commits][conventional-commits-badge]][conventional-commits-url]\n[![Chat on Matrix][matrix-badge--shields]][matrix-url]\n\n\u003c/div\u003e\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n### Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\n\t\u003c!-- markdownlint-disable-next-line line-length --\u003e\n\t\u003ch3 id=\"installation\" align=\"left\"\u003eInstallation \u003ca href=\"##\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/nodejs/corepack/main/icon.svg?sanitize=true\" alt=\"Corepack logo\" title=\"Corepack friendly\" align=\"right\" height=\"24\" width=\"24\" /\u003e\u003c/a\u003e\u003c/h3\u003e\n\u003c/summary\u003e\n\n\u003cbr /\u003e\n\n`@openinf/util-text` runs on\n[supported versions of Node.js](#platform--node-js-lts) and is available via\n**`npm`**, **`pnpm`**, or **`yarn`**.\n\n**Using the npm CLI**\n\n\u003csup\u003eSee the\n[official documentation for this command](https://docs.npmjs.com/cli/commands/npm-install)\nfor more information.\u003c/sup\u003e\n\n```shell\nnpm i @openinf/util-text\n```\n\n**Using the pnpm CLI**\n\n\u003csup\u003eSee the [official documentation for this command](https://pnpm.io/cli/add)\nfor more information.\u003c/sup\u003e\n\n```shell\npnpm add @openinf/util-text\n```\n\n**Using the Yarn 1 CLI (Classic)**\n\n\u003csup\u003eSee the\n[official documentation for this command](https://classic.yarnpkg.com/en/docs/cli/add)\nfor more information.\u003c/sup\u003e\n\n```shell\nyarn add @openinf/util-text\n```\n\n\u003cbr /\u003e\n\n\u003c/details\u003e\n\n### Usage\n\nTo get started using the text utils provided by `@openinf/util-text`, all\nthat needs to be done is either import/require (depending on the module format)\nthe default export of the module or destructure the individual named helper\nfunctions exported.\n\n```ts\nimport { blueify, ellipsify } from '@openinf/util-text';\n\nconsole.log(blueify(ellipsify('Deserializing database tables')));\n```\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n### API\n\n\u003cbr /\u003e\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/OpenINF/GitHub-Markdown/HEAD/blockquotes/badge/light-theme/tip.svg\"\u003e\n  \u003cimg alt=\"Tip\" src=\"https://raw.githubusercontent.com/OpenINF/GitHub-Markdown/HEAD/blockquotes/badge/dark-theme/tip.svg\"\u003e\n\u003c/picture\u003e\u003cbr /\u003e\n\nThe \u0026ldquo;supplied string\u0026rdquo; should be supplied by app developer (not arbitrarily)\nbecause anything beyond that (e.g., in publicly-facing apps) may need be pre-processed.\nThe next release may perform preprocessing to follow Web Platform Design Principles.\n\n\u003cdetails\u003e\n\u003csummary\u003e\n\u003ca href=\"#\" aria-controls=\"advanced-tips\" aria-expanded=\"false\"\u003e\u003ch4 id=\"advanced-tips\"\u003eAdvanced Tips\u003c/h4\u003e\u003c/a\u003e\n\u003c/summary\u003e\n\n\u003cbr /\u003e\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/OpenINF/GitHub-Markdown/HEAD/blockquotes/badge/light-theme/warning.svg\"\u003e\n  \u003cimg alt=\"Warning\" src=\"https://raw.githubusercontent.com/OpenINF/GitHub-Markdown/HEAD/blockquotes/badge/dark-theme/warning.svg\"\u003e\n\u003c/picture\u003e\u003cbr /\u003e\nNotice that these APIs were not built for (and are potentially not good for)\nlanguage models:\n\n\u003cbr /\u003e\n\n- Speak with a diverse mix of prospective users of your application within your\n  target population about its intended purpose to gain a wider perspective on\n  potential risks and have your app be adapted to those circumstances.\u003cbr /\u003e\n\n  \u0026#x24D8; This tip was paraphrased from [Google AI safety guidance][]; however,\n  further reading on the topic of AI safety guidance may be available elsewhere.\n\n\u003c/details\u003e\n\n\u003cbr /\u003e\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#blueify\"\u003eblueify(text)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReturns the supplied string as blue colored if ANSI escapes are supported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#curlyQuote\"\u003ecurlyQuote(text)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReturns the supplied string as curly quoted if Unicode is supported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#ellipsify\"\u003eellipsify(text)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReturns the supplied string as ellipsified if Unicode is supported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#italicize\"\u003eitalicize(text)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReturns the supplied string as italicized if ANSI escapes are supported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#mdCodeSpans2html\"\u003emdCodeSpans2html(text)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eProcesses the supplied string by transforming any Markdown backtick code\nspans (beginning and ending with a single backtick) into HTML code elements.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#redden\"\u003eredden(text)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReturns the supplied string as red colored if ANSI escapes are supported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#underline\"\u003eunderline(text)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReturns the supplied string as underlined if ANSI escapes are supported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#yellow\"\u003eyellow(text)\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReturns the supplied string as yellow colored if ANSI escapes are supported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"UnicodeEscapes\"\u003e\u003c/a\u003e\n\n#### UnicodeEscapes : \u003ccode\u003eenum\u003c/code\u003e\n**Kind**: global enum  \n**Properties**\n\n| Name | Type | Default |\n| --- | --- | --- |\n| infoSymbol | \u003ccode\u003estring\u003c/code\u003e | \u003ccode\u003e\u0026quot;ⓘ\u0026quot;\u003c/code\u003e | \n| midlineEllipsis | \u003ccode\u003estring\u003c/code\u003e | \u003ccode\u003e\u0026quot;⋯\u0026quot;\u003c/code\u003e | \n| ellipsis | \u003ccode\u003estring\u003c/code\u003e | \u003ccode\u003e\u0026quot;…\u0026quot;\u003c/code\u003e | \n| errorSymbol | \u003ccode\u003estring\u003c/code\u003e | \u003ccode\u003e\u0026quot;ⓧ\u0026quot;\u003c/code\u003e | \n| leftDoubleQuotes | \u003ccode\u003estring\u003c/code\u003e | \u003ccode\u003e\u0026quot;“\u0026quot;\u003c/code\u003e | \n| rightDoubleQuotes | \u003ccode\u003estring\u003c/code\u003e | \u003ccode\u003e\u0026quot;”\u0026quot;\u003c/code\u003e | \n| warningSymbol | \u003ccode\u003estring\u003c/code\u003e | \u003ccode\u003e\u0026quot;⚠\u0026quot;\u003c/code\u003e | \n\n\u003ca name=\"blueify\"\u003e\u003c/a\u003e\n\n#### blueify(text) ⇒ \u003ccode\u003estring\u003c/code\u003e\nReturns the supplied string as blue colored if ANSI escapes are supported.\n\n**Kind**: global function  \n\n| Param | Type |\n| --- | --- |\n| text | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003ca name=\"curlyQuote\"\u003e\u003c/a\u003e\n\n#### curlyQuote(text) ⇒ \u003ccode\u003estring\u003c/code\u003e\nReturns the supplied string as curly quoted if Unicode is supported.\n\n**Kind**: global function  \n\n| Param | Type |\n| --- | --- |\n| text | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003ca name=\"ellipsify\"\u003e\u003c/a\u003e\n\n#### ellipsify(text) ⇒ \u003ccode\u003estring\u003c/code\u003e\nReturns the supplied string as ellipsified if Unicode is supported.\n\n**Kind**: global function  \n\n| Param | Type |\n| --- | --- |\n| text | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003ca name=\"italicize\"\u003e\u003c/a\u003e\n\n#### italicize(text) ⇒ \u003ccode\u003estring\u003c/code\u003e\nReturns the supplied string as italicized if ANSI escapes are supported.\n\n**Kind**: global function  \n\n| Param | Type |\n| --- | --- |\n| text | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003ca name=\"mdCodeSpans2html\"\u003e\u003c/a\u003e\n\n#### mdCodeSpans2html(text) ⇒ \u003ccode\u003estring\u003c/code\u003e\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/OpenINF/GitHub-Markdown/HEAD/blockquotes/badge/light-theme/tip.svg\"\u003e\n  \u003cimg alt=\"Tip\" src=\"https://raw.githubusercontent.com/OpenINF/GitHub-Markdown/HEAD/blockquotes/badge/dark-theme/tip.svg\"\u003e\n\u003c/picture\u003e\u003cbr /\u003e\n\nThis API will be deprecated in the next release in favor of one that follows\n[Web Platform Design Principles](https://github.com/OpenINF/openinf-util-text/issues/169).\n\nProcesses the supplied string by transforming any Markdown backtick code spans\n(beginning and ending with a single backtick) into HTML code elements.\n\n**Kind**: global function  \n\n| Param | Type |\n| --- | --- |\n| text | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003ca name=\"redden\"\u003e\u003c/a\u003e\n\n#### redden(text) ⇒ \u003ccode\u003estring\u003c/code\u003e\nReturns the supplied string as red colored if ANSI escapes are supported.\n\n**Kind**: global function  \n\n| Param | Type |\n| --- | --- |\n| text | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003ca name=\"underline\"\u003e\u003c/a\u003e\n\n#### underline(text) ⇒ \u003ccode\u003estring\u003c/code\u003e\nReturns the supplied string as underlined if ANSI escapes are supported.\n\n**Kind**: global function  \n\n| Param | Type |\n| --- | --- |\n| text | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003ca name=\"yellow\"\u003e\u003c/a\u003e\n\n#### yellow(text) ⇒ \u003ccode\u003estring\u003c/code\u003e\nReturns the supplied string as yellow colored if ANSI escapes are supported.\n\n**Kind**: global function  \n\n| Param | Type |\n| --- | --- |\n| text | \u003ccode\u003estring\u003c/code\u003e | \n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n### Contributing\n\nPull requests are welcome. For major changes, please open an issue first to\ndiscuss what you would like to change. If for whatever reason you spot something\nto fix but cannot patch it yourself, please [open an issue][].\n\n\u003cbr /\u003e\n\n### License\n\nThis project is licensed under either of\n\n- [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)\n- [MIT license](https://opensource.org/licenses/MIT)\n\nat your option.\n\nThe [SPDX](https://spdx.dev) license identifier for this project is\n`MIT OR Apache-2.0`.\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n### Show Your Support\n\n\u003cbr /\u003e\n\nIf you like the project (or want to bookmark it)\u0026nbsp;\u0026mdash;\u003cbr /\u003e\n\u0026mdash;\u0026nbsp;[give it a star ⭐️][]\u0026nbsp;\u0026mdash;\u0026nbsp;it will greatly encourage\nus.\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n\u003ca title=\"The OpenINF website\" href=\"https://open.inf.is\" rel=\"author\"\u003e\n  \u003cimg alt=\"The OpenINF logo\" height=\"32px\" width=\"32px\" src=\"https://open.inf.is/assets/img/svg/logogram-color.svg\" /\u003e\n\u003c/a\u003e\n\n\u003c/div\u003e\n\n\u003c!-- BEGIN LINK DEFINITIONS --\u003e\n[conventional-commits-badge]: https://img.shields.io/badge/commit%20style-Conventional-%23fa6673?logoColor=white\u0026logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMCAzMCI+PHBhdGggc3R5bGU9ImZpbGw6ICNGRkYiIGQ9Ik0xNSwyQTEzLDEzLDAsMSwxLDIsMTUsMTMsMTMsMCwwLDEsMTUsMm0wLTJBMTUsMTUsMCwxLDAsMzAsMTUsMTUsMTUsMCwwLDAsMTUsMFoiLz48L3N2Zz4K 'Commit Style: Conventional Commits'\n[conventional-commits-url]: https://www.conventionalcommits.org 'Commit Style: Conventional Commits'\n[give it a star ⭐️]: https://github.com/OpenINF/openinf-util-text/stargazers\n[license-badge--shields]: https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg?logo=github 'License: MIT/Apache 2.0'\n[license-badge-url]: #license 'License: MIT/Apache 2.0'\n[matrix-badge--shields]: https://img.shields.io/badge/matrix-join%20chat-%2346BC99?logo=matrix 'Chat on Matrix'\n[matrix-url]: https://matrix.to/#/#openinf-space:matrix.org 'You\u0026apos;re invited to talk on Matrix'\n[npm-badge--shields]: https://img.shields.io/npm/v/@openinf/util-text/latest.svg?logo=npm\u0026color=fe7d37 'View on npm'\n[npm-badge-url]: https://www.npmjs.com/package/@openinf/util-text#top 'View on npm'\n[open an issue]: https://github.com/OpenINF/openinf-util-text/issues\n[prettier-badge]: https://img.shields.io/badge/code_style-Prettier-ff69b4.svg?logo=prettier 'Code Style: Prettier'\n[prettier-url]: https://prettier.io/playground 'Code Style: Prettier'\n[project-status-badge]: https://img.shields.io/badge/project%20status-under%20construction-orange 'Project Status: Under construction badge'\n[Google AI safety guidance]:\n  https://developers.generativeai.google/guide/safety_guidance\n  \"Safety Guidance for Developers of Generative AI Applications\"\n\u003c!-- END LINK DEFINITIONS --\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopeninf%2Fopeninf-util-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopeninf%2Fopeninf-util-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopeninf%2Fopeninf-util-text/lists"}