29 lines
920 B
JavaScript
29 lines
920 B
JavaScript
"use strict";
|
|
|
|
// Layer: shared-runtime/pipeline
|
|
// Small helper for explicit ordered update-step pipelines.
|
|
(function (global) {
|
|
function create(stepNames, invokeStep) {
|
|
const names = Object.freeze([...(stepNames || [])]);
|
|
let cachedSteps = null;
|
|
|
|
function steps() {
|
|
if (!cachedSteps) cachedSteps = names.map(name => global[name]);
|
|
return cachedSteps;
|
|
}
|
|
|
|
function run(...args) {
|
|
const concrete = steps();
|
|
if (concrete.length !== names.length || concrete.some(step => !step || typeof step.update !== "function")) return false;
|
|
for (const step of concrete) {
|
|
const result = invokeStep(step, ...args) || {};
|
|
if (result.done) return result.ok !== false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return Object.freeze({ run });
|
|
}
|
|
|
|
global.TarinaiUpdateStepPipelineRunner = Object.freeze({ create });
|
|
})(typeof window !== "undefined" ? window : globalThis);
|