mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 21:01:06 -05:00
21 lines
430 B
JavaScript
21 lines
430 B
JavaScript
function pWaitFor(condition, options = {}) {
|
|
return new Promise((resolve, reject) => {
|
|
const interval = setInterval(() => {
|
|
if (condition()) {
|
|
clearInterval(interval)
|
|
resolve()
|
|
}
|
|
}, options.interval || 20)
|
|
|
|
if (options.timeout) {
|
|
setTimeout(() => {
|
|
clearInterval(interval)
|
|
reject(new Error("Timed out"))
|
|
}, options.timeout)
|
|
}
|
|
})
|
|
}
|
|
|
|
module.exports = pWaitFor
|
|
module.exports.default = pWaitFor
|