MCPcopy Create free account
hub / github.com/xerrors/Yuxi / normalizeOptions

Function normalizeOptions

web/src/utils/questionUtils.js:30–45  ·  view source on GitHub ↗
(rawOptions)

Source from the content-addressed store, hash-verified

28 * 规范化选项列表
29 */
30export const normalizeOptions = (rawOptions) => {
31 if (!Array.isArray(rawOptions)) return []
32
33 return rawOptions
34 .map((item) => {
35 if (item && typeof item === 'object') {
36 const label = String(item.label || item.value || '').trim()
37 const value = String(item.value || item.label || '').trim()
38 return label && value ? { label, value } : null
39 }
40
41 const text = String(item || '').trim()
42 return text ? { label: text, value: text } : null
43 })
44 .filter(Boolean)
45}
46
47/**
48 * 规范化问题列表

Callers 1

normalizeQuestionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected