sax-wasm icon indicating copy to clipboard operation
sax-wasm copied to clipboard

How to pipe stream into the parser?

Open Wernfried opened this issue 1 year ago • 1 comments

I try to pipe a stream into the parser, but it fails:

const fs = require('fs');
const { SaxEventType, SAXParser } = require('sax-wasm');
const parser = new SAXParser(SaxEventType.Attribute | SaxEventType.OpenTag, {highWaterMark: 32 * 1024});

parser.eventHandler = (event, data) => {
  console.log(JSON.stringify(data))
};

fs.createReadStream(`sample.xml`).pipe(parser);

Uncaught TypeError TypeError: dest.on is not a function
    at Readable.pipe (node:internal/streams/readable:743:8)

I also tried with prepareWasm() but no success either. Is it supported somehow?

Wernfried avatar Mar 08 '24 09:03 Wernfried