From e5b69d9e438f102bbb9aae495d3ec30fda9282b5 Mon Sep 17 00:00:00 2001 From: Maxime Allanic Date: Mon, 27 Apr 2020 14:15:04 +0200 Subject: [PATCH] [ADD] some optimization --- source/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/index.js b/source/index.js index 032e6aa..f16c054 100644 --- a/source/index.js +++ b/source/index.js @@ -136,10 +136,12 @@ const createStyler = (open, close, parent) => { const createBuilder = (self, _styler, _isEmpty) => { const builder = (...arguments_) => { if (arguments_.length === 1) { - return applyStyle(builder, String(arguments_[0])); + // Single argument is hot path, implicit coercion is faster than anything + // eslint-disable-next-line no-implicit-coercion + return applyStyle(builder, '' + arguments_[0]); } - const [firstString] = arguments_; + const firstString = arguments_[0]; if (!Array.isArray(firstString)) { // If chalk() was called by itself or with a string,