function copy(copyList, cutflag = false) {
    if (copyList.length === 0) return;
    var tempScope = new Scope(globalScope.name, globalScope.id);
    var oldOx = globalScope.ox;
    var oldOy = globalScope.oy;
    var oldScale = globalScope.scale;
    var d = backUp(globalScope);
    const oldTestbenchData = globalScope.testbenchData;

    loadScope(tempScope, d);
    scopeList[tempScope.id] = tempScope;

    if (cutflag) {
        for (let i = 0; i < copyList.length; i++) {
            const obj = copyList[i];
            if (obj.objectType === 'Node') obj.objectType = 'allNodes';
            for (let j = 0; j < tempScope[obj.objectType].length; j++) {
                if (tempScope[obj.objectType][j].x === obj.x && tempScope[obj.objectType][j].y === obj.y && (obj.objectType != 'Node' || obj.type === 2)) {
                    tempScope[obj.objectType][j].delete();
                    break;
                }
            }
        }
    }
    tempScope.backups = globalScope.backups;
    for (let i = 0; i < updateOrder.length; i++) {
        let prevLength = globalScope[updateOrder[i]].length; // LOL length of list will reduce automatically when deletion starts
        for (let j = 0; j < globalScope[updateOrder[i]].length; j++) {
            const obj = globalScope[updateOrder[i]][j];
            if (obj.objectType != 'Wire') { // }&&obj.objectType!='CircuitElement'){//}&&(obj.objectType!='Node'||obj.type==2)){
                if (!copyList.contains(globalScope[updateOrder[i]][j])) {
                    globalScope[updateOrder[i]][j].cleanDelete();
                }
            }

            if (globalScope[updateOrder[i]].length != prevLength) {
                prevLength--;
                j--;
            }
        }
    }

    var prevLength = globalScope.wires.length;
    for (let i = 0; i < globalScope.wires.length; i++) {
        globalScope.wires[i].checkConnections();
        if (globalScope.wires.length != prevLength) {
            prevLength--;
            i--;
        }
    }

    updateSimulationSet(true);

    var data = backUp(globalScope);
    data.scopes = [];
    var dependencyList = {};
    var requiredDependencies = globalScope.getDependencies();
    var completed = {};
    Object.keys(scopeList).forEach((id) => {
        dependencyList[id] = scopeList[id].getDependencies();
    });
    function saveScope(id) {
        if (completed[id]) return;
        for (let i = 0; i < dependencyList[id].length; i++) { saveScope(dependencyList[id][i]); }
        completed[id] = true;
        data.scopes.push(backUp(scopeList[id]));
    }
    for (let i = 0; i < requiredDependencies.length; i++) { saveScope(requiredDependencies[i]); }
    data.logixClipBoardData = true;
    data.testbenchData = undefined // Don't copy testbench data
    data = JSON.stringify(data);
    simulationArea.multipleObjectSelections = []; // copyList.slice();
    simulationArea.copyList = []; // copyList.slice();
    var canvasUpdate = true;
    updateSimulationSet(true);
    globalScope = tempScope;
    scheduleUpdate();
    globalScope.ox = oldOx;
    globalScope.oy = oldOy;
    globalScope.scale = oldScale;
    // Restore testbench data
    if (oldTestbenchData) {
        globalScope.testbenchData = new TestbenchData(
            oldTestbenchData.testData,
            oldTestbenchData.currentGroup,
            oldTestbenchData.currentCase
        );
    }

    forceResetNodesSet(true);
    // needs to be fixed
    // eslint-disable-next-line consistent-return
    return data;
}
Helper function for copy
@param {JSON} copyList - The data to copied
@param {boolean} cutflag - flase if we want to copy
@category events