* Find a non-computed, non-spread Property by its Identifier key name. * Handles both `Property` (ESTree) and `ObjectProperty` (Babel) node types.
(obj: ObjectExpression, name: string)
| 155 | * Handles both `Property` (ESTree) and `ObjectProperty` (Babel) node types. |
| 156 | */ |
| 157 | function findKey(obj: ObjectExpression, name: string): Property | undefined { |
| 158 | for (const prop of obj.properties) { |
| 159 | if (prop.type !== 'Property' && prop.type !== 'ObjectProperty') continue |
| 160 | if ((prop as Property).computed) continue |
| 161 | const key = (prop as Property).key |
| 162 | if (key.type === 'Identifier' && key.name === name) { |
| 163 | return prop as Property |
| 164 | } |
| 165 | } |
| 166 | return undefined |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Extract the value expression of a property, expanding shorthand. For a |
no outgoing calls
no test coverage detected