UNPKG

1.51 kBJavaScriptView Raw
1
2/**
3 * Module requirements.
4 */
5
6var Table = require('cli-table');
7
8/**
9 * Example.
10 */
11
12/* col widths */
13var table = new Table({
14 head: ['Rel', 'Change', 'By', 'When']
15 , colWidths: [6, 21, 25, 17]
16});
17
18table.push(
19 ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago']
20 , ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago']
21);
22
23console.log(table.toString());
24
25
26/* compact */
27var table = new Table({
28 head: ['Rel', 'Change', 'By', 'When']
29 , colWidths: [6, 21, 25, 17]
30 , style : {compact : true, 'padding-left' : 1}
31});
32
33table.push(
34 ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago']
35 , ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago']
36 , []
37 , ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago']
38);
39
40console.log(table.toString());
41
42/* headless */
43var headless_table = new Table();
44headless_table.push(['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago']);
45console.log(headless_table.toString());
46
47/* vertical */
48var vertical_table = new Table();
49vertical_table.push({ "Some Key": "Some Value"},
50 { "Another much longer key": "And its corresponding longer value"}
51);
52
53console.log(vertical_table.toString());
54
55/* cross */
56var cross_table = new Table({ head: ["", "Header #1", "Header #2"] });
57cross_table.push({ "Header #3": ["Value 1", "Value 2"] },
58 { "Header #4": ["Value 3", "Value 4"] });
59console.log(cross_table.toString());
\No newline at end of file