MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / stringifyTaskListGroupValue

Function stringifyTaskListGroupValue

src/bases/taskListGrouping.ts:72–115  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

70}
71
72export function stringifyTaskListGroupValue(value: unknown): string {
73 if (value === null || value === undefined) {
74 return "None";
75 }
76
77 if (typeof value === "object" && value !== null && typeof value.toString === "function") {
78 const basesValue = value as BasesDisplayValue;
79 if (
80 basesValue.constructor?.name === "NullValue" ||
81 (basesValue.isTruthy && !basesValue.isTruthy())
82 ) {
83 return "None";
84 }
85
86 if (basesValue.constructor?.name === "ListValue" || Array.isArray(basesValue.value)) {
87 const arr = basesValue.value || [];
88 return arr.length > 0
89 ? arr.map((item) => stringifyTaskListGroupValue(item)).join(", ")
90 : "None";
91 }
92
93 return basesValue.toString() || "None";
94 }
95
96 if (typeof value === "string") {
97 return value || "None";
98 }
99
100 if (typeof value === "number") {
101 return String(value);
102 }
103
104 if (typeof value === "boolean") {
105 return value ? "True" : "False";
106 }
107
108 if (Array.isArray(value)) {
109 return value.length > 0
110 ? value.map((item) => stringifyTaskListGroupValue(item)).join(", ")
111 : "None";
112 }
113
114 return stringifyUnknown(value) || "None";
115}
116
117export function groupTasksByTaskListSubProperty(
118 tasks: readonly TaskInfo[],

Callers 2

Calls 2

stringifyUnknownFunction · 0.90
toStringMethod · 0.65

Tested by

no test coverage detected