ghtml 2.0.1 → 2.0.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.
package/.eslintrc.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "root": true,
3
3
  "extends": ["plugin:grules/all"],
4
4
  "rules": {
5
- "no-await-in-loop": "off"
5
+ "no-await-in-loop": "off",
6
+ "require-unicode-regexp": "off"
6
7
  }
7
8
  }
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": "2.0.1",
6
+ "version": "2.0.2",
7
7
  "type": "module",
8
8
  "main": "./src/index.js",
9
9
  "exports": {
package/src/html.js CHANGED
@@ -1,3 +1,9 @@
1
+ const arrayIsArray = Array.isArray;
2
+
3
+ const symbolIterator = Symbol.iterator;
4
+
5
+ const symbolAsyncIterator = Symbol.asyncIterator;
6
+
1
7
  const escapeDictionary = {
2
8
  '"': """,
3
9
  "&": "&",
@@ -7,10 +13,7 @@ const escapeDictionary = {
7
13
  "`": "`",
8
14
  };
9
15
 
10
- const escapeRegExp = new RegExp(
11
- `[${Object.keys(escapeDictionary).join("")}]`,
12
- "u",
13
- );
16
+ const escapeRegExp = new RegExp(`[${Object.keys(escapeDictionary).join("")}]`);
14
17
 
15
18
  const escapeFunction = (string) => {
16
19
  const stringLength = string.length;
@@ -30,8 +33,6 @@ const escapeFunction = (string) => {
30
33
  return escaped + string.slice(start, end);
31
34
  };
32
35
 
33
- const arrayIsArray = Array.isArray;
34
-
35
36
  /**
36
37
  * @param {{ raw: string[] }} literals Tagged template literals.
37
38
  * @param {...any} expressions Expressions to interpolate.
@@ -85,7 +86,7 @@ const htmlGenerator = function* ({ raw: literals }, ...expressions) {
85
86
  } else if (expression === undefined || expression === null) {
86
87
  string = "";
87
88
  } else {
88
- if (expression[Symbol.iterator]) {
89
+ if (expression[symbolIterator]) {
89
90
  const isRaw =
90
91
  literal !== "" && literal.charCodeAt(literal.length - 1) === 33;
91
92
 
@@ -105,7 +106,7 @@ const htmlGenerator = function* ({ raw: literals }, ...expressions) {
105
106
  continue;
106
107
  }
107
108
 
108
- if (expression[Symbol.iterator]) {
109
+ if (expression[symbolIterator]) {
109
110
  for (expression of expression) {
110
111
  if (typeof expression === "string") {
111
112
  string = expression;
@@ -182,7 +183,7 @@ const htmlAsyncGenerator = async function* ({ raw: literals }, ...expressions) {
182
183
  } else if (expression === undefined || expression === null) {
183
184
  string = "";
184
185
  } else {
185
- if (expression[Symbol.iterator] || expression[Symbol.asyncIterator]) {
186
+ if (expression[symbolIterator] || expression[symbolAsyncIterator]) {
186
187
  const isRaw =
187
188
  literal !== "" && literal.charCodeAt(literal.length - 1) === 33;
188
189
 
@@ -202,10 +203,7 @@ const htmlAsyncGenerator = async function* ({ raw: literals }, ...expressions) {
202
203
  continue;
203
204
  }
204
205
 
205
- if (
206
- expression[Symbol.iterator] ||
207
- expression[Symbol.asyncIterator]
208
- ) {
206
+ if (expression[symbolIterator] || expression[symbolAsyncIterator]) {
209
207
  for await (expression of expression) {
210
208
  if (typeof expression === "string") {
211
209
  string = expression;