MCPcopy
hub / github.com/RaspberryPiFoundation/blockly / text_join

Function text_join

packages/blockly/generators/dart/text.ts:26–51  ·  view source on GitHub ↗
(
  block: Block,
  generator: DartGenerator,
)

Source from the content-addressed store, hash-verified

24}
25
26export function text_join(
27 block: Block,
28 generator: DartGenerator,
29): [string, Order] {
30 // Create a string made up of any number of elements of any type.
31 const joinBlock = block as JoinMutatorBlock;
32 switch (joinBlock.itemCount_) {
33 case 0:
34 return ["''", Order.ATOMIC];
35 case 1: {
36 const element =
37 generator.valueToCode(block, 'ADD0', Order.UNARY_POSTFIX) || "''";
38 const code = element + '.toString()';
39 return [code, Order.UNARY_POSTFIX];
40 }
41 default: {
42 const elements = new Array(joinBlock.itemCount_);
43 for (let i = 0; i < joinBlock.itemCount_; i++) {
44 elements[i] =
45 generator.valueToCode(block, 'ADD' + i, Order.NONE) || "''";
46 }
47 const code = '[' + elements.join(',') + '].join()';
48 return [code, Order.UNARY_POSTFIX];
49 }
50 }
51}
52
53export function text_append(block: Block, generator: DartGenerator) {
54 // Append to a variable in place.

Callers

nothing calls this directly

Calls 1

valueToCodeMethod · 0.80

Tested by

no test coverage detected