Postpone function execution
npm install node-postpone --save
var postpone = require('node-postpone');
Return current timestamp (milliseconds since 1970/01/01)
var now = postpone.now();
Postpone execution of a one-time action after delay
delay
: time in milisecondsrun
: function to execute afterdelay
postpone.wait(1000, function() {
console.log('done after 1 sec');
});
Execute a action and postpone execution of a one-time action after delay
delay
: time in milisecondsstart
: function to execute immediatelyrun
: function to execute afterdelay
postpone.runWait(1000,
function() {
console.log('done task 1 : immediately');
},
function() {
console.log('done task 2 : after 1 sec');
}
);
Execute a action and postpone execution of a one-time action after delay
delay
: time in milisecondsstart
: function to execute immediatelyrun
: function to execute afterdelay
afterstart
finish
postpone.runAndWait(1000,
function() {
console.log('done task 1 : immediately');
},
function() {
console.log('done task 2 : 1 sec after task 1 finish');
}
);
npm test
MIT