0.1.1 • Published 4 months ago

mininterval-runner v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

mininterval-runner

CI

Repeated execution with minimum interval control. Useful for running crawlers.

Usage

import { MinIntervalRunner } from 'mininterval-runner';

const task = async (runner) => {
    // do something

    // Stop executing the task when needed
    // runner.stop();
};

// Create a new MinIntervalRunner instance with a minimum interval of 5 minutes and the task function
const runner = new MinIntervalRunner(5 * 60 * 1000, task);

// The following listeners can be set if needed (usually for logging)
// runner.onStart
// runner.onBeforeWaiting
// runner.onAfterWaiting
// runner.onBeforeExecuting
// runner.onAfterExecuting
// runner.onStop
// runner.onTaskError // if this handler returns `true`, the task will restart immediately instead of waiting for the mininterval.

// Start executing the task
await runner.start();

License

MIT

0.1.1

4 months ago

0.1.0

4 months ago