Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore initial Dec 16, 2015
.travis.yml Add travis config Feb 26, 2017
LICENSE initial Dec 16, 2015
align.js only trim the side we aren't aligning to Jan 8, 2016
package.json 1.1.3 May 24, 2018


A wide-character aware text alignment function for use in terminals / on the console.


var align = require('wide-align')

// Note that if you view this on a unicode console, all of the slashes are
// aligned. This is because on a console, all narrow characters are
// an en wide and all wide characters are an em. In browsers, this isn't
// held to and wide characters like "古" can be less than two narrow
// characters even with a fixed width font.

console.log('abc', 10))     // '   abc    '
console.log('古古古', 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))   // '    古古古'

Functions, length)str

Returns str with spaces added to both sides such that that it is length chars long and centered in the spaces.

align.left(str, length)str

Returns str with spaces to the right such that it is length chars long.

align.right(str, length)str

Returns str with spaces to the left such that it is length chars long.


These functions were originally taken from cliui. Changes include switching to the MUCH faster pad generation function from lodash, making center alignment pad both sides and adding left alignment.

You can’t perform that action at this time.