0.4.0 • Published 5 years ago

feedify v0.4.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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):

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

License

MIT © Ahmed T. Ali

0.4.0

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.0

5 years ago