|
| 1 | +const ansi = require("ansi-styles"); |
| 2 | + |
| 3 | +const color = { |
| 4 | + tblclr: (border) => ansi.cyan.open + border + ansi.cyan.close, |
| 5 | + white: (txt) => ansi.white.open + txt + ansi.white.close, |
| 6 | + black: (txt) => ansi.black.open + txt + ansi.black.close, |
| 7 | + green: (txt) => ansi.green.open + txt + ansi.green.close, |
| 8 | + cyan: (txt) => ansi.cyan.open + txt + ansi.cyan.close, |
| 9 | + magenta: (txt) => ansi.magenta.open + txt + ansi.magenta.close, |
| 10 | + yellow: (txt) => ansi.yellow.open + txt + ansi.yellow.close, |
| 11 | + red: (txt) => ansi.red.open + txt + ansi.red.close, |
| 12 | + cyanBright: (txt) => ansi.cyanBright.open + txt + ansi.cyanBright.close, |
| 13 | + magentaBright: (txt) => |
| 14 | + ansi.magentaBright.open + txt + ansi.magentaBright.close, |
| 15 | + redBright: (txt) => ansi.redBright.open + txt + ansi.redBright.close, |
| 16 | + greenBright: (txt) => ansi.greenBright.open + txt + ansi.greenBright.close, |
| 17 | + cyanBG: (txt) => ansi.bgCyan.open + txt + ansi.bgCyan.close, |
| 18 | +}; |
| 19 | +exports.color = color; |
| 20 | + |
| 21 | +exports.txt = { |
| 22 | + line: "-".repeat(60), |
| 23 | + tab: " ", |
| 24 | + space: " ", |
| 25 | + br: "\n", |
| 26 | +}; |
| 27 | + |
| 28 | +exports.formatNumber = (value) => |
| 29 | + value.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); |
| 30 | +exports.ucfirst = (string) => string.charAt(0).toUpperCase() + string.slice(1); |
| 31 | + |
| 32 | +exports.table = { |
| 33 | + borders: { |
| 34 | + top: color.tblclr("═"), |
| 35 | + "top-mid": color.tblclr("╤"), |
| 36 | + "top-left": color.tblclr("╔"), |
| 37 | + "top-right": color.tblclr("╗"), |
| 38 | + bottom: color.tblclr("═"), |
| 39 | + "bottom-mid": color.tblclr("╧"), |
| 40 | + "bottom-left": color.tblclr("╚"), |
| 41 | + "bottom-right": color.tblclr("╝"), |
| 42 | + left: color.tblclr("║"), |
| 43 | + "left-mid": color.tblclr("╟"), |
| 44 | + mid: color.tblclr("─"), |
| 45 | + "mid-mid": color.tblclr("┼"), |
| 46 | + right: color.tblclr("║"), |
| 47 | + "right-mid": color.tblclr("╢"), |
| 48 | + middle: color.tblclr("│"), |
| 49 | + }, |
| 50 | + col5: (txt) => { |
| 51 | + return { colSpan: 5, content: txt } |
| 52 | + }, |
| 53 | +}; |
0 commit comments