MCPcopy
hub / github.com/ZToolsCenter/ZTools / stringify

Method stringify

src/main/core/logCollector.ts:210–219  ·  view source on GitHub ↗

* 安全序列化单个参数

(arg: any)

Source from the content-addressed store, hash-verified

208 * 安全序列化单个参数
209 */
210 private stringify(arg: any): string {
211 if (typeof arg === 'string') return arg
212 if (arg instanceof Error) return `${arg.name}: ${arg.message}`
213 try {
214 const str = JSON.stringify(arg)
215 return str && str.length > 500 ? str.substring(0, 500) + '...' : (str ?? String(arg))
216 } catch {
217 return String(arg)
218 }
219 }
220}
221
222export default new LogCollector()

Callers 15

serializeArgsMethod · 0.95
jsCodeTemplateFunction · 0.80
saveSearchPreferenceFunction · 0.80
pinCommandFunction · 0.80
updatePinnedOrderFunction · 0.80
handleMainPushSelectFunction · 0.80
writeClipboardFilesFunction · 0.80
applyFunction · 0.80
setFunction · 0.80
sendRawJsonMethod · 0.80
stringifyToolResultMethod · 0.80
updateProgressTextMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected