GithubHelp home page GithubHelp logo

sumonst21 / feed-watcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yayudev/feed-watcher

0.0 3.0 0.0 16 KB

A rss watcher optimized for synchronous data handling.

Home Page: https://www.npmjs.com/package/feed-watcher

License: MIT License

Makefile 3.23% JavaScript 96.77%

feed-watcher's Introduction

feed-watcher

npm version travis status
feed-watcher is a rss watcher based on Nikenozo's rss-watcher but optimized for synchronous data handling and storing of the results from the parse. Also it was rewritted to use promises as on not-event-based requests instead of callbacks for better code quality :)

Installation

You can install feed-watcher by using:

  npm install feed-watcher

Usage

A basic watcher can be created using:

  var Watcher  = require('feed-watcher'),
      feed     = 'http://lorem-rss.herokuapp.com/feed?unit=second&interval=5',
      interval = 10 // seconds

  // if not interval is passed, 60s would be set as default interval.
  var watcher = new Watcher(feed, interval)

  // Check for new entries every n seconds.
  watcher.on('new entries', function (entries) {
    entries.forEach(function (entry) {
      console.log(entry.title)
    })
  })

  // Start watching the feed.
  watcher
    .start()
    .then(function (entries) {
      console.log(entries)
    })
    .catch(function(error) {
      console.error(error)
    })

  // Stop watching the feed.
  watcher.stop()

Options

If you want to change the watcher config after creating it, you should use watcher.config:

  watcher.config({ feedUrl: feed, interval: 60 })

Events

Watcher exposes 3 events: 'new entries', 'stop' and 'error'.

  // Returns an array of entry objects founded since last check.
  watcher.on('new entries', function (entries) {
    console.log(entries)
  })

  // Emitted when watcher.stop() is called,
  watcher.on('stop', function () {
    console.log('stopped')
  })

  // Emitted when an error happens while checking feed.
  watcher.on('error', function (error) {
    console.error(error)
  })

Tests

Tests can be run using

  npm test

License

Project License can be found here

feed-watcher's People

Contributors

yayudev avatar

Watchers

James Cloos avatar Md. Sumon Islam avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.