提交 6071192a 编写于 作者: Q qq_20735085

Tue Mar 26 10:41:00 CST 2024 inscode

上级 f73384d4
......@@ -15,4 +15,11 @@ async function loopWithPromise(count, duration, callback) {
}
}
module.exports.loopWithPromise = loopWithPromise;
\ No newline at end of file
(async () => {
// 一定要加上 await,可以实现调用点阻塞
await loopWithPromise(5, 300, (count) => {
console.log("执行次数: " + count);
});
console.log("执行完成!");
})();
\ No newline at end of file
const { loopWithPromise } = require('./index');
(async () => {
// 一定要加上 await
await loopWithPromise(5, 300, (count) => {
console.log("执行次数: " + count);
});
console.log("执行完成!");
})();
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册