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

feed-mixer

v0.1.1

Published

Transform multiple rss/atom feeds into one rss/atom feed.

Downloads

14

Readme

feed-mixer

feed-mixer is a module which transforms multiple rss/atom feeds into a single rss/atom feed.

It can be a single method use module or it can poll data every so often.

Here is an example of it being used in the context of a server.

npm install feed-mixer

usage

var FeedMixer = require('feed-mixer');

var mixer = new FeedMixer({
    "title": "My aggregate feed",
    "description": "This feed is made up of many.",
    "link": "http://example.com",
    "output": "rss-2.0",
    "feeds": [
        "https://www.youtube.com/feeds/videos.xml?user=vsauce",
        "https://twitrss.me/twitter_user_to_rss/?user=tweetsauce"
    ]
});

// Pattern A

mixer.refresh().then(function (feed) {
    require('fs').writeFileSync("output.rss", feed);
});

// OR Pattern B

mixer.on('refreshComplete', function (feed) {
    require('fs').writeFileSync("output.rss", feed);
});

mixer.refresh();

API

FeedMixer(config)

Returns a FeedMixer object

var mixer = new FeedMixer({
    "title": "My aggregate feed",
    "description": "This feed is made up of many.",
    "link": "http://example.com",
    "output": "rss-2.0",
    "update": "00:30:00",
    "feeds": [
        "https://www.youtube.com/feeds/videos.xml?user=vsauce",
        "https://twitrss.me/twitter_user_to_rss/?user=tweetsauce"
    ]
})

FeedMixer(configSource)

Returns a FeedMixer object with a config specified to JSON source.

var mixer = new FeedMixer('./config.json')

FeedMixer.refresh()

Returns a promise of which the callback argument is a string of the aggregate feed.

This function works by requesting all the feeds specified in the url and then aggregating them into one feed.

mixer.refresh().then(function (feed) {
    require('fs').writeFileSync('aggregate.rss', feed);
});

FeedMixer.aggregate

Returns a traversable object of the aggregate feed in the format of the feed module.

mixer.aggregate.length

FeedMixer.getFeed(feedFormatType)

Returns a string version of the aggregate feed.

feedFormatType is either "rss-2.0" or "atom-1.0". Defaults to the config output type.

var feedString = mixer.getFeed('atom-1.0');

FeedMixer.end()

FeedMixer.finish()

Stop the automatic polling/refreshing of the aggregate feed.

mixer.end();

config options

Config is either supplied in the constructor argument or as a resource string to a JSON file.

{
    name:        Your aggregate feed name
    description: Your aggregate feed description
    link:        Your aggregate feed url
    output:      Your aggregate feed in "rss-2.0" or "atom-1.0" format
    update:      (Optional) How often to refresh (hh:mm:ss format)
}

Events

FeedMixer.events.on('refreshStart')

Event called when the refresh() method is called. Argument passed is the Date of refresh.

mixer.events.on('refreshStart', function (when) {
    console.log('Started fetching/aggregating at ', when);
});

FeedMixer.events.on('refreshCompleted')

Event called when aggregate feed is ready and FeedMixer.aggregate property is updated.

Argument passed is the string of the aggregate feed in either the rss or atom format.

var latestFeedVersion;

mixer.events.on('refreshComplete', function (feed) {
    latestFeedVersion = feed;
});