wait
wait
延时函数,可以用来模拟网络延迟,比如:wait(1)
表示延迟 1 秒
🍱 参数
number
- 延时的秒数
🔥 返回值
boolean
🚀 示例
import { wait } from 'atools-js';
const handleTest = async () => {
await wait(1);
console.log('wait 1s'); // wait 1s
};
💡 源码
source code
/atools/_basic/wait.ts
export const wait = async (milliseconds: number) =>
new Promise((resolve) => setTimeout(resolve, milliseconds));