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 +0 -1
- package/package.json +2 -2
- package/src/index.js +15 -11
package/bench/index.js
CHANGED
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.
|
|
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": "^
|
|
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 =
|
|
63
|
-
|
|
64
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
218
|
+
if (expression == null) {
|
|
215
219
|
continue;
|
|
216
220
|
}
|
|
217
221
|
|