Files
kidsai/html/rechner/node_modules/node-cron/dist/esm/tasks/state-machine.js
2025-06-24 15:43:32 +02:00

25 lines
766 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StateMachine = void 0;
const allowedTransitions = {
'stopped': ['stopped', 'idle', 'destroyed'],
'idle': ['idle', 'running', 'stopped', 'destroyed'],
'running': ['running', 'idle', 'stopped', 'destroyed'],
'destroyed': ['destroyed']
};
class StateMachine {
state;
constructor(initial = 'stopped') {
this.state = initial;
}
changeState(state) {
if (allowedTransitions[this.state].includes(state)) {
this.state = state;
}
else {
throw new Error(`invalid transition from ${this.state} to ${state}`);
}
}
}
exports.StateMachine = StateMachine;
//# sourceMappingURL=state-machine.js.map