MCPcopy Index your code
hub / github.com/simstudioai/sim / addLoop

Method addLoop

packages/testing/src/builders/workflow.builder.ts:106–132  ·  view source on GitHub ↗

* Adds a loop container block.

(
    id: string,
    position?: Position,
    config?: {
      iterations?: number
      loopType?: 'for' | 'forEach' | 'while' | 'doWhile'
    }
  )

Source from the content-addressed store, hash-verified

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.

Callers 3

withLoopMethod · 0.80

Calls 1

createBlockFunction · 0.90

Tested by

no test coverage detected