MCPcopy Create free account
hub / github.com/TanStack/ai / findKey

Function findKey

codemods/move-sampling-to-model-options/transform.ts:157–167  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

155 * Handles both `Property` (ESTree) and `ObjectProperty` (Babel) node types.
156 */
157function 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

Callers 2

resolveProviderFunction · 0.70
transformFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected