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

Function mergeAdjacentTextLikeChildren

packages/cli/src/transform.ts:935–949  ·  view source on GitHub ↗
(children: any[])

Source from the content-addressed store, hash-verified

933}
934
935function mergeAdjacentTextLikeChildren(children: any[]): any[] {
936 const merged: any[] = [];
937 for (const child of children) {
938 if (isEmptyTextLikeChild(child)) continue;
939
940 const previous = merged[merged.length - 1];
941 if (previous?.type === "JSXText" && child.type === "JSXText") {
942 setTextLikeValue(previous, `${getTextLikeValue(previous) ?? ""}${getTextLikeValue(child) ?? ""}`);
943 continue;
944 }
945
946 merged.push(child);
947 }
948 return merged;
949}
950
951function trimTextLikeEdges(value: string): { core: string; hasLeadingWhitespace: boolean; hasTrailingWhitespace: boolean } {
952 return {

Callers 1

Calls 3

isEmptyTextLikeChildFunction · 0.85
setTextLikeValueFunction · 0.85
getTextLikeValueFunction · 0.85

Tested by

no test coverage detected