1.0.4 • Published 8 years ago

is-time-to-run v1.0.4

Weekly downloads
16
License
-
Repository
github
Last release
8 years ago

is-time-to-run

NPM

Motivation

I run a script which checks availability of websites. This script is run in crone every 5 minutes. If any of the website is unavailable I need to send an e-mail. But I don't want to send this e-mail every 5 minutes but every hour.

This module allows to check if certain period of time has passed and allow your script to run again. It aims at stateless scripts (that don't run in loop as a daemon) and for this purpose it utilises a helper file where it stores information about the last time your script has run.

API

isTime(callback)

This method will return information if your code can be executed again. If it can it will change the helper file to the current time.

Usage

var IsTimeToRun = require('is-time-to-run');

var timeChecker = new IsTimeToRun({
    path: 'tmp/',   # default ''
    period: '30',   # default 60
    unit: 'minutes' # default 'minutes'
});

timeChecker.isTime((err, canRun) => {
    
});
1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago