From f809f17c861666236d55d3637f52fe150b5bb7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Didrik=20Nordstr=C3=B6m?= Date: Sat, 10 Mar 2012 13:22:30 +0100 Subject: [PATCH] Create a new parser for each file/URL that is parsed --- node-rss.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/node-rss.js b/node-rss.js index 9c1cb05..2de14b5 100644 --- a/node-rss.js +++ b/node-rss.js @@ -23,7 +23,8 @@ var callback = function() {}; // The main "meat" of this module - parses an rss feed and triggers // the callback when done. // using node-xml: http://github.com/robrighter/node-xml -var parser = new xml.SaxParser(function(cb) { +var parser = function() { + return new xml.SaxParser(function(cb) { var articles = Array(); var current_element = false; var article_count = 0; @@ -93,6 +94,7 @@ var parser = new xml.SaxParser(function(cb) { sys.puts(''+JSON.stringify(msg)+""); }); }); +}; /** @@ -103,7 +105,7 @@ var parser = new xml.SaxParser(function(cb) { */ exports.parseFile = function(file, cb) { callback = cb; - parser.parseFile(file); + parser().parseFile(file); } /** * parseURL() @@ -142,7 +144,7 @@ exports.parseURL = function(url, cb) { body += chunk; }); response.addListener('end', function() { - parser.parseString(body); + parser().parseString(body); }); break; // redirect status returned