flowie
Version:
Library for creating, and working with flows
31 lines • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const immutable_1 = require("immutable");
const flowie3_1 = require("./flowie3");
function buildFlowieFromContainer(flowieContainer, flow) {
if (flow.split) {
return buildSplitFlow(flow.split, flowieContainer);
}
const [firstFlowItemName, ...otherFlowItemNames] = flow.pipe;
const firstFlowItem = flowieContainer.functionsContainer[firstFlowItemName];
return buildPipeFlow(immutable_1.Seq.Indexed(otherFlowItemNames), flowieContainer, flowie3_1.flowie(firstFlowItem));
}
exports.default = buildFlowieFromContainer;
function buildSplitFlow(splitFunctions, flowieContainer) {
const result = splitFunctions.map(getFunctionsFromContainer, flowieContainer);
return flowie3_1.flowie(...result);
}
function buildPipeFlow(flowItemsNameSequence, flowieContainer, flowieFlow) {
const flowieItemName = flowItemsNameSequence.first();
const nextFunctionToPipe = flowieContainer.functionsContainer[flowieItemName];
const nextStepFlowieFlow = flowieFlow.pipe(nextFunctionToPipe);
const nextFlowieItemsNameSequence = flowItemsNameSequence.rest();
if (!nextFlowieItemsNameSequence.size) {
return nextStepFlowieFlow;
}
return buildPipeFlow(nextFlowieItemsNameSequence, flowieContainer, nextStepFlowieFlow);
}
function getFunctionsFromContainer(functionName) {
return this.functionsContainer[functionName];
}
//# sourceMappingURL=buildFlowieFromContainer.js.map