优化重试请求逻辑

This commit is contained in:
tangly1024
2022-04-29 14:50:54 +08:00
parent 869cd0a3c9
commit 245290d46d
4 changed files with 60 additions and 33 deletions

View File

@@ -80,3 +80,22 @@ export function isObject(item) {
export function isIterable(obj) {
return obj != null && typeof obj[Symbol.iterator] === 'function'
}
export function deepClone(obj) {
const newObj = Array.isArray(obj) ? [] : {}
if (obj && typeof obj === 'object') {
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
newObj[key] = (obj && typeof obj[key] === 'object') ? deepClone(obj[key]) : obj[key]
}
}
}
return newObj
}
/**
* 延时
* @param {*} ms
* @returns
*/
export const delay = ms => new Promise(resolve => setTimeout(resolve, ms))