kitten-cloud-function
Version:
用于编程猫源码云功能(云变量、云列表等)的客户端工具
47 lines (46 loc) • 1.3 kB
JavaScript
import { RevocableCommandGroup } from "../../../../utils/command/revocable-command-group";
import { None } from "../../../../utils/other";
export class KittenCloudDataUpdateCommandGroup extends RevocableCommandGroup {
removeFrontIneffective() {
let count = 0;
let firstCommand;
while ((firstCommand = this.first()) != None) {
if (firstCommand.isEffective()) {
break;
}
else {
firstCommand.finish();
this.shift();
count++;
}
}
return count;
}
removeBackIneffective() {
let count = 0;
let lastCommand;
while ((lastCommand = this.last()) != None) {
if (lastCommand.isEffective()) {
break;
}
else {
lastCommand.finish();
this.pop();
count++;
}
}
return count;
}
toCloudJSON() {
const result = [];
for (const command of this.commandArray) {
if (command.isLegal()) {
result.push(command.toCloudJSON());
}
}
return result;
}
toCloudString() {
return JSON.stringify(this.toCloudJSON());
}
}