function safeStringify(value: unknown): string { try { const serialized = JSON.stringify(value); if (serialized !== undefined) { return serialized;
}
} catch { // Fall back to string coercion when value is not JSON-serializable.
} return String(value);
}
function toAllowedValueLabel(value: unknown): string { if (typeof value === "string") { return JSON.stringify(truncateHintText(value, MAX_ALLOWED_VALUE_CHARS));
} return truncateHintText(safeStringify(value), MAX_ALLOWED_VALUE_CHARS);
}
function toAllowedValueValue(value: unknown): string { if (typeof value === "string") { return value;
} return safeStringify(value);
}
function toAllowedValueDedupKey(value: unknown): string { if (value === null) { return"null:null";
} const kind = typeof value; if (kind === "string") { return `string:${value as string}`;
} return `${kind}:${safeStringify(value)}`;
}
export function summarizeAllowedValues(
values: ReadonlyArray<unknown>,
): AllowedValuesSummary | null { if (values.length === 0) { returnnull;
}
const deduped: Array<{ value: string; label: string }> = []; const seenValues = new Set<string>(); for (const item of values) { const dedupeKey = toAllowedValueDedupKey(item); if (seenValues.has(dedupeKey)) { continue;
}
seenValues.add(dedupeKey);
deduped.push({
value: toAllowedValueValue(item),
label: toAllowedValueLabel(item),
});
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.