JSPM

  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q63730F
  • License MIT

Esoteric string formatting

Package Exports

  • @thebespokepixel/string

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@thebespokepixel/string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@thebespokepixel/string

A collection of enhanced formats and utilities for strings.

Project status npm Status XO code style Chat on Gitter
Build Status Dependency Status devDependency Status

Designed to curate esoteric and eclectic Unicode string manipulations, plus some more generally helpful utilities.

Install

npm install @thebespokepixel/string --save

Usage

const bString = require('@thebespokepixel/string')

console.log(bString.subScript('String to print'))

API

.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) 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
Superscript ⁰¹²³⁴⁵⁶⁷⁸⁹ ⁺⁻⁼⁼⁽⁾╵╵⋅ ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᵍʳˢᵗᵘᵛʷˣʸᶻ ᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴼᴿˢᵀᵁⱽᵂˣʸᶻ
Subscript ₀₁₂₃₄₅₆₇₈₉ ₊₋₌₌₍₎╷╷. ₐₓₓₓₑₓₓₕᵢⱼₖₗₘₙₒₚₓᵣₛₜᵤᵥₓₓₓₓ ᴀʙcᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ