MCPcopy Create free account
hub / github.com/donghaxkim/react-rewrite / getObjectPropertyValueNode

Function getObjectPropertyValueNode

packages/cli/src/batch-transform.ts:752–766  ·  view source on GitHub ↗
(objectExpression: any, propertyName: string)

Source from the content-addressed store, hash-verified

750}
751
752function getObjectPropertyValueNode(objectExpression: any, propertyName: string): any | null {
753 for (const property of objectExpression?.properties ?? []) {
754 if (property?.type !== "Property" && property?.type !== "ObjectProperty") continue;
755 const keyName =
756 property.key?.type === "Identifier"
757 ? property.key.name
758 : property.key?.type === "StringLiteral" || property.key?.type === "Literal"
759 ? String(property.key.value ?? "")
760 : null;
761 if (keyName === propertyName) {
762 return property.value ?? null;
763 }
764 }
765 return null;
766}
767
768function resolveVariableDeclaratorByName(j: any, root: any, name: string): any | null {
769 const matches = root.find(j.VariableDeclarator, {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected