ghtml 3.1.2 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bench/index.js CHANGED
@@ -105,7 +105,6 @@ bench.add("sparse escape", () => {
105
105
  });
106
106
 
107
107
  (async () => {
108
- await bench.warmup();
109
108
  await bench.run();
110
109
 
111
110
  const table = bench.table();
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Replace your template engine with fast JavaScript by leveraging the power of tagged templates.",
4
4
  "author": "Gürgün Dayıoğlu",
5
5
  "license": "MIT",
6
- "version": "3.1.2",
6
+ "version": "3.1.3",
7
7
  "type": "commonjs",
8
8
  "bin": "./bin/src/index.js",
9
9
  "main": "./src/index.js",
@@ -29,7 +29,7 @@
29
29
  "c8": "^10.1.2",
30
30
  "globals": "^16.0.0",
31
31
  "grules": "^0.26.1",
32
- "tinybench": "^3.0.7",
32
+ "tinybench": "^4.0.1",
33
33
  "typescript": ">=5.7.2"
34
34
  },
35
35
  "repository": {
package/src/index.js CHANGED
@@ -55,13 +55,17 @@ const escapeFunction = (string) => {
55
55
  */
56
56
  const html = (literals, ...expressions) => {
57
57
  let accumulator = "";
58
- let i = 0;
59
58
 
60
- for (; i !== expressions.length; ++i) {
59
+ for (let i = 0; i !== expressions.length; ++i) {
61
60
  let literal = literals.raw[i];
62
- let string = Array.isArray(expressions[i])
63
- ? expressions[i].join("")
64
- : `${expressions[i] ?? ""}`;
61
+ let string =
62
+ typeof expressions[i] === "string"
63
+ ? expressions[i]
64
+ : expressions[i] == null
65
+ ? ""
66
+ : Array.isArray(expressions[i])
67
+ ? expressions[i].join("")
68
+ : `${expressions[i]}`;
65
69
 
66
70
  if (literal.length && literal.charCodeAt(literal.length - 1) === 33) {
67
71
  literal = literal.slice(0, -1);
@@ -89,7 +93,7 @@ const htmlGenerator = function* (literals, ...expressions) {
89
93
 
90
94
  if (typeof expression === "string") {
91
95
  string = expression;
92
- } else if (expression === undefined || expression === null) {
96
+ } else if (expression == null) {
93
97
  string = "";
94
98
  } else {
95
99
  if (typeof expression[Symbol.iterator] === "function") {
@@ -108,13 +112,13 @@ const htmlGenerator = function* (literals, ...expressions) {
108
112
  if (typeof expression === "string") {
109
113
  string = expression;
110
114
  } else {
111
- if (expression === undefined || expression === null) {
115
+ if (expression == null) {
112
116
  continue;
113
117
  }
114
118
 
115
119
  if (typeof expression[Symbol.iterator] === "function") {
116
120
  for (expression of expression) {
117
- if (expression === undefined || expression === null) {
121
+ if (expression == null) {
118
122
  continue;
119
123
  }
120
124
 
@@ -180,7 +184,7 @@ const htmlAsyncGenerator = async function* (literals, ...expressions) {
180
184
 
181
185
  if (typeof expression === "string") {
182
186
  string = expression;
183
- } else if (expression === undefined || expression === null) {
187
+ } else if (expression == null) {
184
188
  string = "";
185
189
  } else {
186
190
  if (
@@ -202,7 +206,7 @@ const htmlAsyncGenerator = async function* (literals, ...expressions) {
202
206
  if (typeof expression === "string") {
203
207
  string = expression;
204
208
  } else {
205
- if (expression === undefined || expression === null) {
209
+ if (expression == null) {
206
210
  continue;
207
211
  }
208
212
 
@@ -211,7 +215,7 @@ const htmlAsyncGenerator = async function* (literals, ...expressions) {
211
215
  typeof expression[Symbol.asyncIterator] === "function"
212
216
  ) {
213
217
  for await (expression of expression) {
214
- if (expression === undefined || expression === null) {
218
+ if (expression == null) {
215
219
  continue;
216
220
  }
217
221