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

Function formatString

packages/utils/src/artifact.ts:107–113  ·  view source on GitHub ↗
(value: string, format: 'json' | 'ts')

Source from the content-addressed store, hash-verified

105}
106
107function formatString(value: string, format: 'json' | 'ts'): string {
108 // JSON strings use standard double-quoted escaping
109 if (format === 'json') return JSON.stringify(value);
110
111 // TS strings use single quotes instead of double quotes around string values, to match regular TS style
112 return `'${JSON.stringify(value).replace(/'/g, "\\'").replace(/\\"/g, '"').slice(1, -1)}'`;
113}
114
115function formatArray(
116 array: readonly any[],

Callers 1

stringifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected