stream-xml
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -18,2 +18,11 @@ "use strict"; | ||
const isWhitespace = (char) => char === BLANK || char === TAB || char === RETURN || char === NEWLINE; | ||
/** | ||
* Checks if two Uint8Arrays are equal | ||
*/ | ||
const isEqual = (a, b) => { | ||
if (a.length !== b.length) { | ||
return false; | ||
} | ||
return a.every((d, i) => d === b[i]); | ||
}; | ||
var StateType; | ||
@@ -44,2 +53,3 @@ (function (StateType) { | ||
#textDecoder; | ||
#textEncoder = new TextEncoder(); | ||
/** | ||
@@ -70,3 +80,3 @@ * Create a new Parser. | ||
this.#callbacks.push({ | ||
tagName: Buffer.from(tagName), | ||
tagName: this.#textEncoder.encode(tagName), | ||
enter, | ||
@@ -306,3 +316,3 @@ exit, | ||
for (const cb of this.#callbacks) { | ||
if (Buffer.compare(this.#buffer.subarray(nameStart, nameEnd), cb.tagName) === 0) { | ||
if (isEqual(this.#buffer.subarray(nameStart, nameEnd), cb.tagName)) { | ||
if (enter) { | ||
@@ -309,0 +319,0 @@ cb.enter(); |
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"main": "dist/index.js", | ||
@@ -11,0 +11,0 @@ "license": "MIT", |
19654
440