MCPcopy Create free account
hub / github.com/chhoumann/quickadd / formatMacroOutput

Function formatMacroOutput

src/engine/SingleMacroEngine.ts:48–64  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

46type UserScriptCallable = () => unknown;
47
48function formatMacroOutput(value: unknown): string {
49 if (value === null || value === undefined) return "";
50 if (typeof value === "string") return value;
51 if (typeof value === "number" || typeof value === "boolean") {
52 return String(value);
53 }
54 if (typeof value === "bigint" || typeof value === "symbol") {
55 return value.toString();
56 }
57 if (value instanceof Error) return value.message;
58
59 try {
60 return JSON.stringify(value);
61 } catch {
62 return Object.prototype.toString.call(value);
63 }
64}
65
66export class SingleMacroEngine {
67 private readonly choiceExecutor: IChoiceExecutor;

Callers 1

runAndGetOutputMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected