feedify

A package for parsing RSS and Atom feeds

Use npm.im/unread instead
Last updated a year ago by z0al .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install feedify 
SYNC missed versions from official npm registry.

Feedify

All Contributors Build Bundlephobia

NPM

A package for parsing RSS 2.0, Atom 1.0.

Installation

npm add feedify

Usage

Simple

import { parse } from 'feedify';

fetch('https://overreacted.io/rss.xml')
	.then(resp => {
		return resp.text();
	})
	.then(text => {
		return parse(text);
	})
	.then(data => {
		console.log('Feed: ', data.feed);
		console.log('Items: ', data.items);
	});

Stream-like

If you want more control you can use parsers directly. E.g.:

import { RSSParser } from 'feedify';

const parser = new RSSParser();

parser.write('<rss> ....');
parser.write('... </rss>');
// ...

// You MUST close the stream or an infinite loop might happen
parser.close();

for (let item of parser.items()) {
	console.log(item);
}

console.log(parser.feed());

Error handling

import { parse } from 'feedify';

const text = 'borken feed';

// using .catch
parse(text)
	.then(output => console.log(output))
	.catch(err => {
		console.log('Oops, ', err);
	});

// OR, using try catch

try {
	const output = await parse(text);
	console.log(output);
} catch (err) {
	console.log('Oops, ', err);
}

Contributors

Thanks goes to these wonderful people (emoji key):

Ahmed T. Ali
Ahmed T. Ali

???? ???? ???? ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT © Ahmed T. Ali

Current Tags

  • 0.4.0                                ...           latest (a year ago)

10 Versions

  • 0.4.0 [deprecated]           ...           a year ago
  • 0.3.4 [deprecated]           ...           a year ago
  • 0.3.3 [deprecated]           ...           a year ago
  • 0.3.2 [deprecated]           ...           a year ago
  • 0.3.1 [deprecated]           ...           a year ago
  • 0.3.0 [deprecated]           ...           a year ago
  • 0.2.0 [deprecated]           ...           a year ago
  • 0.1.1 [deprecated]           ...           a year ago
  • 0.1.0 [deprecated]           ...           a year ago
  • 0.0.0 [deprecated]           ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |