"use strict"
const htmlparser = require("htmlparser2")
const TransformableString = require("./TransformableString")
const NO_IGNORE = 0
const IGNORE_NEXT = 1
const IGNORE_UNTIL_ENABLE = 2
function iterateScripts(code, options, onChunk) {
if (!code) return
const xmlMode = options.xmlMode
const isJavaScriptMIMEType = options.isJavaScriptMIMEType || (() => true)
const javaScriptTagNames = options.javaScriptTagNames || ["script"]
let index = 0
let inScript = false
let cdata = []
let ignoreState = NO_IGNORE
const chunks = []
function pushChunk(type, end) {
chunks.push({ type, start: index, end, cdata })
cdata = []
index = end
}
const parser = new htmlparser.Parser(
{
onopentag(name, attrs) {
// Test if current tag is a valid