npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

better-rss

v1.4.1

Published

Better RSS is specialized library for rss feeds

Downloads

9

Readme

better-rss

Better RSS is specialized library for rss feeds. It emits you updates on new items in a feed and fetches og images if no images are provided in feed.

Installation

Go to your node project and run npm install better-rss

Usage

Get updates about new items

const betterRSS = require('./main');
const rss = new betterRSS({ updateInterval: 120000 });

rss.feeds().add('https://some-url.to/my/rss/feed.xml');

rss.on('newItem', (item, feed) => {
    // do your stuff
});

Fetch a feed directly

const betterRSS = require('./main');
const rss = new betterRSS({ updateInterval: 120000 });

rss.getRSS('http://myrss.com/rss.xml')
    .then(data => console.log(data));

Documentation

Class new betterRSS(options)

  • options | object | An object that will be given in the constructor
    • feeds | array | An array with strings of your rss feeds
    • updateInterval | number | A number that specify the interval of update requests in milliseconds
    • autoUpdate | bool | This boolean defines whether automatic updates should be performed
    • extraImages | bool | This boolean defines if the library should use og images if no default thumbnail is provided
    • cacheImages | bool | This boolean defines if the library should cache the image urls for og images for already fetched items
    • itemLimit | number | A number that specify a limit how many items in a feed should be processed

Methods

getRSS(url)

  • url | string | The url you want to get the rss feed from
  • returns: Promise

feeds()

  • add(url) | Add a feed to the list
    • url | string | The url to the rss feed
    • returns: boolean
      • true | Successful added
      • false | Already in feeds
  • get(feed) | Get a feed from the list with data
    • feed | string/number | Define the feed that you want. (can be index in list or url itself)
    • returns: Array
  • getAll() | Get all feeds with data
    • returns: Object
  • list(parsed) | Get a list with all feed urls
    • parsed | bool | Define if you want to get an array with only strings or an array with parsed url objects
      • returns: Array
  • remove(feed) | Remove a feed from the list
    • feed | string | The url to the rss feed
      • returns: boolean
        • true | Successful removed
        • false | Not found
  • has(url) | Check if a feed is in the list
    • url | string | The url to the rss feed
      • returns: boolean
        • true | Found
        • false | Not found

updater()

  • start() | Start the auto updater
  • stop() | Stop the auto updater
    • returns:
      • true | Successful stopped
      • false | Cant stopped because auto updater not running
  • update() | Update all rss feeds now

on(event, callback)

  • event | string | The event that you want to listen on
  • callback([args]) | function | The callback function that will be triggered on an event

updateFeeds()

Updates all feeds. Please not use this. Use updater().update() instead.

filter(func)

  • func(item, feed) | function | A function / lambda expression that should return true or false. This is a filter function that will executed every time before a newItem event is emitting.

Events

  • updating | Will be triggered when the auto updater updates all rss feeds
    • No callback args
  • error | Triggered when an error occurs
    • err | object | Error object in callback arg
  • newItem | Executed if a new item in a feed is available
    • item | object | RSS item object
    • feed | object | RSS feed object

Default RSS Object

let rss = {
    feed: {
        title: null,
        link: null,
        url: null,
        author: null,
        description: null,
        image: null,
        _source: null
    },
    items: [
        {
            title: null,
            pubDate: null,
            link: null,
            guid: null,
            author: null,
            thumbnail: null,
            description: null,
            content: null,
            categories: []
        }
    ]
}