wide-align
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
string-width | 2.1.1 | 1.93 kB | MIT | prod |
The "wide-align" is an npm package that provides a wide-character aware text alignment functionality. This is particularly useful for aligning text in terminals or on the console.
To use "wide-align", you first need to install it via npm. Once installed, you can use it in your JavaScript code by requiring the module and then using the align
object's methods (center
, left
, and right
) as demonstrated below:
var align = require('wide-align')
console.log(align.center('abc', 10)) // Outputs: ' abc '
console.log(align.center('古古古', 10)) // Outputs: ' 古古古 '
console.log(align.left('abc', 10)) // Outputs: 'abc '
console.log(align.left('古古古', 10)) // Outputs: '古古古 '
console.log(align.right('abc', 10)) // Outputs: ' abc'
console.log(align.right('古古古', 10)) // Outputs: ' 古古古'
In these examples, the text strings are aligned based on a defined length. The center
method aligns the text to the center, adding spaces to both sides. The left
method aligns the text to the left and adds spaces to the right to reach the defined length, while the right
method aligns the text to the right, adding spaces to the left.
As for documentation, the package's README file serves as its primary documentation. It describes what "wide-align" does and gives usage examples. No separate documentation link is mentioned in the README hence, it's safe to assume that the README contains all the necessary details about the package. The project repository can be visited on GitHub at git+https://github.com/iarna/wide-align.git for more details or any additional updates.