From 0d9c54df99c3916f0bb5bcdb0f433070ae4928e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Thu, 4 Apr 2024 07:47:07 +0200 Subject: [PATCH 1/5] perf: assume literals.raw is not empty --- src/html.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/html.js b/src/html.js index 6384f5a..265980b 100644 --- a/src/html.js +++ b/src/html.js @@ -23,10 +23,6 @@ const escapeFunction = (key) => { const html = (literals, ...expressions) => { let accumulator = ""; - if (!literals.raw.length) { - return accumulator; - } - for (let index = 0; index < expressions.length; ++index) { let literal = literals.raw[index]; let expression = @@ -47,7 +43,7 @@ const html = (literals, ...expressions) => { accumulator += literal + expression; } - accumulator += literals.raw[expressions.length]; + accumulator += literals.raw[expressions.length] ?? ""; return accumulator; }; From 7a1377dd7b4af0f28687e9a9e33214aa03157f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Thu, 4 Apr 2024 08:11:02 +0200 Subject: [PATCH 2/5] perf: assume array is of strings --- src/html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/html.js b/src/html.js index 265980b..1ab47cf 100644 --- a/src/html.js +++ b/src/html.js @@ -43,7 +43,7 @@ const html = (literals, ...expressions) => { accumulator += literal + expression; } - accumulator += literals.raw[expressions.length] ?? ""; + accumulator += literals.raw[expressions.length]; return accumulator; }; From e25ddf538be557ff248cc93c8a9e964b7716270e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Thu, 4 Apr 2024 08:15:12 +0200 Subject: [PATCH 3/5] format includeFile --- src/includeFile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/includeFile.js b/src/includeFile.js index 8b48070..e55ab3d 100644 --- a/src/includeFile.js +++ b/src/includeFile.js @@ -1,7 +1,6 @@ import { readFileSync } from "node:fs"; const readFileSyncOptions = { encoding: "utf8" }; - const fileCache = new Map(); /** From b587907866cf5fed7a390a28b1fe1cb6a174763f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Thu, 4 Apr 2024 08:15:18 +0200 Subject: [PATCH 4/5] fix test --- test/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/index.js b/test/index.js index f2e4941..1cf3843 100644 --- a/test/index.js +++ b/test/index.js @@ -12,7 +12,7 @@ const conditionFalse = false; const emptyString = ""; test("renders empty input", () => { - assert.strictEqual(html({ raw: [] }), ""); + assert.strictEqual(html({ raw: [""] }), ""); }); test("renders empty input", () => { From cab68c5bcb0712aaa07cb54e8f2e1075e93250c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Thu, 4 Apr 2024 09:23:32 +0200 Subject: [PATCH 5/5] v1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 94e6616..ba5fe2e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Replace your template engine with fast JavaScript by leveraging the power of tagged templates.", "author": "Gürgün Dayıoğlu", "license": "MIT", - "version": "1.0.1", + "version": "1.1.0", "type": "module", "main": "./src/index.js", "exports": {