https://github.com/thebespokepixel/string
Esoteric string formatting.
https://github.com/thebespokepixel/string
helper library node-module npm string-manipulation strings
Last synced: 3 months ago
JSON representation
Esoteric string formatting.
- Host: GitHub
- URL: https://github.com/thebespokepixel/string
- Owner: thebespokepixel
- License: mit
- Created: 2016-04-21T07:41:17.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T17:52:16.000Z (about 2 years ago)
- Last Synced: 2025-03-12T09:05:52.809Z (3 months ago)
- Topics: helper, library, node-module, npm, string-manipulation, strings
- Language: JavaScript
- Homepage: https://thebespokepixel.github.io/string/
- Size: 21.9 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# @thebespokepixel/string
> A collection of enhanced formats and utilities for strings.
##### Publishing Status
[](https://www.npmjs.com/package/@thebespokepixel/string "npm") [](https://libraries.io/github/thebespokepixel/string "Libraries.io")
[](https://travis-ci.com/thebespokepixel/string "Travis") [](https://github.com/rollup/rollup/wiki/pkg.module "Rollup")##### Development Status
[](https://travis-ci.com/thebespokepixel/string "Travis") [](https://libraries.io/github/thebespokepixel/string "Libraries.io")
[](https://snyk.io/test/github/thebespokepixel/string "Snyk") [](https://codeclimate.com/github/thebespokepixel/string/maintainability "Code-Climate") [](https://codeclimate.com/github/thebespokepixel/string/test_coverage "Code-Climate Coverage")##### Documentation/Help
[](https://inch-ci.org/github/thebespokepixel/string "Inch.io") [](https://twitter.com/thebespokepixel "Twitter")
## Usage
#### Installation```shell
npm install --save @thebespokepixel/string
```#### Example
```js
const bString = require('@thebespokepixel/string')console.log(bString.subScript('String to print'))
```#### .pad(string, char, length)
Pads `string`, using `char` to `length` characters. If length is negative, pads the right rather than the left of `string`. If length is less than `string.length`, it will crop `string` to fit.
#### .toSuperscript(string) | .toSubscript(string)
Prints the string using the alternative super/sub characters available in Unicode (Such as in DejaVu Sans Mono or Source Code Pro). Superscript support is much more complete that Subscript. Unavaiable subscript characters will be printed as `ₓ`. The character `Q` has to be approximated.
TODO: Use compound Unicode overlay characters to better approximate missing chars.
Unless the environment has `TERM_FONT=full` set (see [Term-NG][termNG]) and you have a Unicode terminal font that supports sub/super-script characters, then it will fall back to printing normal characters.
##### Character set (Github display is incomplete)
| Class | Numerals | Symbols | Lower case | Upper case |
|-------------|------------|-----------|----------------------------|----------------------------|
| Basic | `0123456789` | `+-=:()/|. ` | `abcdefghijklmnopqrstuvwxyz` | `ABCDEFGHIJKLMNOPQRSTUVWXYZ` |
| Superscript | `⁰¹²³⁴⁵⁶⁷⁸⁹` | `⁺⁻⁼⁼⁽⁾╵╵⋅ ` | `ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᵍʳˢᵗᵘᵛʷˣʸᶻ` | `ᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴼᴿˢᵀᵁⱽᵂˣʸᶻ` |
| Subscript | `₀₁₂₃₄₅₆₇₈₉` | `₊₋₌₌₍₎╷╷. ` | `ₐₓₓₓₑₓₓₕᵢⱼₖₗₘₙₒₚₓᵣₛₜᵤᵥₓₓₓₓ` | `ᴀʙcᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ` |[termNG]: https://www.npmjs.com/package/term-ng
## Documentation
Full documentation can be found at [https://thebespokepixel.github.io/string/][1][1]: https://thebespokepixel.github.io/string/