Files
Roo-Code/src/__mocks__/p-wait-for.js
2025-01-17 14:11:28 -05:00

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