UNPKG

902 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.addReset = exports.getNodeStyle = void 0;
4var utils_1 = require("./utils");
5function getNodeStyle(style) {
6 if (typeof style === 'string') {
7 return "\u001B[" + handleUndefined(utils_1.stringColorToAnsiColor('color', style)).replace(/;$/, '') + "m";
8 }
9 else {
10 var codes = "" + (style['font-weight'] === 'bold' ? utils_1.ANSICodes('bold') : '') + handleUndefined(utils_1.stringColorToAnsiColor('color', style.color)) + handleUndefined(utils_1.stringColorToAnsiColor('background', style.background));
11 return "\u001B[" + codes.replace(/;$/, '') + "m";
12 }
13}
14exports.getNodeStyle = getNodeStyle;
15function handleUndefined(input) {
16 return input ? input : '';
17}
18function addReset(input) {
19 return input + "\u001B[" + utils_1.ANSICodes('reset') + "m";
20}
21exports.addReset = addReset;