* 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)
| 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. |
no test coverage detected