Neatly Planned Meal

    every-moment

    0.0.1 • Public • Published

    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

    Install

    npm i every-moment

    DownloadsWeekly Downloads

    7

    Version

    0.0.1

    License

    MIT

    Last publish

    Collaborators

    • raygerrard