提交 d4b46081 authored 作者: vipcxj's avatar vipcxj

fix: 补上sleep函数的实现

上级 e5109733
...@@ -117,6 +117,10 @@ export function filterValidParams(params) { ...@@ -117,6 +117,10 @@ export function filterValidParams(params) {
return _.pickBy(params, _.negate(_.isUndefined)); return _.pickBy(params, _.negate(_.isUndefined));
} }
export async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export async function tryIt(times, cb, delay) { export async function tryIt(times, cb, delay) {
let err; let err;
for (let i = 0; i < times; ++i) { for (let i = 0; i < times; ++i) {
...@@ -132,5 +136,5 @@ export async function tryIt(times, cb, delay) { ...@@ -132,5 +136,5 @@ export async function tryIt(times, cb, delay) {
if (err) { if (err) {
throw err; throw err;
} }
}; }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论