Compare commits

...

2 Commits

Author SHA1 Message Date
github-actions[bot]
f2a4b80f1e Version Packages 2021-01-28 09:10:39 +01:00
Thomas Allmer
f343c5030a fix(check-html-links): read and parse with the same increased highWaterMark 2021-01-28 09:02:56 +01:00
3 changed files with 13 additions and 5 deletions

View File

@@ -1,5 +1,11 @@
# check-html-links
## 0.1.2
### Patch Changes
- f343c50: When reading bigger files, especially bigger files with all content on one line it could mean a read chunk is in the middle of a character. This can lead to strange symbols in the resulting string. The `hightWaterMark` is now increased from the node default of 16KB to 256KB. Additionally, the `hightWaterMark` is now synced for reading and parsing.
## 0.1.1
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "check-html-links",
"version": "0.1.1",
"version": "0.1.2",
"publishConfig": {
"access": "public"
},

View File

@@ -15,10 +15,12 @@ import path from 'path';
const require = createRequire(import.meta.url);
const { SaxEventType, SAXParser } = saxWasm;
const streamOptions = { highWaterMark: 256 * 1024 };
const saxPath = require.resolve('sax-wasm/lib/sax-wasm.wasm');
const saxWasmBuffer = fs.readFileSync(saxPath);
const parserReferences = new SAXParser(SaxEventType.Attribute);
const parserIds = new SAXParser(SaxEventType.Attribute /*, { highWaterMark: 256 * 1024 } */);
const parserReferences = new SAXParser(SaxEventType.Attribute, streamOptions);
const parserIds = new SAXParser(SaxEventType.Attribute, streamOptions);
/** @type {Error[]} */
let checkLocalFiles = [];
@@ -76,7 +78,7 @@ function extractReferences(htmlFilePath) {
};
return new Promise(resolve => {
const readable = fs.createReadStream(htmlFilePath);
const readable = fs.createReadStream(htmlFilePath, streamOptions);
readable.on('data', chunk => {
// @ts-expect-error
parserReferences.write(chunk);
@@ -112,7 +114,7 @@ function idExists(filePath, id) {
};
return new Promise(resolve => {
const readable = fs.createReadStream(filePath);
const readable = fs.createReadStream(filePath, streamOptions);
readable.on('data', chunk => {
// @ts-expect-error
parserIds.write(chunk);