feat: add components
This commit is contained in:
41
components/component-colorprint-ex.js
Normal file
41
components/component-colorprint-ex.js
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
var HEADER = '\033[95m';
|
||||
var OKBLUE = '\033[94m';
|
||||
var OKGREEN = '\033[92m';
|
||||
var WARNING = '\033[93m';
|
||||
var FAIL = '\033[91m';
|
||||
var BOLD = '\033[1m';
|
||||
var UNDERLINE = '\033[4m';
|
||||
var ENDC = '\033[0m';
|
||||
|
||||
var colorMapping = {
|
||||
"header": HEADER,
|
||||
"okblue": OKBLUE,
|
||||
"okgreen": OKGREEN,
|
||||
"warning": WARNING,
|
||||
"fail": FAIL,
|
||||
"bold": BOLD,
|
||||
"underline": UNDERLINE,
|
||||
"none": null // nothing special
|
||||
};
|
||||
|
||||
var colorPrint = exports;
|
||||
|
||||
for (var k in colorMapping) {
|
||||
colorPrint[k] = {};
|
||||
colorPrint[k].render = ((k) => {
|
||||
return (x) => {
|
||||
return colorMapping[k] ? (colorMapping[k] + x + ENDC) : x;
|
||||
};
|
||||
})(k);
|
||||
colorPrint[k].print = ((k) => {
|
||||
return (x) => {
|
||||
print(colorPrint[k].render(x));
|
||||
};
|
||||
})(k);
|
||||
colorPrint[k].println = ((k) => {
|
||||
return (x) => {
|
||||
println(colorPrint[k].render(x));
|
||||
};
|
||||
})(k);
|
||||
}
|
||||
Reference in New Issue
Block a user