ghtml 3.1.1 → 3.1.2

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +18 -18
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.1",
6
+ "version": "3.1.2",
7
7
  "type": "commonjs",
8
8
  "bin": "./bin/src/index.js",
9
9
  "main": "./src/index.js",
@@ -27,7 +27,7 @@
27
27
  "devDependencies": {
28
28
  "@fastify/pre-commit": "^2.2.0",
29
29
  "c8": "^10.1.2",
30
- "globals": "^15.13.0",
30
+ "globals": "^16.0.0",
31
31
  "grules": "^0.26.1",
32
32
  "tinybench": "^3.0.7",
33
33
  "typescript": ">=5.7.2"
package/src/index.js CHANGED
@@ -63,9 +63,9 @@ const html = (literals, ...expressions) => {
63
63
  ? expressions[i].join("")
64
64
  : `${expressions[i] ?? ""}`;
65
65
 
66
- if (literal.length !== 0 && literal.charCodeAt(literal.length - 1) === 33) {
66
+ if (literal.length && literal.charCodeAt(literal.length - 1) === 33) {
67
67
  literal = literal.slice(0, -1);
68
- } else if (string.length !== 0) {
68
+ } else if (string.length) {
69
69
  string = escapeFunction(string);
70
70
  }
71
71
 
@@ -94,13 +94,13 @@ const htmlGenerator = function* (literals, ...expressions) {
94
94
  } else {
95
95
  if (typeof expression[Symbol.iterator] === "function") {
96
96
  const isRaw =
97
- literal.length !== 0 && literal.charCodeAt(literal.length - 1) === 33;
97
+ literal.length && literal.charCodeAt(literal.length - 1) === 33;
98
98
 
99
99
  if (isRaw) {
100
100
  literal = literal.slice(0, -1);
101
101
  }
102
102
 
103
- if (literal.length !== 0) {
103
+ if (literal.length) {
104
104
  yield literal;
105
105
  }
106
106
 
@@ -120,7 +120,7 @@ const htmlGenerator = function* (literals, ...expressions) {
120
120
 
121
121
  string = `${expression}`;
122
122
 
123
- if (string.length !== 0) {
123
+ if (string.length) {
124
124
  if (!isRaw) {
125
125
  string = escapeFunction(string);
126
126
  }
@@ -135,7 +135,7 @@ const htmlGenerator = function* (literals, ...expressions) {
135
135
  string = `${expression}`;
136
136
  }
137
137
 
138
- if (string.length !== 0) {
138
+ if (string.length) {
139
139
  if (!isRaw) {
140
140
  string = escapeFunction(string);
141
141
  }
@@ -150,18 +150,18 @@ const htmlGenerator = function* (literals, ...expressions) {
150
150
  string = `${expression}`;
151
151
  }
152
152
 
153
- if (literal.length !== 0 && literal.charCodeAt(literal.length - 1) === 33) {
153
+ if (literal.length && literal.charCodeAt(literal.length - 1) === 33) {
154
154
  literal = literal.slice(0, -1);
155
- } else if (string.length !== 0) {
155
+ } else if (string.length) {
156
156
  string = escapeFunction(string);
157
157
  }
158
158
 
159
- if (literal.length !== 0 || string.length !== 0) {
159
+ if (literal.length || string.length) {
160
160
  yield literal + string;
161
161
  }
162
162
  }
163
163
 
164
- if (literals.raw[expressions.length].length !== 0) {
164
+ if (literals.raw[expressions.length].length) {
165
165
  yield literals.raw[expressions.length];
166
166
  }
167
167
  };
@@ -188,13 +188,13 @@ const htmlAsyncGenerator = async function* (literals, ...expressions) {
188
188
  typeof expression[Symbol.asyncIterator] === "function"
189
189
  ) {
190
190
  const isRaw =
191
- literal.length !== 0 && literal.charCodeAt(literal.length - 1) === 33;
191
+ literal.length && literal.charCodeAt(literal.length - 1) === 33;
192
192
 
193
193
  if (isRaw) {
194
194
  literal = literal.slice(0, -1);
195
195
  }
196
196
 
197
- if (literal.length !== 0) {
197
+ if (literal.length) {
198
198
  yield literal;
199
199
  }
200
200
 
@@ -217,7 +217,7 @@ const htmlAsyncGenerator = async function* (literals, ...expressions) {
217
217
 
218
218
  string = `${expression}`;
219
219
 
220
- if (string.length !== 0) {
220
+ if (string.length) {
221
221
  if (!isRaw) {
222
222
  string = escapeFunction(string);
223
223
  }
@@ -232,7 +232,7 @@ const htmlAsyncGenerator = async function* (literals, ...expressions) {
232
232
  string = `${expression}`;
233
233
  }
234
234
 
235
- if (string.length !== 0) {
235
+ if (string.length) {
236
236
  if (!isRaw) {
237
237
  string = escapeFunction(string);
238
238
  }
@@ -247,18 +247,18 @@ const htmlAsyncGenerator = async function* (literals, ...expressions) {
247
247
  string = `${expression}`;
248
248
  }
249
249
 
250
- if (literal.length !== 0 && literal.charCodeAt(literal.length - 1) === 33) {
250
+ if (literal.length && literal.charCodeAt(literal.length - 1) === 33) {
251
251
  literal = literal.slice(0, -1);
252
- } else if (string.length !== 0) {
252
+ } else if (string.length) {
253
253
  string = escapeFunction(string);
254
254
  }
255
255
 
256
- if (literal.length !== 0 || string.length !== 0) {
256
+ if (literal.length || string.length) {
257
257
  yield literal + string;
258
258
  }
259
259
  }
260
260
 
261
- if (literals.raw[expressions.length].length !== 0) {
261
+ if (literals.raw[expressions.length].length) {
262
262
  yield literals.raw[expressions.length];
263
263
  }
264
264
  };