0.0.1 • Published 10 years ago

every-moment v0.0.1

Weekly downloads
31
License
MIT
Repository
github
Last release
10 years ago

NPM version Build Status Dependency Status

Declarative setInterval using moment durations

Getting Started

See usage for example of combining the 'wait-one-moment' module for declarative setTimeout and setInterval.

Install

$ npm install --save every-moment

Usage

var every = require('every-moment');
var wait = require('wait-one-moment');
var potatoes;

var timer = every(1, 'second', function() {
    console.log(this.duration);
});

wait(5, 'seconds', function() {
    timer.set(2, 'seconds').start();
});

wait(10, 'seconds', function() {
    console.log('Stop the clock!');
    timer.stop();
});

wait(15, 'seconds', function() {
    if(!potatoes) {
        console.log('No potatoes :(');
        potatoes = true;
        this.start();
    } else {
        console.log('YUM :)');
    }
});

License

MIT © Ray Gerrard