Created
April 7, 2017 16:04
-
-
Save RafaPegorari/0aa93483839e12c49afb19d39f3de5ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Color | |
* | |
* @author: Rafael Pegorari <[email protected]> | |
* @copyright Copyright (c) 2015-2017, MEANStack.io. | |
* @license See LICENSE | |
* MIT Licensed | |
*/ | |
'use strict'; | |
/** | |
* Module dependencies. | |
*/ | |
var util = require('util'); | |
/** | |
* Style of color for console. | |
* | |
* @returns {{}} | |
* @constructor | |
*/ | |
class Color { | |
constructor() { | |
/** | |
* Colors | |
* | |
* @type {{red: string, green: string, yellow: string, blue: string, black: string}} | |
*/ | |
this.colors = { | |
red: '\x1B[31m', | |
green: '\x1B[32m', | |
yellow: '\x1B[33m', | |
blue: '\x1B[34m', | |
black: '\x1B[39m' | |
}; | |
return this.generate(); | |
} | |
/** | |
* Generate method colors. | |
* | |
* @returns {{}} | |
*/ | |
generate () { | |
let methods = {}; | |
Object.keys(this.colors).forEach((index) => { | |
return methods[index] = (str) => { | |
return util.format('%s%s%s', this.colors[index], str, this.colors.black); | |
} | |
}); | |
return methods; | |
}; | |
} | |
module.exports = new Color(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment