In TL-Script, calculations can be written particularly elegantly as processing chains, in which each expression represents a further processing of the result of the previous expression.
$projects .get(`...#milestones`) .filter(m -> $m.get(`...#open`)) ...
Sometimes, however, you need the result of the previous expression more than once - not just as input to the next function. In this case, you have to rebuild the expression - wrap it in a block, assign the previous result to a variable and continue calculating with the variable.
{ $openMilestones = $projects .get(`...#milestones`) .filter(m -> $m.get(`...#open`)); // Use $openMilestones in computation of result - potentially twice. }
It would be nicer if such an expression, which can access the entire previous result more than once - i.e. bind it to a variable - could also be formulated in the chain without having to rebuild the expression beforehand:
$projects .get(`...#milestones`) .filter(m -> $m.get(`...#open`)) .with(openMilestones -> ... $openMilestones ... $openMilestones )
The with() function expects a function and passes its input completely to this function. It therefore performs a similar task to map() in the chain. In contrast to map(), however, it is not the partial results that are transformed, but the entire result, and the final result is not necessarily a list as with map(), but exactly the result of the inner function.