@mondaydotcomorg/atp-compiler
Version:
Production-ready compiler for transforming async iteration patterns into resumable operations with checkpoint-based state management
60 lines • 1.82 kB
JavaScript
/**
* Example: Loop Transformer as a Plugin
*
* Shows how to migrate existing LoopTransformer to plugin architecture
* This demonstrates the migration path for built-in transformers
*/
import { LoopTransformer } from '../../transformer/loop-transformer.js';
/**
* Loop Transformer Plugin
*
* Transforms for...of, while, and for loops into resumable versions
* with checkpoint-based state management
*/
export class LoopTransformerPlugin {
name = 'loop-transformer';
version = '1.0.0';
priority = 50; // Standard priority for core transformations
transformer;
constructor(batchSizeThreshold = 10) {
this.transformer = new LoopTransformer(batchSizeThreshold);
}
initialize(config) {
// Initialize with config if needed
console.log('[LoopTransformerPlugin] Initialized');
}
getVisitor(config) {
return {
ForOfStatement: (path) => {
this.transformer.transformForOfLoop(path);
},
WhileStatement: (path) => {
this.transformer.transformWhileLoop(path);
},
ForStatement: (path) => {
this.transformer.transformForLoop(path);
},
};
}
getMetadata() {
return {
loopCount: this.transformer.getTransformCount(),
arrayMethodCount: 0,
parallelCallCount: 0,
batchableCount: 0,
};
}
reset() {
this.transformer.resetTransformCount();
}
dispose() {
console.log('[LoopTransformerPlugin] Disposed');
}
}
/**
* Factory function for easy creation
*/
export function createLoopTransformerPlugin(batchSizeThreshold) {
return new LoopTransformerPlugin(batchSizeThreshold);
}
//# sourceMappingURL=loop-transformer-plugin.js.map