Skip to content

Commit f0ca89b

Browse files
committed
Switch to arrow functions instead of passing thisArg
1 parent 66e9453 commit f0ca89b

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

lib/feedparser.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,21 +196,21 @@ FeedParser.prototype.handleOpenTag = function (node) {
196196
if (this.in_xhtml && this.xhtml['#name'] != n['#name']) { // We are in an xhtml node
197197
// This builds the opening tag, e.g., <div id='foo' class='bar'>
198198
this.xhtml['#'] += '<' + n['#name'];
199-
Object.keys(n['@']).forEach(function (name) {
199+
Object.keys(n['@']).forEach((name) => {
200200
this.xhtml['#'] += ' ' + name + '="' + n['@'][name] + '"';
201-
}, this);
201+
});
202202
this.xhtml['#'] += '>';
203203
} else if (this.stack.length === 0 &&
204204
(n['#name'] === 'rss' ||
205205
(n['#local'] === 'rdf' && _.nslookup([n['#uri']], 'rdf')) ||
206206
(n['#local'] === 'feed' && _.nslookup([n['#uri']], 'atom')))) {
207-
Object.keys(n['@']).forEach(function (name) {
207+
Object.keys(n['@']).forEach((name) => {
208208
var o = {};
209209
if (name != 'version') {
210210
o[name] = n['@'][name];
211211
this.meta['@'].push(o);
212212
}
213-
}, this);
213+
});
214214
switch (n['#local']) {
215215
case 'rss':
216216
this.meta['#type'] = 'rss';
@@ -433,7 +433,7 @@ FeedParser.prototype.handleAttributes = function handleAttributes (attrs, el) {
433433
basepath = this.xmlbase[0]['#'];
434434
}
435435

436-
Object.keys(attrs).forEach(/** @this {FeedParserInstance} */ function (key) {
436+
Object.keys(attrs).forEach(/** @type (key: string) => void */ (key) => {
437437
var attr = attrs[key]
438438
, ns = {}
439439
, prefix = ''
@@ -469,7 +469,7 @@ FeedParser.prototype.handleAttributes = function handleAttributes (attrs, el) {
469469
this.xhtml = { '#name': el, '#': '' };
470470
}
471471
simplifiedAttributes[prefix + attr.local] = attr.value ? attr.value.trim() : '';
472-
}, this);
472+
});
473473
return simplifiedAttributes;
474474
};
475475

@@ -496,7 +496,7 @@ FeedParser.prototype.handleMeta = function handleMeta (node, type, options) {
496496
meta.categories = [];
497497
}
498498

499-
Object.keys(node).forEach(function (name) {
499+
Object.keys(node).forEach((name) => {
500500
var el = node[name];
501501

502502
if (normalize) {
@@ -525,7 +525,7 @@ FeedParser.prototype.handleMeta = function handleMeta (node, type, options) {
525525
case ('atom:link'):
526526
case ('atom10:link'):
527527
if (Array.isArray(el)) {
528-
el.forEach(function (link) {
528+
el.forEach((link) => {
529529
if (link['@']['href']) { // Atom
530530
if (_.get(link['@'], 'rel')) {
531531
if (link['@']['rel'] == 'alternate') {
@@ -558,7 +558,7 @@ FeedParser.prototype.handleMeta = function handleMeta (node, type, options) {
558558
else if (this.xmlbase && this.xmlbase.length > 0) {
559559
meta.link = _.resolve(_.get(this.xmlbase[0], '#'), meta.link);
560560
}
561-
}, this);
561+
});
562562
} else {
563563
if (el['@']['href']) { // Atom
564564
if (_.get(el['@'], 'rel')) {
@@ -762,7 +762,7 @@ FeedParser.prototype.handleMeta = function handleMeta (node, type, options) {
762762
if (~name.indexOf(':')) meta[name] = el;
763763
else meta[type + ':' + name] = el;
764764
}
765-
}, this); // forEach end
765+
}); // forEach end
766766

767767
if (normalize) {
768768
if (!meta.description) {
@@ -851,7 +851,7 @@ FeedParser.prototype.handleItem = function handleItem (node, type, options) {
851851
item.enclosures = [];
852852
}
853853

854-
Object.keys(node).forEach(function (name) {
854+
Object.keys(node).forEach((name) => {
855855
var el = node[name]
856856
, attrs = _.get(el, '@')
857857
, enclosure;
@@ -1135,7 +1135,7 @@ FeedParser.prototype.handleItem = function handleItem (node, type, options) {
11351135
if (~name.indexOf(':')) item[name] = el;
11361136
else item[type + ':' + name] = el;
11371137
}
1138-
}, this); // forEach end
1138+
}); // forEach end
11391139

11401140
if (normalize) {
11411141
if (!item.description) {

0 commit comments

Comments
 (0)