开发者社区> 镜像站> NPM> sim-timer
sim-timer
Discrete timer for simulations
Last updated 7 years ago by emilbay .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install sim-timer 
SYNC missed versions from official npm registry.

sim-timer.js

Discrete timer for simulations.

Installation

npm install sim-timer

Methods

#####var t = new Timer;

Singleton constructor for Timer.

Returns either new instance or existing instance of Timer.

#####t.tick();

Advance time by 1 unit, and call appropriate intervals.

Returns the new time.

#####t.setInterval(delay, callback); Add a new interval to the timer. Opposed the the default Javascript setInterval, this takes the delay first and then the callback.

delay time delay between calls.
callback function to be called at appropriate tick.

Returns id of the interval. This is used the clear the interval.

#####t.clearInterval(id);

Removes the interval from the timer.

id of the interval

Returns Timer for chaining.

Current Tags

  • 0.0.2                                ...           latest (7 years ago)

2 Versions

  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)