habitica/website/server/libs/sleep.js

16 lines
323 B
JavaScript
Raw Permalink Normal View History

// using import common from '../../common';
// the test:unit can't be compiled
// so the sleepAsync can't be used here (to prevent duplicated code)
2024-03-11 14:59:57 +00:00
function sleep (seconds = 1) {
2019-10-08 14:57:10 +00:00
const milliseconds = seconds * 1000;
2019-10-08 14:57:10 +00:00
return new Promise(resolve => {
setTimeout(resolve, milliseconds);
});
2019-10-08 14:57:10 +00:00
}
2024-03-11 14:59:57 +00:00
export {
sleep,
};