UNPKG

rete-kit

Version:

Rete.js Kit ==== [![Made in Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7)](https://stand-with-ukraine.pp.ua) [![Discord](https://img.shields.io/discord/1081223198055604244?color=%237289da&label=Discord)](https://disco

40 lines (39 loc) 1.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SingleFileStrategy = void 0; /** * Strategy for merging all instructions into a single file */ class SingleFileStrategy { constructor(outputFileName, contentTransformerFactory) { this.outputFileName = outputFileName; this.contentTransformerFactory = contentTransformerFactory; } transform(instructions) { if (instructions.length === 0) { return instructions; } // Process each instruction individually (apply transformers), then merge them const processedContents = instructions.map(instruction => { const contentTransformers = this.contentTransformerFactory ? this.contentTransformerFactory(instruction) : []; let content = instruction.content; for (const transformer of contentTransformers) { content = transformer.transform(content); } return content; }); // Combine all processed instruction contents const finalContent = processedContents.join('\n\n'); return [ { content: finalContent, file: this.outputFileName, contextId: instructions[0].contextId, title: instructions[0].title } ]; } } exports.SingleFileStrategy = SingleFileStrategy;