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

@rowanmanning/feed-parser

v1.1.0

Published

A well-tested and resilient parser for RSS and Atom feeds

Downloads

2,409

Readme

@rowanmanning/feed-parser

A well-tested and resilient Node.js parser for RSS and Atom feeds.

Table of Contents

Introduction

This is a Node.js-based feed parser for RSS and Atom feeds. The project has the following aims:

  • Run automated tests against real-world feeds. It's currently tested against ~40 feeds via Sample Feeds. This ensures that we support real feeds rather than just the specifications.

  • Related to the point above, be as lenient as possible with feed parsing.

  • Keep up to date with the latest Node.js versions, including dropping support for end-of-life versions.

  • Maintain compatibility with the great parts of node-feedparser, e.g. resolving relative URLs.

Requirements

This library requires the following to run:

Usage

Install with npm:

npm install @rowanmanning/feed-parser

Load the library into your code:

const { parseFeed } = require('@rowanmanning/feed-parser');

// or

import { parseFeed } from '@rowanmanning/feed-parser';

You can use the parseFeed function to parse an RSS or Atom feed as a string. The return value is an object representation of the feed:

const feed = parseFeed('<channel> etc. </channel>');
console.log(feed.title);

This will try to parse even invalid feeds, but if no data can be pulled out an error will be thrown with a code property set to INVALID_FEED.

This library does not parse feeds via a URL, you can do so relatively easily with fetch:

const response = await fetch('https://github.com/rowanmanning/feed-parser/releases.atom');
const feed = parseFeed(await response.text());

Parsed feed

The feed object returned by parseFeed has the following properties.

Feed

Represents an RSS or Atom feed.

FeedAuthor

Represents the author of a Feed or FeedItem.

FeedCategory

Represents the content category of a Feed or FeedItem.

FeedGenerator

Represents software that generated a Feed.

FeedImage

Represents an image for a Feed.

FeedItem

Represents an RSS item or Atom entry in a Feed.

FeedItemMedia

Represents a piece of media attached to a FeedItem.

FeedMeta

Represents meta information about a Feed.

Supported feed formats

Standards

Feeds that adhere to the following standards are supported and most properties will be parsed:

The following XML namespaces are also parsed, and more data will be parsed out for RSS feeds that implement these:

Leniency

Feeds in the real world rarely comply strictly with the standards and can sometimes be invalid XML. We try to be as lenient as possible, only throwing errors if no data can be pulled out of the feed. We test against a suite of real-world feeds.

Contributing

The contributing guide is available here. All contributors must follow this library's code of conduct.

License

Licensed under the MIT license. Copyright © 2022, Rowan Manning

Credit

This library takes inspiration from the following: