1.0.0 • Published 8 years ago

@dustinpoissant/timerjs v1.0.0

Weekly downloads
1
License
CC-BY-NC-SA-3.0
Repository
github
Last release
8 years ago

Timer JS

1.0.0

A simple JavaScript timer prototype.

Create a new instance of Timer

var t = new Timer();
Auto Start

If you would like the timer to be started automatically (when it is created) just pass true into the constructor.

var t = new Timer(true);

Start

t.start();

Time

console.log(t.time);

The time is in milliseconds, divide by 1000 to convert it to seconds. t.time/1000. You can also set the time using the time member.

Pause

t.pause();

The timer can be resumed after it has been paused.

Resume

t.resume(); // or t.start()

resume() and start() are identical and can be used interchangeably.

Toggle

t.toggle();

Starts the timer if it is stopped, stops it if it is running.

Stop

t.stop();

Stopping the timer is different from "pausing" because the timer can not be restarted (resumed or started) until the timer is reset.

Reset

t.reset();

Resetting the timer stops it and sets it to 0.

Running

console.log(t.running);

Determine if the timer is currently running or not using the running member.

#License

This software is property of Dustin Poissant.

This software is distributed AS-IS with no warranties/guarantees either expressed or implied.

This software is Licensed under CC BY-NC-SA 3.0 US.

1.0.0

8 years ago