jxdnsong
2023-04-05 be147d2a99d60a30b20fade742e85b45f06172ae
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
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-10-17 09:34:19
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2022-10-17 09:45:20
 * @FilePath: \srs-police-affairs\src\utils\tool.js
 * @Description: 
 * 
 * Copyright (c) 2022 by shuishen 1109946754@qq.com, All Rights Reserved. 
 */
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 default executeFunction