habitica/website/server/libs/sleep.js

12 lines
316 B
JavaScript
Raw 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)
export default 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
}