interval-task-runner
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

IntervalTaskRunner

Repeatedly executes a function with a minimum time delay between reach call (with millisecond precision). Written in TypeScript.

Installation and Usage

Install

npm install interval-task-runner

Example Usages

import { IntervalTaskRunner, Interval } from 'interval-task-runner';
 
const task = () => console.log('foo'); // The task to run.
 
// example 1
const interval = Interval.fromHz(10); // Run task approx. 10 times per second.
const runner = new IntervalTaskRunner(task, interval);
runner.start(); // Now printing 'foo' ~10 times per second.
// Later...
runner.stop(); // No longer printing 'foo'.
 
// example 2
const interval = Interval.fromMs(100); // Run task approx. every 100 milliseconds (or 10 Hz).
const runner = new IntervalTaskRunner(task, interval).start(); // One-liner.
runner.stop();

API

Readme

Keywords

none

Package Sidebar

Install

npm i interval-task-runner

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

28.3 kB

Total Files

36

Last publish

Collaborators

  • akolos