merge two almost the same snippets
This commit is contained in:
parent
fb3aa8e234
commit
943a283fe7
1 changed files with 2 additions and 16 deletions
18
index.js
18
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue