@dotmh/tick
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

DotMH.dev

DotMH Tick.

DotMH Tick is designed for making polling loops when needed easier.

Installation

npm i @dotmh/tick

Usage

To use Tick you first have to require it.

const Tick = require('@dotmh/tick')

Then create a new instance of the class

const tick = new Tick();

Then set up tick

tick.every('2ms').start(() => console.log('hello world'));

You can stop the tick with

tick.stop()

You can also set a condition which mean the callback will be called if the condition function return true.

tick.every('2s').when(() => true).start(() => console.log('do something'));

See vercel/ms to see more about the format for the time string.

Readme

Keywords

Package Sidebar

Install

npm i @dotmh/tick

Weekly Downloads

0

Version

2.0.1

License

Apache-2.0

Unpacked Size

14.8 kB

Total Files

5

Last publish

Collaborators

  • dotmh