0.0.1 • Published 7 years ago

lazywise v0.0.1

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

lazywise

check conditions periodically and invoke the specified function 'once' satisfied

how it works

example

const lazywise = require('lazywise');

var n = 0;
var list = [];
const readyCheck = function (name) {
    console.log('readyCheck: ' + ++n);
    if (list.length < 5) {
        list.push(name);
    }
    return list.length;
};

const finishingMove = function (err, name, delayed, restart) {
    list = [];
    console.log('====== finishingMove ======');
    restart();
};

lazywise.start('foo', readyCheck, 100, 1000, 3000, null, finishingMove);

output:

readyCheck: 1
readyCheck: 2
readyCheck: 3
readyCheck: 4
readyCheck: 5
readyCheck: 6
readyCheck: 7
readyCheck: 8
readyCheck: 9
readyCheck: 10
readyCheck: 11
readyCheck: 12
readyCheck: 13
readyCheck: 14
readyCheck: 15
====== finishingMove ======
readyCheck: 16
readyCheck: 17
readyCheck: 18
readyCheck: 19
readyCheck: 20
readyCheck: 21
readyCheck: 22
readyCheck: 23
readyCheck: 24
readyCheck: 25
readyCheck: 26
readyCheck: 27
readyCheck: 28
readyCheck: 29
readyCheck: 30
====== finishingMove ======
...