zhongrj
2026-06-02 0299e41c6692684d943b4a206472a86ea84ea4b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function executeFunction (callbackArray, amount) {
    return new Promise(function (resolve, reject) {
        let index = 0
        let currentIndex = 1
 
        function execute () {
            try {
                callbackArray[index]()
                index++
            } catch (e) {
                return new Error(e)
            } finally {
                if (currentIndex == callbackArray.length) {
                    resolve
                }
                execute()
                currentIndex++
            }
        }
        execute()
    })
}
 
export function deepClone(obj) {
    if (obj === null || typeof obj !== 'object') {
        return obj
    }
    if (obj instanceof Date) {
        return new Date(obj.getTime())
    }
    if (obj instanceof Array) {
        return obj.map(item => deepClone(item))
    }
    if (typeof obj === 'object') {
        const clonedObj = {}
        for (let key in obj) {
            if (Object.prototype.hasOwnProperty.call(obj, key)) {
                clonedObj[key] = deepClone(obj[key])
            }
        }
        return clonedObj
    }
}
 
export default executeFunction