GithubHelp home page GithubHelp logo

openinf / openinf-util-text Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 388 KB

Cross-platform terminal-friendly text utilities

Home Page: https://github.com/OpenINF/openinf-util-text#readme

License: Other

JavaScript 79.53% TypeScript 20.47%
text color utilities cross-platform nodejs javascript functional predicate helpers helpers-library javascript-library typescript typescript-library npm-package commonjs commonjs-module commonjs-package typescript-package nodejs-module

openinf-util-text's Introduction

OpenINF logo

@openinf/util-text

Essential cross-platform terminal-friendly text utilities


'View on npm' 'License: MIT/Apache-2.0'


The high-level goal of @openinf/util-text is to serve as a Node.js package containing essential cross-platform text utilities that degrade gracefully when used in terminals lacking feature support. We are constantly working to improve this repository, so please feel free to contribute if you notice any omissions or errors.

Thanks!


Platform: Node.js LTS

Supported Node.js Environments

  • v4:Argon (Ar)
  • v6:Boron (B)
  • v8:Carbon (C)
  • v10:Dubnium (Db)
  • v12:Erbium (Er)
  • v14:Fermium (Fm)
  • v16:Gallium (Ga)
  • v18:Hydrogen (H)

Code Style: Prettier Commit Style: Conventional Commits Chat on Matrix





Table of Contents





Installation Corepack logo


@openinf/util-text runs on supported versions of Node.js and is available via npm, pnpm, or yarn.

Using the npm CLI

See the official documentation for this command for more information.

npm i @openinf/util-text

Using the pnpm CLI

See the official documentation for this command for more information.

pnpm add @openinf/util-text

Using the Yarn 1 CLI (Classic)

See the official documentation for this command for more information.

yarn add @openinf/util-text

Usage

To get started using the text utils provided by @openinf/util-text, all that needs to be done is either import/require (depending on the module format) the default export of the module or destructure the individual named helper functions exported.

import { blueify, ellipsify } from '@openinf/util-text';

console.log(blueify(ellipsify('Deserializing database tables')));



API


Tip

The “supplied string” should be supplied by app developer (not arbitrarily) because anything beyond that (e.g., in publicly-facing apps) may need be pre-processed. The next release may perform preprocessing to follow Web Platform Design Principles.


Warning
Notice that these APIs were not built for (and are potentially not good for) language models:
  • Speak with a diverse mix of prospective users of your application within your target population about its intended purpose to gain a wider perspective on potential risks and have your app be adapted to those circumstances.

    ⓘ This tip was paraphrased from Google AI safety guidance; however, further reading on the topic of AI safety guidance may be available elsewhere.


blueify(text)string

Returns the supplied string as blue colored if ANSI escapes are supported.

curlyQuote(text)string

Returns the supplied string as curly quoted if Unicode is supported.

ellipsify(text)string

Returns the supplied string as ellipsified if Unicode is supported.

italicize(text)string

Returns the supplied string as italicized if ANSI escapes are supported.

mdCodeSpans2html(text)string

Processes the supplied string by transforming any Markdown backtick code spans (beginning and ending with a single backtick) into HTML code elements.

redden(text)string

Returns the supplied string as red colored if ANSI escapes are supported.

underline(text)string

Returns the supplied string as underlined if ANSI escapes are supported.

yellow(text)string

Returns the supplied string as yellow colored if ANSI escapes are supported.

UnicodeEscapes : enum

Kind: global enum
Properties

Name Type Default
infoSymbol string "ⓘ"
midlineEllipsis string "⋯"
ellipsis string "…"
errorSymbol string "ⓧ"
leftDoubleQuotes string "“"
rightDoubleQuotes string "”"
warningSymbol string "⚠"

blueify(text) ⇒ string

Returns the supplied string as blue colored if ANSI escapes are supported.

Kind: global function

Param Type
text string

curlyQuote(text) ⇒ string

Returns the supplied string as curly quoted if Unicode is supported.

Kind: global function

Param Type
text string

ellipsify(text) ⇒ string

Returns the supplied string as ellipsified if Unicode is supported.

Kind: global function

Param Type
text string

italicize(text) ⇒ string

Returns the supplied string as italicized if ANSI escapes are supported.

Kind: global function

Param Type
text string

mdCodeSpans2html(text) ⇒ string

Tip

This API will be deprecated in the next release in favor of one that follows Web Platform Design Principles.

Processes the supplied string by transforming any Markdown backtick code spans (beginning and ending with a single backtick) into HTML code elements.

Kind: global function

Param Type
text string

redden(text) ⇒ string

Returns the supplied string as red colored if ANSI escapes are supported.

Kind: global function

Param Type
text string

underline(text) ⇒ string

Returns the supplied string as underlined if ANSI escapes are supported.

Kind: global function

Param Type
text string

yellow(text) ⇒ string

Returns the supplied string as yellow colored if ANSI escapes are supported.

Kind: global function

Param Type
text string





Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. If for whatever reason you spot something to fix but cannot patch it yourself, please open an issue.


License

This project is licensed under either of

at your option.

The SPDX license identifier for this project is MIT OR Apache-2.0.





Show Your Support


If you like the project (or want to bookmark it) —
— give it a star ⭐️ — it will greatly encourage us.



The OpenINF logo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.