UNPKG

flow-typed

Version:

A repository of high quality flow type definitions

49 lines (36 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sectionHeader = exports.listItem = void 0; var _colors = _interopRequireDefault(require("colors")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const bulletPoint = ` • `; const arrow = ` └> `; const genericRowPad = ` `; const shouldNewLine = condition => condition ? '\n' : ''; const createListItem = values => { const [first, second, ...rest] = values; let value = `${bulletPoint}${first}${shouldNewLine(!!second)}`; if (second) { value += `${arrow}${second}${shouldNewLine(rest.length > 0)}`; } if (rest.length > 0) { rest.forEach((r, i) => { value += `${genericRowPad}${r}${shouldNewLine(i !== rest.length - 1)}`; }); } return _colors.default.bold(value); }; const listItem = (...values) => { const validItems = values.map(o => { if (!o) return ''; return o; }).filter(o => !!o); console.log(createListItem(validItems)); }; exports.listItem = listItem; const sectionHeader = title => { console.log(_colors.default.green(`===> ${_colors.default.bold(title)} <===`)); }; exports.sectionHeader = sectionHeader;