npm.io
1.0.3 โ€ข Published 4 years ago

variant.js

Licence
MIT
Version
1.0.3
Deps
0
Size
8 kB
Vulns
0
Weekly
0

variant.js

Install

npm i variant.js

Info

Convert a string into different kind of Unicode variants. Created to show some "cool" styled text in the browsers built-in alert(), prompt() and confirm() dialogs.

Variant Alias Description Example
monospace m Monospace ๐š–๐š˜๐š—๐š˜๐šœ๐š™๐šŠ๐šŒ๐šŽ
bold b Bold text ๐›๐จ๐ฅ๐
italic if Italic text ๐‘–๐‘ก๐‘Ž๐‘™๐‘–๐‘
bold italic bi bold+italic text ๐’ƒ๐’๐’๐’… ๐’Š๐’•๐’‚๐’๐’Š๐’„
script c Handwriting style ๐“ˆ๐’ธ๐“‡๐’พ๐“…๐“‰
bold script bc Bolder handwriting ๐“ซ๐“ธ๐“ต๐“ญ ๐“ผ๐“ฌ๐“ป๐“ฒ๐“น๐“ฝ
gothic g Gothic (fraktur) ๐”ค๐”ฌ๐”ฑ๐”ฅ๐”ฆ๐” 
gothic bold gb Gothic in bold ๐–Œ๐–”๐–™๐–๐–Ž๐–ˆ ๐–‡๐–”๐–‘๐–‰
doublestruck d Outlined text ๐••๐• ๐•ฆ๐•“๐•๐•–๐•ค๐•ฅ๐•ฃ๐•ฆ๐•”๐•œ
๐—Œ๐–บ๐—‡๐—Œ s Sans-serif style ๐—Œ๐–บ๐—‡๐—Œ
bold ๐—Œ๐–บ๐—‡๐—Œ bs Bold sans-serif ๐—ฏ๐—ผ๐—น๐—ฑ ๐˜€๐—ฎ๐—ป๐˜€
italic ๐—Œ๐–บ๐—‡๐—Œ is Italic sans-serif ๐˜ช๐˜ต๐˜ข๐˜ญ๐˜ช๐˜ค ๐˜ด๐˜ข๐˜ฏ๐˜ด
bold italic sans bis Bold italic sans-serif ๐™—๐™ค๐™ก๐™™ ๐™ž๐™ฉ๐™–๐™ก๐™ž๐™˜ ๐™จ๐™–๐™ฃ๐™จ
circled o Letters within circles โ“’โ“˜โ“กโ“’โ“›โ“”โ““
paranthesis p Letters within paranthesis โ’ซโ’œโ’ญโ’ โ’ฉโ’ฏโ’ฃโ’ โ’ฎโ’ค
fullwidth w Wider monospace font ๏ฝ†๏ฝ•๏ฝŒ๏ฝŒ๏ฝ—๏ฝ‰๏ฝ„๏ฝ”๏ฝˆ

The text can be enriched with underline or strike (or both) through the flags param:

Variant Flags Example
gothic underline ๐”คฬฒ๐”ฌฬฒ๐”ฑฬฒ๐”ฅฬฒ๐”ฆฬฒ๐” ฬฒ
paranthesis strike ๐š™ฬถ๐šŠฬถ๐š›ฬถ๐šŠฬถ๐š—ฬถ๐šฬถ๐š‘ฬถ๐šŽฬถ๐šœฬถ๐š’ฬถ๐šœฬถ
Example
const variant = require("variant.js");

console.log(variant.format("Hello World", "monospace", "strike")); // "๐™ทฬถ๐šŽฬถ๐š•ฬถ๐š•ฬถ๐š˜ฬถโ€€ฬถ๐š†ฬถ๐š˜ฬถ๐š›ฬถ๐š•ฬถ๐šฬถ"
Notes
  • There is no support for special chars such as &, % and so on.
  • Not all combinations of variants and flags is guaranteed to work.
  • Some variants does not support numbers some variants does not support capital or small letters.

Keywords