MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / normalizeRuntimeValue

Function normalizeRuntimeValue

src/api/TaskNotesAPI.ts:3170–3201  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

3168}
3169
3170function normalizeRuntimeValue(value: unknown): TaskNotesRuntimeValue {
3171 if (Array.isArray(value)) return value.map(normalizeRuntimeValue);
3172 if (isRecord(value)) {
3173 const fn = value["fn"];
3174 if (fn === "today") return { fn: "today" };
3175 if (fn === "now") return { fn: "now" };
3176 if (fn === "date" && typeof value["value"] === "string") {
3177 return { fn: "date", value: value["value"] };
3178 }
3179 if (
3180 fn === "dateAdd" &&
3181 Number.isFinite(value["amount"]) &&
3182 (value["unit"] === "day" || value["unit"] === "week" || value["unit"] === "month")
3183 ) {
3184 return {
3185 fn: "dateAdd",
3186 value: normalizeRuntimeValue(value["value"]),
3187 amount: Number(value["amount"]),
3188 unit: value["unit"],
3189 };
3190 }
3191 }
3192 if (
3193 typeof value === "string" ||
3194 typeof value === "number" ||
3195 typeof value === "boolean" ||
3196 value === null
3197 ) {
3198 return value;
3199 }
3200 return stringifyUnknownValue(value);
3201}
3202
3203function toFilterConditionValue(
3204 value: TaskNotesRuntimeValue | undefined

Callers 2

Calls 2

stringifyUnknownValueFunction · 0.85
isRecordFunction · 0.70

Tested by

no test coverage detected