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 🙏

© 2025 – Pkg Stats / Ryan Hefner

easysax

v0.3.2

Published

pure javascript xml parser

Downloads

153

Readme

EASYSAX - pure javascript sax-style parser for xml

Простой и быстрый SAX парсер XML. Парсер не потоковый, и не расчитан на гиганские файлы. Весь XML должен быть в памяти. Встроен механизм работы с пространсвами имен.

Парсер был написан для RSS ридера http://zzreader.com На конец 2017 года остается самым быстрым SAX парсером XML под NODE.JS

Install

$ npm install easysax

Benchmark

https://github.com/vflash/sax-benchmark

sh: node bench-01.js

count - 100000
size - 25

saxjs : 346.182ms
libxml: 852.098ms
expat : 705.867ms
expat buffer: 712.212ms
ltx: 137.998ms
easysax ns=on uq=on attr=on   : 100.050ms
easysax ns=off uq=on attr=on  : 82.520ms
easysax ns=off uq=off attr=on : 69.133ms
easysax ns=off uq=off attr=off: 29.226ms

sh: node bench-02.js

count - 1000
size - 22750

saxjs : 1484.910ms
libxml: 1058.808ms
expat : 1028.151ms
expat buffer: 853.925ms
ltx: 359.173ms
easysax ns=on uq=on attr=on   : 151.511ms
easysax ns=off uq=on attr=on  : 114.646ms
easysax ns=off uq=off attr=on : 88.604ms
easysax ns=off uq=off attr=off: 80.773ms

sh: node bench-03.js

count - 1000
size - 121786

saxjs : 10765.309ms
libxml: 5387.832ms
expat : 6734.018ms
expat buffer: 5865.209ms
ltx: 2953.910ms
easysax ns=on uq=on attr=on   : 1769.676ms
easysax ns=off uq=on attr=on  : 1475.585ms
easysax ns=off uq=off attr=on : 1214.665ms
easysax ns=off uq=off attr=off: 405.799ms

Пример использования

var parser = new EasySax();

// если требуется пространство имен
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('startNode', function(elementName, getAttr, unEntities, isTagEnd, getStringNode) {
	// elementName -- (string) название элемента. при указании пространства имен, то автоматически подставляется префикс
	// getAttr() -- (function) парсит атрибуты и возврашает обьект. 
	// unEntities() -- (function) встроенный xml декодер.  пример: uq("<a>")
	// isTagEnd -- (boolean) флаг что элемент пустой "<elem/>"
	// getStringNode() -- (function) возвращает нераспарсенная строка элемента. Пример: <item title="text" id="x345">	
});

parser.on('endNode', function(elementName, unEntities, isTagStart, getStringNode) {
	// isTagStart -- (boolean) флаг что элемент пустой "<elem/>"
});

parser.on('textNode', function(text, uq) {
	// text -- (String) строковой элемент. пример: uq(text);
});

parser.on('cdata', function(text) {
	// text -- (String) строковой элемент CDATA
});


parser.on('comment', function(text) {
	// text - (String) текст комментария
});


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


parser.parse(xml); // xml -- (String) строка xml