Skip to content

Commit 912589d

Browse files
committed
syntax
1 parent e356e75 commit 912589d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,16 @@ var parseRSS2 = function(xmlObj, options, callback) {
132132
}
133133

134134
var parseRSS = function(channel, items, options, callback) {
135+
items = items || [];
136+
options.customFields = options.customFields || {};
135137
var itemFields = ITEM_FIELDS.concat(options.customFields.item || []);
136138
var feedFields = FEED_FIELDS.concat(options.customFields.feed || []);
137139

138140
var json = {feed: {entries: []}};
139141

140142
if (channel['atom:link']) json.feed.feedUrl = channel['atom:link'][0].$.href;
141143
copyFromXML(channel, json.feed, feedFields);
142-
(items || []).forEach(function(item) {
144+
items.forEach(function(item) {
143145
var entry = {};
144146
copyFromXML(item, entry, itemFields);
145147
if (item.enclosure) {
@@ -211,7 +213,7 @@ var decorateItunes = function decorateItunes(json, channel) {
211213
}
212214

213215
copyFromXML(channel, json.feed.itunes, PODCAST_FEED_FIELDS);
214-
(items).forEach(function(item, index) {
216+
items.forEach(function(item, index) {
215217
var entry = json.feed.entries[index];
216218
entry.itunes = {};
217219
copyFromXML(item, entry.itunes, PODCAST_ITEM_FIELDS);
@@ -227,10 +229,6 @@ Parser.parseString = function(xml, options, callback) {
227229
callback = options;
228230
options = {};
229231
}
230-
options.customFields = options.customFields || {};
231-
var itemFields = ITEM_FIELDS.concat(options.customFields.item || []);
232-
var feedFields = FEED_FIELDS.concat(options.customFields.feed || []);
233-
234232
XML2JS.parseString(xml, function(err, result) {
235233
if (err) return callback(err);
236234
if (result.feed) {
@@ -278,7 +276,7 @@ Parser.parseURL = function(feedUrl, options, callback) {
278276
req.on('error', callback);
279277
}
280278

281-
Parser.parseFile = function(file,options,callback) {
279+
Parser.parseFile = function(file, options, callback) {
282280
FS.readFile(file, 'utf8', function(err, contents) {
283281
return Parser.parseString(contents, options, callback);
284282
})

0 commit comments

Comments
 (0)