UNPKG

1.22 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.sectionHeader = exports.listItem = void 0;
7
8var _colors = _interopRequireDefault(require("colors"));
9
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12const bulletPoint = ` • `;
13const arrow = ` └> `;
14const genericRowPad = ` `;
15
16const shouldNewLine = condition => condition ? '\n' : '';
17
18const createListItem = values => {
19 const [first, second, ...rest] = values;
20 let value = `${bulletPoint}${first}${shouldNewLine(!!second)}`;
21
22 if (second) {
23 value += `${arrow}${second}${shouldNewLine(rest.length > 0)}`;
24 }
25
26 if (rest.length > 0) {
27 rest.forEach((r, i) => {
28 value += `${genericRowPad}${r}${shouldNewLine(i !== rest.length - 1)}`;
29 });
30 }
31
32 return _colors.default.bold(value);
33};
34
35const listItem = (...values) => {
36 const validItems = values.map(o => {
37 if (!o) return '';
38 return o;
39 }).filter(o => !!o);
40 console.log(createListItem(validItems));
41};
42
43exports.listItem = listItem;
44
45const sectionHeader = title => {
46 console.log(_colors.default.green(`===> ${_colors.default.bold(title)} <===`));
47};
48
49exports.sectionHeader = sectionHeader;
\No newline at end of file