This package has been deprecated

Author message:

Use npm.im/unread instead

feedify
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

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

Package Sidebar

Install

npm i feedify

Weekly Downloads

0

Version

0.4.0

License

MIT

Unpacked Size

60.3 kB

Total Files

6

Last publish

Collaborators

  • z0al