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

Function getSourceBetween

packages/cli/src/transform.ts:780–787  ·  view source on GitHub ↗
(prevNode: any, nextNode: any, source?: string, lineStarts?: number[])

Source from the content-addressed store, hash-verified

778}
779
780function getSourceBetween(prevNode: any, nextNode: any, source?: string, lineStarts?: number[]): string {
781 if (!source) return "";
782 const starts = lineStarts ?? getLineStarts(source);
783 const prevEnd = getNodeIndex(prevNode, "end", starts);
784 const nextStart = getNodeIndex(nextNode, "start", starts);
785 if (prevEnd == null || nextStart == null || nextStart < prevEnd) return "";
786 return source.slice(prevEnd, nextStart);
787}
788
789function getRenderedChildText(child: any, source?: string, lineStarts?: number[]): string {
790 if (child.type === "JSXText") return collapseRenderedWhitespace(child.value);

Callers 3

getRenderedElementTextFunction · 0.85

Calls 2

getLineStartsFunction · 0.85
getNodeIndexFunction · 0.85

Tested by

no test coverage detected