diff --git a/index.js b/index.js index 2ff5efca283366476e67176d17a2436be0d5dbf6..9b2b1a9062d5a7169b5290a6f679da8489aebf13 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/test.js b/test.js deleted file mode 100644 index 56b441181634075f986a8ff161cf3cbe1d86a56d..0000000000000000000000000000000000000000 --- a/test.js +++ /dev/null @@ -1,10 +0,0 @@ -const { loopWithPromise } = require('./index'); - -(async () => { - // 一定要加上 await - await loopWithPromise(5, 300, (count) => { - console.log("执行次数: " + count); - }); - - console.log("执行完成!"); -})(); \ No newline at end of file