npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

easysax

v0.6.1

Published

pure javascript xml parser

Readme

EASYSAX - pure javascript sax-style parser for xml

Simple and fast SAX XML parser.

  • Incremental processing: EasySAX supports incremental data processing. This allows parsing files several gigabytes in size with minimal RAM consumption, passing data to the parser as it is read.
  • Namespaces: Supports namespace normalization.
  • Fast: High-performance streaming engine.

The parser was written for the RSS reader http://zzreader.com (not working) Remains the fastest SAX XML parser for JS by 2026

Install

$ npm install easysax

Benchmark

sh: bun benchmark/stream.js

file: mock                                                              elems    text
------------------------------------------------------------------------------------------
only load                      - total: 169.28   time: 2.51     500 MB

easysax ns=on  uq=on  attr=on  - total: 3109.29  time: 2670.36  500 MB 7505704  5003804
easysax ns=off uq=on  attr=on  - total: 2482.34  time: 2100.68  500 MB 7505704  5003804
easysax ns=off uq=off attr=on  - total: 1369.77  time: 1066.33  500 MB 7505704  5003804
easysax ns=off uq=off attr=off - total: 1237.50  time: 887.20   500 MB 7505704  5003804

eksml          uq=off attr=on  - total: 1557.89  time: 1259.11  500 MB 7505704  2501901
saxes          uq=on  attr=on  - total: 7909.32  time: 7439.90  500 MB 7505704  5003804
ltx            uq=on  attr=on  - total: 14608.25 time: 14167.45 500 MB 7505704  5003803
------------------------------------------------------------------------------------------

sh: bun benchmark/stream.js -file AS_HOUSES_PARAMS.XML

file: ./AS_HOUSES_PARAMS.XML
------------------------------------------------------------------------------------------
only load                      - total: 29979.80 time: 29.69    4.74 GB

easysax ns=on  uq=on  attr=on  - total: 53994.98 time: 21257.70 4.74 GB 27997407 1
easysax ns=off uq=on  attr=on  - total: 50518.53 time: 17841.35 4.74 GB 27997407 1
easysax ns=off uq=off attr=on  - total: 47360.99 time: 14886.36 4.74 GB 27997407 1
easysax ns=off uq=off attr=off - total: 42390.00 time: 10174.52 4.74 GB 27997407 1

eksml          uq=off attr=on  - total: 58463.19 time: 25675.42 4.74 GB 27997407 1
ltx            uq=on  attr=on  - total: 89953.37 time: 56807.52 4.74 GB 27997407 1
saxes          uq=on  attr=on  - total: 123178.7 time: 89020.67 4.74 GB 27997407 0
------------------------------------------------------------------------------------------

sh: node benchmark/bench-01.js

count - 100000
size - 34
----------------------------------------------
easysax    ns=on  uq=on  attr=on  : 124.97  ms
easysax    ns=off uq=on  attr=on  : 71.09   ms
easysax    ns=off uq=off attr=on  : 67.30   ms
easysax    ns=off uq=off attr=off : 52.92   ms

eksml             uq=off attr=on  : 111.99  ms
saxen      ns=off uq=on  attr=on  : 94.97   ms
saxophone         uq=off attr=on  : 69.96   ms
ltx               uq=on  attr=on  : 88.91   ms
saxes             uq=on  attr=on  : 174.89  ms
saxjs             uq=on  attr=on  : 245.46  ms
libxml                            : 1184.2  ms
expat                             : 1102.1  ms
saxwasm~481                       : 513.93  ms
tuananh           uq=off attr=on  : 2778.8  ms
----------------------------------------------

sh: node bench-02.js

count - 1000
size - 22736
----------------------------------------------
easysax    ns=on  uq=on  attr=on  : 104.48  ms
easysax    ns=off uq=on  attr=on  : 75.82   ms
easysax    ns=off uq=off attr=on  : 54.09   ms
easysax    ns=off uq=off attr=off : 45.54   ms

eksml             uq=off attr=on  : 68.54   ms
saxen      ns=off uq=on  attr=on  : 67.67   ms
saxophone         uq=off attr=on  : 83.87   ms
ltx               uq=on  attr=on  : 130.20  ms
saxes             uq=on  attr=on  : 157.29  ms
saxjs             uq=on  attr=on  : 576.21  ms
libxml                            : 1362.6  ms
expat                             : 1174.6  ms
saxwasm~481                       : 436.54  ms
tuananh           uq=off attr=on  : 451.34  ms
----------------------------------------------

sh: node bench-03.js

count - 1000
size - 121786
----------------------------------------------
easysax    ns=on  uq=on  attr=on  : 691.52  ms
easysax    ns=off uq=on  attr=on  : 489.07  ms
easysax    ns=off uq=off attr=on  : 389.16  ms
easysax    ns=off uq=off attr=off : 319.11  ms

eksml             uq=off attr=on  : 420.79  ms
saxen      ns=off uq=on  attr=on  : 837.77  ms
saxophone         uq=off attr=on  : 681.66  ms
ltx               uq=on  attr=on  : 920.86  ms
saxes             uq=on  attr=on  : 1155.2  ms
saxjs             uq=on  attr=on  : 4305.0  ms
libxml                            : 7069.5  ms
expat                             : 7421.8  ms
saxwasm~481                       : 3548.3  ms
tuananh           uq=off attr=on  : 1993.5  ms
----------------------------------------------

Example of use

var parser = new EasySax();

// if namespace is required
parser.ns('rss', {
	'http://www.w3.org/2005/Atom': 'atom',
	'http://www.w3.org/1999/xhtml': 'xhtml',
	'http://search.yahoo.com/mrss/': 'media',
	'http://purl.org/rss/1.0/': 'rss',
	'http://purl.org/dc/elements/1.1/': 'dc',
	'http://www.w3.org/1999/02/22-rdf-syntax-ns#' : 'rdf',
	'http://purl.org/rss/1.0/modules/content/': 'content',
	'http://www.yandex.ru': 'yandex',
	'http://news.yandex.ru': 'yandex',
	'http://backend.userland.com/rss2': 'rss'
});

parser.on('error', function(msg) {
	// console.log('error - ' + msg);
});

parser.on('opentag', function(elementName, attrs, isTagEnd) {
	// elementName -- (string) element name. If namespaces are enabled, it automatically sets the prefix
	// attrs -- (object) object with attributes
	// isTagEnd -- (boolean) flag that the element is empty "<elem/>"
});

parser.on('closetag', function(elementName, isTagStart) {
	// isTagStart -- (boolean) flag that the element is empty "<elem/>"
});

parser.on('text', function(text) {
	// text -- (String) line of text
});

parser.on('cdata', function(text) {
    // text -- (String) CDATA element text string
});

parser.on('comment', function(text) {
	// text - (String) comment text
});

//parser.on('question', function() {}); // <? ... ?>
//parser.on('attention', function() {}); // <!XXXXX zzzz="eeee">


parser.write(stringChunk);
parser.write(stringChunk);
...
parser.end(stringChunk);

API Reference

Constructor Options

You can pass a configuration object when creating a new instance: new EasySax(config)

| Parameter | Description | Default | | :--- | :--- | :--- | | autoEntity (boolean) | Automatically decode HTML entities (&amp;, &lt;, &quot;, etc.) in text nodes. | true | | lazy (boolean) | If true, passes a getAttr() function to opentag for lazy attribute evaluation (saves memory/CPU). If false, attributes are evaluated immediately as an object. | false | | strict (boolean) | Enables strict parsing mode with rigorous XML syntax validation. Recommended if you are unsure about the quality of the input XML | false | | defaultNS (string) | Root element name for namespace rules. If empty, namespace processing is disabled. | '' | | ns (object) | Namespace mapping object { 'http://uri': 'prefix' }. Works only if defaultNS is set. | null | | on (object) | Object for bulk event subscription on initialization. Format: { opentag: fn, text: fn, ... }. | undefined | | intern (boolean) | Enables string interning. Repeated strings (tag names, attributes) are deduplicated via Map, saving memory on large files. | true | | map (Map) | Custom Map object for storing interned strings. Allows sharing a single string pool across multiple parser instances. | new Map() | | salt (number) | Salt for the string hashing algorithm. Useful for isolating pools of different parsers when sharing a map. | null | | entityDecode (function) | Custom function for entity decoding. Overrides the built-in decoder. | Built-in function |

Methods

| Method | Description | | :--- | :--- | | setup(config) | Applies or updates parser settings after creation. Accepts the same config object as the constructor. | | on(event, cb) | Subscribes a callback to a parsing event. Events: opentag, closetag, text, cdata, comment, error, question, attention, unknownNS. Passing null unsubscribes. | | ns(root, nsMap) | Sets namespace rules. root is the root element name, nsMap is { 'URI': 'prefix' }. Calling ns(null) disables NS. Returns the parser instance (chainable). | | write(chunk) | Feeds a chunk of XML data to the parser. Can be called multiple times for streaming. Ignored if parsing was stopped via stop(). | | end([chunk]) | Finalizes the parsing process. Optionally accepts a final data chunk. Resets internal state, freeing memory. | | parse(xml) | Convenience method to parse a small XML string entirely. Automatically calls write(xml) then end(). | | stop() | Forcefully stops parsing. Sets an internal flag, after which write() calls are ignored. Useful for early exit when target data is found. | | getNodeString() | Returns the raw XML string of the current node being parsed. |