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

0.1.3 • Public • Published

feed-watch

feed-watch is a highly configurable lightweight module for watching/emitting changes in rss feeds.

Installation

You can install feed-watch by using:

  npm install feed-watch

Usage

A basic feed-watch can be implemented as follows:

  import FeedWatch, { FeedConfig, FeedItem, FeedItemEvent } from 'feed-watch';
 
  const feedWatch = new FeedWatch();
 
  const myUidGenerator = (feedItem: FeedItem) => `${feedItem.guid}`;
 
  const feed: FeedConfig = {
    name: 'my-feed',
    url: '<my-feed-url>',
    refreshRateInSecs: 100,
    skipInitialList: false, // set this to true if you do not want events for the initial set of items.
    uidGenerator: null// takes in a fuction that returns a unique string for every feed item, used to de-dupe
                        // make sure that this can uniquely identify an item in the feed.
    parserOpts{}// config options for feed-parser
    requestOpts{ // config options for axios
      headers: {
        'user-agent': '<user-agent-string>'
      }
    };
  }
 
  feedWatch.on('error', (err) => {
    console.error(err);
  });
 
  feedWatch.on('item', ({ feed, item }: FeedItemEvent) => {
    console.log(feed, item);
  });
 
  feedWatch.add(feed);

Package Sidebar

Install

npm i feed-watch

Weekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

133 kB

Total Files

13

Last publish

Collaborators

  • agarwal-sumit