* Adds a loop container block.
(
id: string,
position?: Position,
config?: {
iterations?: number
loopType?: 'for' | 'forEach' | 'while' | 'doWhile'
}
)
| 104 | * Adds a loop container block. |
| 105 | */ |
| 106 | addLoop( |
| 107 | id: string, |
| 108 | position?: Position, |
| 109 | config?: { |
| 110 | iterations?: number |
| 111 | loopType?: 'for' | 'forEach' | 'while' | 'doWhile' |
| 112 | } |
| 113 | ): this { |
| 114 | this.blocks[id] = createBlock({ |
| 115 | id, |
| 116 | type: 'loop', |
| 117 | name: 'Loop', |
| 118 | position: position ?? { x: 0, y: 0 }, |
| 119 | data: { |
| 120 | loopType: config?.loopType ?? 'for', |
| 121 | count: config?.iterations ?? 3, |
| 122 | type: 'loop', |
| 123 | }, |
| 124 | }) |
| 125 | this.loops[id] = { |
| 126 | id, |
| 127 | nodes: [], |
| 128 | iterations: config?.iterations ?? 3, |
| 129 | loopType: config?.loopType ?? 'for', |
| 130 | } |
| 131 | return this |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Adds a block as a child of a loop container. |
no test coverage detected