sax-async

Wrapper around sax-js to allow for asynchronous event handlers, and using streams2 to properly exert backpressure on piped streams

Usage no npm install needed!

<script type="module">
  import saxAsync from 'https://cdn.skypack.dev/sax-async';
</script>

README

Version of sax-js which uses the new streams API for backpressure, and allows callbacks on the events using crisphooks.

var SaxAsync = require('sax-async');

var strict = false;
var options = {};

var parseStream = new SaxAsync(strict, options);

parseStream.hookAsync('closetag', function(next, tag) {
    console.log(tag);
    setTimeout(next, 100);
});

parseStream.hookSync('end', function() {
    console.log('Ended.');
});

require('fs').createReadStream('./test.xml').pipe(parseStream);