This module offers a variety of ways to implement loops in TSL. In it’s basic form it’s:
Loop( count, ( { i } ) => {
} );
export {}However, it is also possible to define a start and end ranges, data types and loop conditions:
Loop( { start: int( 0 ), end: int( 10 ), type: 'int', condition: '<' }, ( { i } ) => {
} );
export {}Nested loops can be defined in a compacted form:
Loop( 10, 5, ( { i, j } ) => {
} );
export {}Loops that should run backwards can be defined like so:
Loop( { start: 10 }, () => {} );
export {}It is possible to execute with boolean values, similar to the while syntax.
const value = float( 0 ).toVar();
Loop( value.lessThan( 10 ), () => {
value.addAssign( 1 );
} );
export {}The module also provides Break() and Continue() TSL expression for loop control.
Constructor
new LoopNode(params?)| Parameter | Type | Default Value |
|---|---|---|
| params? | Array<any> | [] |
Constructs a new loop node.
| Accessor | Type | |
|---|---|---|
| get type | string | |
Properties
| Property | Type | Default Value | |
|---|---|---|---|
| params | Array<any> | — | |
| Method | Type | |
|---|---|---|
| getVarName | (index: number) => string | |
| getProperties | (builder: NodeBuilder) => Object | |
| setup | (builder: any) => void | |
| generate | (builder: any) => void | |
Extends
NodeTSL function for creating a loop node.
Properties
...Array<any>Returns
LoopNodeTSL function for creating a Continue() expression.
Returns
ExpressionNodeTSL function for creating a Break() expression.
Returns
ExpressionNode