1.0.0 • Published 4 years ago
interval-as-class v1.0.0
interval-as-class
setTimeout
, just as a class.
Usage
The package exports the Interval
class as default export.
Interval(func, time, { aligned, offset, start})
Creates a new Interval
instance.
The following arguments are supported:
func
: The function that should be called at each intervaltime
: The time between each function call in millisecondsaligned
: Iftrue
, aligns the time of the function calls whenDate.now() % time
is close to zero (default:false
)offset
: Ifaligned
istrue
, this value will be used as offset to the aligned time (default:0
)start
: Iftrue
, theInterval
will start immediately without callingstart()
start()
Starts calling the function at the given intervals.
stop()
Stops calling the function.
1.0.0
4 years ago