MCPcopy Create free account
hub / github.com/CashScript/cashscript / formatArtifact

Function formatArtifact

packages/utils/src/artifact.ts:67–75  ·  view source on GitHub ↗
(artifact: Artifact, format: 'json' | 'ts')

Source from the content-addressed store, hash-verified

65}
66
67export function formatArtifact(artifact: Artifact, format: 'json' | 'ts'): string {
68 if (format === 'ts') {
69 // We remove any undefined values to make the artifact serializable
70 const normalisedArtifact = JSON.parse(JSON.stringify(artifact));
71 return `export default ${stringify(normalisedArtifact, 'ts')} as const;\n`;
72 }
73
74 return stringify(artifact, 'json');
75}
76
77const indent = (level: number): string => ' '.repeat(level);
78

Callers 2

runFunction · 0.90
compileFunction · 0.90

Calls 1

stringifyFunction · 0.85

Tested by

no test coverage detected