html-template-tag-stream
Advanced tools
Comparing version 1.1.2 to 2.0.0
@@ -21,2 +21,4 @@ // src/libs/chars.ts | ||
var htmlPrototype = Object.getPrototypeOf(html); | ||
var GeneratorFunction = function* () { | ||
}.constructor; | ||
function* typeChecker(sub, isRawHtml) { | ||
@@ -29,2 +31,8 @@ const type = typeof sub; | ||
yield "" + sub; | ||
} else if (Array.isArray(sub) || sub instanceof GeneratorFunction && (sub = sub())) { | ||
for (const s of sub) { | ||
for (const x of typeChecker(s, isRawHtml)) { | ||
yield x; | ||
} | ||
} | ||
} else if (sub instanceof Function) { | ||
@@ -34,8 +42,2 @@ for (const s of typeChecker(sub(), isRawHtml)) { | ||
} | ||
} else if (Array.isArray(sub)) { | ||
for (const s of sub) { | ||
for (const x of typeChecker(s, true)) { | ||
yield x; | ||
} | ||
} | ||
} else if (sub.constructor === htmlPrototype) { | ||
@@ -42,0 +44,0 @@ for (const s of sub) { |
@@ -21,2 +21,4 @@ // src/libs/chars.ts | ||
var htmlPrototype = Object.getPrototypeOf(html); | ||
var GeneratorFunction = function* () { | ||
}.constructor; | ||
async function* typeChecker(sub, isRawHtml) { | ||
@@ -29,2 +31,8 @@ const type = typeof sub, isPromise = sub instanceof Promise; | ||
yield "" + sub; | ||
} else if (Array.isArray(sub) || sub instanceof GeneratorFunction && (sub = sub())) { | ||
for await (const s of sub) { | ||
for await (const x of typeChecker(s, isRawHtml)) { | ||
yield x; | ||
} | ||
} | ||
} else if (isPromise || sub instanceof Function) { | ||
@@ -35,8 +43,2 @@ sub = isPromise ? await sub : sub(); | ||
} | ||
} else if (Array.isArray(sub)) { | ||
for await (const s of sub) { | ||
for await (const x of typeChecker(s, true)) { | ||
yield x; | ||
} | ||
} | ||
} else if (sub.constructor === htmlPrototype) { | ||
@@ -43,0 +45,0 @@ for await (const s of sub) { |
{ | ||
"name": "html-template-tag-stream", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"description": "ES6 Tagged Template for compiling HTML template streams.", | ||
@@ -41,3 +41,6 @@ "main": "./lib/index.js", | ||
"author": "Jon Nyman", | ||
"license": "ISC" | ||
"license": "ISC", | ||
"devDependencies": { | ||
"typescript": "^5.1.6" | ||
} | ||
} |
8345
131
1