MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / toYamlString

Function toYamlString

yaml-flow-editor/src/components/NodeConfigPanel.tsx:7–31  ·  view source on GitHub ↗
(obj: unknown)

Source from the content-addressed store, hash-verified

5
6// Helper to convert object to YAML string (for display)
7const toYamlString = (obj: unknown): string => {
8 if (obj === null || obj === undefined) {
9 return '';
10 }
11 if (typeof obj === 'object' && Object.keys(obj).length === 0) {
12 return '';
13 }
14 try {
15 // Convert null/undefined values to empty strings to preserve keys
16 const normalized = Object.fromEntries(
17 Object.entries(obj as Record<string, unknown>).map(([key, value]) => [
18 key,
19 value === null || value === undefined ? '' : value
20 ])
21 );
22 return yaml.dump(normalized, {
23 indent: 2,
24 lineWidth: -1,
25 skipInvalid: false,
26 forceQuotes: true, // Force quotes to preserve empty strings
27 }).trim();
28 } catch {
29 return '';
30 }
31};
32
33// Helper to parse YAML string to object
34const parseYamlParams = (str: string): Record<string, unknown> | null => {

Callers 3

YamlParamsEditorFunction · 0.70
renderGatherCallsFunction · 0.70
renderParallelParamsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected