Comparing version 0.0.10 to 0.0.11
64
index.js
@@ -9,2 +9,60 @@ var native = require('./build/Release/parser'); | ||
// Finds "best" link for an Atom feed article. | ||
function atomLink(article) { | ||
var link; | ||
var links = article.links; | ||
var best = false; | ||
if (links.length > 0) { | ||
link = links[0]; | ||
} | ||
for (var i = 0; i < links.length; i++) { | ||
var l = links[i]; | ||
if (l.rel === 'alternate') { | ||
if (l.type === 'text/html') { | ||
link = l; | ||
best = true; | ||
} else if (!best) { | ||
link = l; | ||
} | ||
} | ||
} | ||
article.link = link ? link.href : undefined; | ||
} | ||
// Postprocess a single Atom feed article. | ||
function postProcAtomArticle(article) { | ||
parseDate(article); | ||
atomLink(article); | ||
} | ||
// Postprocess a single RSS 2 feed article. | ||
function postProcRss2Article(article) { | ||
parseDate(article); | ||
} | ||
// Postprocess the whole Atom feed. | ||
function postProcAtom(feed) { | ||
feed.items.forEach(postProcAtomArticle); | ||
} | ||
// Postprocess the whole RSS 2 feed. | ||
function postProcRss2(feed) { | ||
feed.items.forEach(postProcRss2Article); | ||
} | ||
function parseAndPostProc(xml, options) { | ||
var result = native.parse(xml, options.content); | ||
if (result.type === 'atom') { | ||
postProcAtom(result); | ||
} else { | ||
postProcRss2(result); | ||
} | ||
return result; | ||
} | ||
// parse(xml, [options], [cb]). | ||
@@ -30,4 +88,3 @@ | ||
try { | ||
result = native.parse(xml, options.content); | ||
result.items.forEach(parseDate); | ||
result = parseAndPostProc(xml, options); | ||
cb(null, result); | ||
@@ -38,6 +95,5 @@ } catch (err) { | ||
} else { | ||
result = native.parse(xml, options.content); | ||
result.items.forEach(parseDate); | ||
result = parseAndPostProc(xml, options); | ||
return result; | ||
} | ||
}; |
{ | ||
"name": "fast-feed", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "rss", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144225
14
194