optimized arguments handling, moved out of hot zone

This commit is contained in:
Yanis Benson 2019-03-26 18:13:31 +03:00
parent b251c00ae3
commit 091e8ed936

View file

@ -178,7 +178,10 @@ const proto = Object.defineProperties(() => {}, {
});
const createBuilder = (self, _styles, _isEmpty) => {
const builder = (...arguments_) => applyStyle(builder, ...arguments_);
const builder = (...arguments_) => {
// eslint-disable-next-line no-implicit-coercion
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
};
// `__proto__` is used because we must return a function, but there is
// no way to create a function with a different prototype
@ -191,9 +194,7 @@ const createBuilder = (self, _styles, _isEmpty) => {
return builder;
};
const applyStyle = (self, ...arguments_) => {
let string = arguments_.join(' ');
const applyStyle = (self, string) => {
if (!self.enabled || self.level <= 0 || !string) {
return self._isEmpty ? '' : string;
}