船员公众号
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
704 B

2 months ago
// @ts-nocheck
/**
* Promise
* @param delay 300
* @returns Promise
*/
export const sleep = (delay: number = 300) =>
new Promise(resolve => setTimeout(resolve, delay));
// 示例
// async function example() {
// console.log("Start");
// // 延迟 1 秒后执行
// await sleep(1000);
// console.log("1 second later");
// // 延迟 500 毫秒后执行
// await sleep(500);
// console.log("500 milliseconds later");
// // 延迟 2 秒后执行
// await sleep(2000);
// console.log("2 seconds later");
// console.log("End");
// }
// example();