1.1.3 • Published 7 years ago

expiry-timer v1.1.3

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

#Expiry Timer NPM

Code Climate Build Status dependencies Status

Sometimes, it's useful in code to know if a certain amount of time has elapsed.

This module (dependent only on the babel-runtime) provides a nice, neat interface for that

Installation

npm i expiry-timer --save

Usage

import timer from '../src/timer';

const e = timer(5000); // 5 seconds;

/*
 * Some time later 
 */
if (e.done()) {
    /* Do a thing */
    e.reset(); // Clock starts ticking immediately
}

API

To create a timer that counts down for time milliseconds:

const counter = timer(time);

Call done() on the timer to see if it has expired:

if (counter.done() {
    /* do something */
}

Call reset() to reset the timer back to its original length.

Call reset(newLength) to reset the timer to a new length.

License

Provided under the MIT License.

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago