optimized arguments handling, moved out of hot zone
This commit is contained in:
parent
b251c00ae3
commit
091e8ed936
1 changed files with 5 additions and 4 deletions
9
index.js
9
index.js
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue