t-comm
Version:
专业、稳定、纯粹的工具库
29 lines (25 loc) • 509 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
/**
* 等待一段时间
* @func
* @param {number} ms 毫秒
* @returns Promise
* @example
*
* async function main() {
* await sleep(2000)
*
* // 等待2秒后才会打印
* console.log('hello')
* }
*
* main()
*/
var sleep = function sleep(ms) {
return new Promise(function (res) {
return setTimeout(res, ms);
});
};
// const numList = Array.from({ length: 10 }, (_, i) => i);
exports.sleep = sleep;