Security update to Drupal 8.4.6
[yaffs-website] / node_modules / wide-align / README.md
1 wide-align
2 ----------
3
4 A wide-character aware text alignment function for use in terminals / on the
5 console.
6
7 ### Usage
8
9 ```
10 var align = require('wide-align')
11
12 // Note that if you view this on a unicode console, all of the slashes are
13 // aligned. This is because on a console, all narrow characters are
14 // an en wide and all wide characters are an em. In browsers, this isn't
15 // held to and wide characters like "古" can be less than two narrow
16 // characters even with a fixed width font.
17
18 console.log(align.center('abc', 10))     // '   abc    '
19 console.log(align.center('古古古', 10))  // '  古古古  '
20 console.log(align.left('abc', 10))       // 'abc       '
21 console.log(align.left('古古古', 10))    // '古古古    '
22 console.log(align.right('abc', 10))      // '       abc'
23 console.log(align.right('古古古', 10))   // '    古古古'
24 ```
25
26 ### Functions
27
28 #### `align.center(str, length)` → `str`
29
30 Returns *str* with spaces added to both sides such that that it is *length*
31 chars long and centered in the spaces.
32
33 #### `align.left(str, length)` → `str`
34
35 Returns *str* with spaces to the right such that it is *length* chars long.
36
37 ### `align.right(str, length)` → `str`
38
39 Returns *str* with spaces to the left such that it is *length* chars long.
40
41 ### Origins
42
43 These functions were originally taken from 
44 [cliui](https://npmjs.com/package/cliui). Changes include switching to the
45 MUCH faster pad generation function from
46 [lodash](https://npmjs.com/package/lodash), making center alignment pad
47 both sides and adding left alignment.