MCPcopy Create free account
hub / github.com/composify-js/composify / stringify

Function stringify

packages/react/src/renderer/Parser/Parser.ts:154–173  ·  view source on GitHub ↗
(node: Node | string)

Source from the content-addressed store, hash-verified

152};
153
154export const stringify = (node: Node | string): string => {
155 if (typeof node === 'string') {
156 return node;
157 }
158
159 const attributes = stringifyAttributes(node.props);
160 const children = node.children.map((child) => stringify(child)).join('');
161
162 if (node.type === 'Fragment') {
163 return `<>${children}</>`;
164 }
165
166 const attrs = attributes ? ` ${attributes}` : '';
167
168 if (children.length > 0) {
169 return `<${node.type}${attrs}>${children}</${node.type}>`;
170 }
171
172 return `<${node.type}${attrs} />`;
173};
174
175const stringifyAttributes = (props: Record<string, unknown>): string => {
176 return Object.entries(props)

Callers 2

Parser.spec.tsFile · 0.90
stringifyValueFunction · 0.85

Calls 1

stringifyAttributesFunction · 0.85

Tested by

no test coverage detected