lazywise

0.0.1 • Public • Published

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 ======
...

Readme

Keywords

Package Sidebar

Install

npm i lazywise

Weekly Downloads

1

Version

0.0.1

License

ISC

Last publish

Collaborators

  • edwingeng