• Stars
    star
    196
  • Rank 198,553 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Subscribes to RSS/Atom/JSON feeds and notifies on new items.

FeedSub

FeedSub subscribes to a remote RSS/Atom/JSON feed and notifies you of any new items it reads.

It works by checking the feed every once in a while, comparing the date of the document via a conditional GET if supported. Otherwise it looks for a date tag in the feed. If it's the same as the last date, it stops downloading it and parsing the xml/json. If it's an updated document, then it looks through it top to bottom taking note of all the new items. Once it finds something it has already read, it stops downloading and parsing the document.

Depfu codecov

Usage

const FeedSub = require('feedsub');

let reader = new FeedSub('http://rss.cnn.com/rss/cnn_latest.rss', {
  interval: 10 // Check feed every 10 minutes.
});

reader.on('item', (item) => {
  console.log('Got item!');
  console.dir(item);
});

reader.start();

API

new FeedSub(feed, [options])

Creates a new instance of FeedSub. options defaults to.

{
  // Number of minutes to wait between checking the feed for new items.
  interval: 10,

  // Some feeds contain a `ttl` tag that specify the
  // number of minutes to cache the feed.
  // Setting this to true will ignore that.
  forceInterval: false,

  // If true, calls `reader.start()` when initialized.
  autoStart: false, 

  // Emits items on the very first request.
  // After which, it should consider those items read.
  emitOnStart: false,

  // Keeps track of last date of the feed.
  lastDate: null,

  // Maximum size of `history` array.
  maxHistory: 10,

  // Some feeds have a `skipHours` tag with a list of
  // hours in which the feed should not be read.
  // if this is set to true and the feed has that tag, it obeys that rule
  skipHours: false,

  // If you'd like to specify exactly what hours to skip.
  hoursToSkip: [],

  // Same as `skipHours`, but with days.
  skipDays: false,

  // Specify exactly what days to skip, ex: ['Saturday', 'Sunday'].
  daysToSkip: [],

  // Options object passed to [miniget](https://github.com/fent/node-miniget).
  requestOpts: {}
}

FeedSub#read([callback(err, items)])

Reads the feed. Calls callback with possible error or new items discovered if provided. Causes reader to emit new item events.

FeedSub#start(readOnStart)

Starts checking the feed for any new items every options.interval minutes. If readOnStart is true, it checks right away.

FeedSub#options

Options that were passed to the constructor along with any defaults are kept here.

FeedSub#stop()

Stops the reader from automatically reading the feed.

Event: item

  • Object - Item.

Emitted whenever there is a new item.

Event: items

  • Array.<Object> - List of items.

Emits all new items from one request in one array.

Event: error

  • Error

Emitted when there is an error downloading or parsing the feed. Not emitted if callback is given for read or readInterval.

Install

npm install feedsub

Tests

Tests are written with mocha

npm test

More Repositories

1

node-ytdl-core

YouTube video downloader in javascript.
JavaScript
4,507
star
2

randexp.js

Create random strings that match a given regular expression.
JavaScript
1,779
star
3

node-ytdl

Command line youtube video downloader.
JavaScript
1,188
star
4

node-m3u8stream

Concatenates segments from a m3u8/dash-mpd playlist into a consumable stream.
TypeScript
213
star
5

timequeue.js

A queue with custom concurrency and time limit.
TypeScript
191
star
6

node-torrent

Torrent reader, writer, and hash checker for node.
JavaScript
190
star
7

feedme.js

RSS/Atom/JSON feed parser
TypeScript
155
star
8

clusterhub

Sync data in your cluster applications.
JavaScript
131
star
9

ret.js

Tokenizes a string that represents a regular expression.
JavaScript
90
star
10

socket.io-clusterhub

socket.io storage powered by clusterhub for multi process applications.
JavaScript
70
star
11

chrome-options

Options page for Chrome extensions
JavaScript
64
star
12

node-muk

Mock object methods and dependencies.
JavaScript
57
star
13

node-miniget

A small http(s) GET library.
TypeScript
52
star
14

node-streamify

Streamify helps you easily provide a streaming interface for your code.
JavaScript
51
star
15

pauseable.js

Create event emitters, intervals, and timeouts that can be paused and resumed.
JavaScript
47
star
16

node-streamspeed

A simple way to keep track of the speed of your node streams.
TypeScript
38
star
17

irc-colors.js

Color and formatting for irc bots made easy. Inspired by colors.js and cli-color.
JavaScript
35
star
18

node-kat

File and stream concatenation the right way.
JavaScript
25
star
19

node-stream-equal

Test that two readable streams are equal to each other.
TypeScript
24
star
20

node-streamin

Provide a better streaming api in your app.
JavaScript
20
star
21

npm-updates

Emits update events from the npm repository.
JavaScript
16
star
22

node-jstream

Continuously reads in JSON and outputs Javascript objects.
JavaScript
16
star
23

muk-prop.js

Mock object methods and properties
JavaScript
12
star
24

hook.io-feedsub

hook.io bindings for RSS/Atom/JSON feeds
JavaScript
11
star
25

node-eventyoshi

Allows several event emitters to be listened and emitted through a single one.
JavaScript
11
star
26

node-torrent-cli

CLI for reading, writing, and hash checking torrents
JavaScript
10
star
27

chrome-veefeed

Follow YouTube and Twitch channels, get notifications, categorize videos
JavaScript
9
star
28

pokecry

guess pokemon through their cries
JavaScript
8
star
29

node-newsemitter

An event emitter that emits only new events.
TypeScript
7
star
30

clusterchat

A simple multi process chat demo using socket.io-clusterhub
JavaScript
7
star
31

ordered-queue.js

Queue with concurrency that starts tasks in order and runs them in parallel.
JavaScript
7
star
32

node-module-boilerplate

My personal boilerplate that I use to create node modules.
JavaScript
6
star
33

vim-relative-indent

Hide leading indent
Vim Script
5
star
34

hook.io-npm

Hook that emits on npm module updates.
JavaScript
5
star
35

jps

A scraper for the jpopsuki tracker.
JavaScript
5
star
36

nickserv

Communicates with the NickServ IRC service
JavaScript
5
star
37

node-streamit

JavaScript
4
star
38

ann

IRC bot made to announce and for convenience.
CoffeeScript
4
star
39

vim-frozen

colorscheme for vim
Vim Script
3
star
40

twi

really basic twitter cli client
JavaScript
3
star
41

node-writestreamp

A writable file stream that creates directories as needed.
JavaScript
3
star
42

gifchat

gifphy bot for hipchat
JavaScript
2
star
43

queue2.js

A unordered queue and ordered queue working together.
JavaScript
2
star
44

pokenum

A way to remember numbers using Pokemon.
JavaScript
1
star
45

node-muk-require

Mock dependencies
JavaScript
1
star
46

nickie

Nickserv irc bot.
JavaScript
1
star
47

node-callme

Hey I just met you, and this is crazy, but here's my callback.
JavaScript
1
star
48

jquery.rubber.js

jQuery plugin that stretches text fields to fit their content.
JavaScript
1
star