From 943a283fe7279a79bf7076225198a7b7987e1a43 Mon Sep 17 00:00:00 2001 From: Steve Mao Date: Tue, 5 Jan 2016 23:03:55 +1100 Subject: [PATCH] merge two almost the same snippets --- index.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 5714447..f2377a2 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,7 @@ Object.keys(ansiStyles).forEach(function (key) { styles[key] = { get: function () { - return build.call(this, this._styles.concat(key)); + return build.call(this, this._styles ? this._styles.concat(key) : [key]); } }; }); @@ -87,21 +87,7 @@ function applyStyle() { return str; } -function init() { - var ret = {}; - - Object.keys(styles).forEach(function (name) { - ret[name] = { - get: function () { - return build.call(this, [name]); - } - }; - }); - - return ret; -} - -defineProps(Chalk.prototype, init()); +defineProps(Chalk.prototype, styles); module.exports = new Chalk(); module.exports.styles = ansiStyles;