mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
24 lines
438 B
JavaScript
24 lines
438 B
JavaScript
var Promise = require('bluebird')
|
|
|
|
module.exports.periodicNotify = function(promise, interval) {
|
|
var resolver = Promise.defer()
|
|
, timer = setInterval(notify, interval)
|
|
|
|
function notify() {
|
|
resolver.progress()
|
|
}
|
|
|
|
function resolve() {
|
|
resolver.resolve()
|
|
}
|
|
|
|
function reject() {
|
|
resolver.reject()
|
|
}
|
|
|
|
promise.then(resolve, reject)
|
|
|
|
return resolver.promise.finally(function() {
|
|
clearInterval(timer)
|
|
})
|
|
}
|