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

url-keeper

v1.2.1

Published

Dynamically maintains a list of URLs based on their availability in a given time interval. You can also add or remove an URL on the fly. Uses url-monitor and event-timer.

Downloads

2

Readme

url-keeper

Dynamically maintains a list of URLs based on their availability in a given time interval. You can also add or remove a URL on the fly. Uses url-monitor and event-timer.

Installation

npm install url-keeper

How to

Here a simple example with the 'change' event, in fact a timer based on interval option, which gives you a Javascript Object with detailed informations (http status codes, status, last checked time) :

// Load module
var urlkeeper = require('./url-keeper.js');

// create url-keeper instance
var monitor = new urlkeeper({
    interval: 5000,                    // 5000 ms by default, optional
    timeout: 3000,                     // 3000 ms by default, optional
    list:['http://www.google.fr',      // Mandatory
          'http://www.microsoft.com',
          'http://www.apple.com',
          'https://www.debian.org']
});

// Timer which refreshes results on time interval
monitor.on('change', (data) => { 
    console.dir(data,{colors: true}); 
})

// Add an url
monitor.add('http://www.npmjs.com');

// Start url-keeper
monitor.start();

The results given by the 'change' event will be :

{ 
    'http://www.google.fr': { 
        code: 200, 
        status: 'available', 
        time: 1462138566961 
    },
    'http://www.microsoft.com': { 
        code: 200, 
        status: 'available', 
        time: 1462138566917 
    },
    'http://www.apple.com': { 
        code: 200, 
        status: 'available', 
        time: 1462138567049 
    },
    'https://www.debian.org': { 
        code: 200, 
        status: 'available', 
        time: 1462138567341 
    },
    'http://www.npmjs.com': { 
        code: 301, 
        status: 'available', 
        time: 1462138567062 
    } 
}

If you want to manage the refresh of the list by yourself without the 'change' event, you can access the list with this method (but the interval option is always necessary for URL checking) :

// create url-keeper instance
var monitor = new urlkeeper({
    eventTimer: 'false',               // 'true' by default, optional
    list:['http://www.google.fr',      // Mandatory
          'http://www.microsoft.com',
          'http://www.apple.com',
          'https://www.debian.org']
});

monitor.start();

monitor.getList();

You can get an array of the URLs (for an example, to get the updated list passed at origin in the options before stopping the instance) :

monitor.getURLs();

Or an array of the available URLs :

monitor.getAvailableURLs();

You can add or delete an url to the list on the fly :

monitor.add('https://my.secure.site');
monitor.del('https://my.secure.site');

If you want to know if url-keeper is running (returns 'true' or 'false'):

monitor.isRunning();

To stop url-keeper:

monitor.stop();

Updates

  • v1.2.1 : Updating dependencies
  • v1.2.0 : Add 'getAvailableURLs()' method and 'eventTimer' option
  • v1.0.1 : Removes an old reference to an unused module
  • v1.0.0 : Initial release

License

The MIT License (MIT) Copyright (c) 2016 Julien Blanc