| | |
| | | /* |
| | | * @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 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 |