1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-13 11:29:53 +03:00
inav-configurator/js/msp/MSPchainer.js
2024-02-26 11:58:56 -03:00

37 lines
No EOL
752 B
JavaScript

'use strict';
var MSPChainerClass = function () {
var self = {};
self.chain = [];
self.exitPoint = null;
self.chainIndex = 0;
self.setChain = function (chain) {
self.chain = chain;
};
self.setExitPoint = function (exitPoint) {
self.exitPoint = exitPoint;
};
self.returnCallback = function () {
self.chainIndex++;
if (self.chain[self.chainIndex]) {
self.chain[self.chainIndex](self.returnCallback);
} else if (self.exitPoint) {
self.exitPoint();
}
};
self.execute = function () {
self.chainIndex = 0;
self.chain[self.chainIndex](self.returnCallback);
};
return self;
};
module.exports = MSPChainerClass;