A looser setInterval that schedules upon task completion to avoid overlap.
loose-interval Is designed to be similar to
setInterval but for tasks that you don't want to overlap. Instead of starting the process every
interval milliseconds, it pauses
interval milliseconds between the completion and next execution.
var looseInterval = require"loose-interval"// your function must provide a callback to call when it is done/* copy a bunch of files, or scrape a website or something *//* phew! that took a while, but I'm done now, let's callback */callbacksome cool args// Run your task waiting a minute between finish & rexecutionvar task = looseIntervalsomeSlowTask 60000// Execute a callback whenever it completesvar task = looseIntervalsomeSlowTask 60000 console.log// Stop recurrence of your tasktaskstop// Run it one timetaskrunOnce
Create a task. Requires a function (which has a callback) to execute. If no interval is given, it will not be executed or recur without
.start being called.
Interval is in milliseconds, and is the pause between your function's completion and next execution.
If a callback is provided, that callback will be executed with whatever arguments your function provides.
Start or change the interval of a recurring task. Interval is in milliseconds.
Stop the task for recurring. Can still be executed with
.runOnce or rescheduled with
Run the function a single time, without repeating. This does not respect a schedule version and can cause overlapping tasks.