🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

stream-xml

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-xml - npm Package Compare versions

Comparing version

to
0.5.0

@@ -55,2 +55,13 @@ /// <reference types="node" />

/**
* Aborts parsing the current input. If you're using streams,
* this means all further chunks get ignored unless you call
* `reset`. The `parse` method automatically calls `reset`
* after the entire input string is parsed.
*/
abort(): void;
/**
* Resets the parser to its initial state.
*/
reset(): void;
/**
* Returns the attributes of the node that is currently being entered.

@@ -57,0 +68,0 @@ * This method can only be called from inside the enter callback of a node.

@@ -53,2 +53,3 @@ "use strict";

#textEncoder = new TextEncoder();
#aborted = false;
/**

@@ -105,2 +106,3 @@ * Create a new Parser.

this._parse(0, buffer.length);
this.reset();
}

@@ -124,2 +126,5 @@ push(chunk) {

for (let i = start; i < end; i++) {
if (this.#aborted) {
break;
}
const char = this.#buffer[i];

@@ -220,2 +225,24 @@ const lastChar = this.#buffer[i - 1] ?? 0;

/**
* Aborts parsing the current input. If you're using streams,
* this means all further chunks get ignored unless you call
* `reset`. The `parse` method automatically calls `reset`
* after the entire input string is parsed.
*/
abort() {
this.#aborted = true;
}
/**
* Resets the parser to its initial state.
*/
reset() {
this.#bufferPos = 0;
this.#state = StateType.Init;
this.#stateStartPos = 0;
this.#stateEndPos = 0;
this.#attributeEndPos = 0;
this.#stateCommentChar = 0;
this.#resetPos = 0;
this.#aborted = false;
}
/**
* Returns the attributes of the node that is currently being entered.

@@ -222,0 +249,0 @@ * This method can only be called from inside the enter callback of a node.

@@ -8,3 +8,4 @@ /// <reference types="node" />

constructor(options?: Options);
_write(chunk: any, _encoding: BufferEncoding, next: (error?: Error | null | undefined) => void): void;
_write(chunk: any, _encoding: BufferEncoding, next: (error?: Error | null) => void): void;
_final(callback: (error?: Error | null) => void): void;
}

@@ -16,3 +16,7 @@ "use strict";

}
_final(callback) {
this.parser.reset();
callback();
}
}
exports.StreamParser = StreamParser;

@@ -8,3 +8,3 @@ {

},
"version": "0.4.0",
"version": "0.5.0",
"main": "dist/index.js",

@@ -11,0 +11,0 @@ "license": "MIT",