yourss v0.1.0
YouRSS
RSS Feed manipulation made easy. Merge, map, filter, sort, and cache RSS feeds in Node.
Note: This project is pre-version 1.0.0, so breaking changes may occur. Use at your own risk or lock down to a specific version using NPM.
Y88b / ,88~-_ 888 | 888~-_ ,d88~~\ ,d88~~\
Y88b / d888 \ 888 | 888 \ 8888 8888
Y88b/ 88888 | 888 | 888 | `Y88b `Y88b
Y8Y 88888 | 888 | 888 / `Y88b, `Y88b,
Y Y888 / Y88 | 888_-~ 8888 8888
/ `88_-~ "8__/ 888 ~-_ \__88P' \__88P'
Table of Contents
Usage
Node
The recommended way to use this package is as an npm package. To install and save it to your project's dependencies, run:
npm install yourss --saveAfter installing, call the Yourss factory with an RSS feed ULR and then chain any manipulators to the call. Resolve the feed and get results by calling get(). The response will be a promise of a Feed object.
const Yourss = require('yourss');
const url = 'http://www.rss-feed-url.com/feed.xml';
const result = Yourss(url)
// Optional: Add manipulators here (see below)
.get();
result.then(feed => {
// Do something with the feed
});Browser
Coming soon!
Manipulators
Cache
Caches the feed response with the results of any previously chained manipulators. Uses SQLite and Keyv by default, but you can set a backend with the Yourss.setBackend method.
Options
ttl- Time to live for the cache.
Example
// Caches a response
feed = Yourss(url).cache(ttl).get();
// Caches the response and any chained manipulators before it
feed = Yourss(url)
.map(mapFunction)
.filter(filterFunction)
.cache(ttl)
.get();Filter
Filters items in the feed based on a callback function.
Options
callback
Example
// Filter any items with a title
feed = Yourss(url)
.filter((item) => {
return item.title;
}).get();Map
Loop over and manipulate items in the feed.
Options
callback
Example
// Change the title of each item in a feed
feed = Yourss(url)
.map((item) => {
return item.title + ' Changed!';
}).get();Merge
Options
feed- The resolved feed to be merged with the current one.callback(optional) - For merging with a custom callback.
Example
// Merge feed2 into the feed
feed2 = Yourss(url2).get();
feed = Yourss(url)
.merge(feed2)
.get();Sort
Change the order of the items in a feed using a custom callback.
Options
callback
Example
// Sort by date ascending
feed = Yourss(url)
.sort((a, b) => {
return (new Date(a.pubdate) - new Date(b.pubdate));
}).get();Contributing
All patches, fixes, and ideas welcome! Please read contributing.md for furthers details.
License
7 years ago
