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

Method getField

packages/blockly/core/block.ts:1130–1145  ·  view source on GitHub ↗

* Returns the named field from a block. * * @param name The name of the field. * @returns Named field, or null if field does not exist.

(name: string)

Source from the content-addressed store, hash-verified

1128 * @returns Named field, or null if field does not exist.
1129 */
1130 getField(name: string): Field | null {
1131 if (typeof name !== 'string') {
1132 throw TypeError(
1133 'Block.prototype.getField expects a string ' +
1134 'with the field name but received ' +
1135 (name === undefined ? 'nothing' : name + ' of type ' + typeof name) +
1136 ' instead',
1137 );
1138 }
1139 for (const field of this.getFields()) {
1140 if (field.name === name) {
1141 return field;
1142 }
1143 }
1144 return null;
1145 }
1146
1147 /**
1148 * Returns a generator that provides every field on the block.

Callers 15

getFieldValueMethod · 0.95
setFieldValueMethod · 0.95
updateCollapsedMethod · 0.80
domToFieldFunction · 0.80
loadFieldsFunction · 0.80
runMethod · 0.80
runMethod · 0.80
CHARAT_EXTENSIONFunction · 0.80
variables.tsFile · 0.80

Calls 1

getFieldsMethod · 0.95

Tested by

no test coverage detected