feedparser
Advanced tools
Comparing version 1.1.5 to 2.0.0
2.0.0 / 2016-12-26 | ||
================== | ||
* Make bin script useful as command line tool and rename to "feedparser" | ||
* Add lint script and run lint before tests | ||
* Update README to clarify the importance of the compressed example | ||
* Drop support for Node 0.10 and 0.12 | ||
* Fix xml declaration parsing to handle extra whitespace | ||
* Fix assignment by reference in options parsing | ||
* Remove unnecessary method | ||
* Replace bespoke helpers with lodash equivalents where possible | ||
* Move feedparser to lib | ||
* Move helpers lib | ||
* Remove weird comment | ||
* Update copyright | ||
* Update addressparser v1.0.1 | ||
* Update dependecy readable-stream v2.2.2 and update tests to conform to api change | ||
* Update dev-dependency (iconv v2.2.1) | ||
* Update dev-dependency (mocha v3.2.0) | ||
* Add eslint/editorconfig and linting | ||
1.1.5 / 2016-09-24 | ||
@@ -3,0 +24,0 @@ ================== |
@@ -5,3 +5,6 @@ { | ||
"description": "Robust RSS Atom and RDF feed parsing using sax js", | ||
"version": "1.1.5", | ||
"bin": { | ||
"feedparser": "./bin/feedparser.js" | ||
}, | ||
"version": "2.0.0", | ||
"keywords": [ | ||
@@ -26,20 +29,27 @@ "rss", | ||
}, | ||
"main": "main.js", | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
"node": ">= 4.2.0" | ||
}, | ||
"dependencies": { | ||
"sax": "~0.6.0", | ||
"addressparser": "~0.1.3", | ||
"addressparser": "^1.0.1", | ||
"array-indexofobject": "~0.0.1", | ||
"readable-stream": "~1.0.17" | ||
"lodash.assign": "^4.2.0", | ||
"lodash.get": "^4.4.2", | ||
"lodash.has": "^4.5.2", | ||
"lodash.uniq": "^4.5.0", | ||
"readable-stream": "^2.2.2", | ||
"sax": "^1.2.1" | ||
}, | ||
"devDependencies": { | ||
"iconv": "2.1.x", | ||
"mocha": "~2.1.0", | ||
"request": "2.27.x" | ||
"eslint": "^2.11.1", | ||
"iconv": "2.2.1", | ||
"mocha": "^3.2.0", | ||
"request": "~2.79.0" | ||
}, | ||
"scripts": { | ||
"lint": "eslint .", | ||
"pretest": "npm run lint", | ||
"test": "mocha" | ||
} | ||
} |
@@ -7,10 +7,10 @@ # Feedparser - Robust RSS, Atom, and RDF feed parsing in Node.js | ||
[![NPM](https://nodei.co/npm/feedparser.png?downloads=true&stars=true)](https://nodei.co/npm/feedparser/) | ||
[![NPM](https://nodei.co/npm/feedparser.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/feedparser/) | ||
Feedparser is for parsing RSS, Atom, and RDF feeds in node.js. | ||
It has a couple features you don't usually see: | ||
It has a couple features you don't usually see in other feed parsers: | ||
1. It resolves relative URLs (such as those seen in Tim Bray's "ongoing" [feed](http://www.tbray.org/ongoing/ongoing.atom)). | ||
2. It properly handles XML namespaces (including those in sadistic feeds | ||
2. It properly handles XML namespaces (including those in unusual feeds | ||
that define a non-default namespace for the main feed elements). | ||
@@ -26,12 +26,14 @@ | ||
The easiest way to use feedparser is to just give it a [readable stream](http://nodejs.org/api/stream.html#stream_readable_stream). | ||
It will then return a readable object stream. | ||
This example is just to briefly demonstrate basic concepts. | ||
**Please** also review the [compressed example](examples/compressed.js) for a | ||
thorough working example that is a suitable starting point for your app. | ||
```js | ||
var FeedParser = require('feedparser') | ||
, request = require('request'); | ||
var FeedParser = require('feedparser'); | ||
var request = require('request'); // for fetching the feed | ||
var req = request('http://somefeedurl.xml') | ||
, feedparser = new FeedParser([options]); | ||
var feedparser = new FeedParser([options]); | ||
@@ -41,19 +43,23 @@ req.on('error', function (error) { | ||
}); | ||
req.on('response', function (res) { | ||
var stream = this; | ||
var stream = this; // `this` is `req`, which is a stream | ||
if (res.statusCode != 200) return this.emit('error', new Error('Bad status code')); | ||
stream.pipe(feedparser); | ||
if (res.statusCode !== 200) { | ||
this.emit('error', new Error('Bad status code')); | ||
} | ||
else { | ||
stream.pipe(feedparser); | ||
} | ||
}); | ||
feedparser.on('error', function(error) { | ||
feedparser.on('error', function (error) { | ||
// always handle errors | ||
}); | ||
feedparser.on('readable', function() { | ||
feedparser.on('readable', function () { | ||
// This is where the action is! | ||
var stream = this | ||
, meta = this.meta // **NOTE** the "meta" is always available in the context of the feedparser instance | ||
, item; | ||
var stream = this; // `this` is `feedparser`, which is a stream | ||
var meta = this.meta; // **NOTE** the "meta" is always available in the context of the feedparser instance | ||
var item; | ||
@@ -67,5 +73,2 @@ while (item = stream.read()) { | ||
I *strongly* encourage you to take a look at the [iconv example](examples/iconv.js) | ||
for a very thorough working example. | ||
### options | ||
@@ -72,0 +75,0 @@ |
@@ -9,14 +9,15 @@ describe('bad feeds', function(){ | ||
var error; | ||
fs.createReadStream(feed).pipe(new FeedParser()) | ||
.once('readable', function () { | ||
done(new Error('Shouldn\'t happen')); | ||
}) | ||
.on('error', function (err) { | ||
error = err; | ||
}) | ||
.on('end', function () { | ||
assert.ok(error instanceof Error); | ||
assert.equal(error.message, 'Not a feed'); | ||
done(); | ||
}); | ||
var feedparser = new FeedParser(); | ||
fs.createReadStream(feed).pipe(feedparser); | ||
feedparser.once('readable', function () { | ||
assert.strictEqual(this.read(), null); | ||
}) | ||
.on('error', function (err) { | ||
error = err; | ||
}) | ||
.on('end', function () { | ||
assert.ok(error instanceof Error); | ||
assert.equal(error.message, 'Not a feed'); | ||
done(); | ||
}); | ||
}); | ||
@@ -31,14 +32,15 @@ | ||
it('should just use the first', function (done) { | ||
fs.createReadStream(feed).pipe(new FeedParser()) | ||
.once('readable', function () { | ||
var stream = this; | ||
var item = stream.read(); | ||
assert.equal(item.guid, 'http://www.braingle.com/50366.html'); | ||
assert.equal(item.permalink, 'http://www.braingle.com/50366.html'); | ||
done(); | ||
}) | ||
.on('error', function (err) { | ||
assert.ifError(err); | ||
done(err); | ||
}); | ||
var feedparser = new FeedParser(); | ||
fs.createReadStream(feed).pipe(feedparser); | ||
feedparser.once('readable', function () { | ||
var stream = this; | ||
var item = stream.read(); | ||
assert.equal(item.guid, 'http://www.braingle.com/50366.html'); | ||
assert.equal(item.permalink, 'http://www.braingle.com/50366.html'); | ||
done(); | ||
}) | ||
.on('error', function (err) { | ||
assert.ifError(err); | ||
done(err); | ||
}); | ||
}); | ||
@@ -54,14 +56,15 @@ | ||
var error; | ||
fs.createReadStream(feed).pipe(new FeedParser()) | ||
.once('readable', function () { | ||
done(new Error('Shouldn\'t happen')); | ||
}) | ||
.on('error', function (err) { | ||
error = err; | ||
}) | ||
.on('end', function () { | ||
assert.ok(error instanceof Error); | ||
assert.ok(error.message.match(/^Invalid code point/)); | ||
done(); | ||
}); | ||
var feedparser = new FeedParser(); | ||
fs.createReadStream(feed).pipe(feedparser); | ||
feedparser.once('readable', function () { | ||
assert.strictEqual(this.read(), null); | ||
}) | ||
.on('error', function (err) { | ||
error = err; | ||
}) | ||
.on('end', function () { | ||
assert.ok(error instanceof Error); | ||
assert.ok(error.message.match(/^Invalid code point/)); | ||
done(); | ||
}); | ||
}); | ||
@@ -68,0 +71,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
440713
43
1745
219
8
4
5
+ Addedlodash.assign@^4.2.0
+ Addedlodash.get@^4.4.2
+ Addedlodash.has@^4.5.2
+ Addedlodash.uniq@^4.5.0
+ Addedaddressparser@1.0.1(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedlodash.assign@4.2.0(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addedlodash.has@4.5.2(transitive)
+ Addedlodash.uniq@4.5.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedaddressparser@0.1.3(transitive)
- Removedisarray@0.0.1(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedsax@0.6.1(transitive)
- Removedstring_decoder@0.10.31(transitive)
Updatedaddressparser@^1.0.1
Updatedreadable-stream@^2.2.2
Updatedsax@^1.2.1