fix: wait for elapsed

This commit is contained in:
cha0s 2024-09-14 17:30:42 -05:00
parent fc96f637ff
commit 89044ab2cf

View File

@ -48,10 +48,20 @@ export default class Script {
Math: MathUtil,
Promise: PromiseUtil,
transition,
wait: (seconds) => (
new Promise((resolve) => {
setTimeout(resolve, seconds * 1000);
})
wait: (seconds = 0) => (
new PromiseUtil.Ticker(
(resolve) => {
if (0 === seconds) {
resolve();
}
},
(elapsed, resolve) => {
seconds -= elapsed;
if (seconds <= 0) {
resolve();
}
}
)
),
};
}