text-align
!
version



!
build
A wide-character aware text alignment function for use in terminals / on the console. This package is a modern implementation of
wide-align with String.prototype.padLeft and String.prototype.padRight.
Requirements
-
Node.js v14 or higher
Getting Started
This package is available in the Node Package Repository and can be easily installed with
npm or
yarn.
``
bash
$ npm i @topcli/text-align
or
$ yarn add @topcli/text-align
`
$3
`
js
import * as align from "@topcli/text-align";
console.log(align.center('abc', 10)); // ' abc '
console.log(align.center('古古古', 10)); // ' 古古古 '
console.log(align.left('abc', 10)); // 'abc '
console.log(align.left('古古古', 10)); // '古古古 '
console.log(align.right('abc', 10)); // ' abc'
console.log(align.right('古古古', 10)); // ' 古古古'
``
API
$3
Returns
str with spaces added to both sides such that that it is
length
chars long and centered in the spaces.
$3
Returns
str with spaces to the right such that it is
length chars long.
$3
Returns
str with spaces to the left such that it is
length chars long.
Contributors ✨

Thanks goes to these wonderful people (
emoji key):
License
MIT