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

Function readStringLiteralValue

packages/cli/src/batch-transform.ts:727–736  ·  view source on GitHub ↗
(node: any)

Source from the content-addressed store, hash-verified

725}
726
727function readStringLiteralValue(node: any): string | null {
728 if (!node) return null;
729 if (node.type === "StringLiteral" || node.type === "Literal") {
730 return typeof node.value === "string" ? node.value : null;
731 }
732 if (node.type === "TemplateLiteral" && (node.expressions?.length ?? 0) === 0) {
733 return node.quasis?.[0]?.value?.cooked ?? node.quasis?.[0]?.value?.raw ?? "";
734 }
735 return null;
736}
737
738function writeStringLiteralValue(node: any, value: string): boolean {
739 if (!node) return false;

Calls

no outgoing calls

Tested by

no test coverage detected