MCPcopy Create free account
hub / github.com/TanStack/ai / itemToString

Function itemToString

examples/ts-react-native-chat/src/App.tsx:128–150  ·  view source on GitHub ↗
(item: unknown)

Source from the content-addressed store, hash-verified

126}
127
128function itemToString(item: unknown): string | undefined {
129 if (!isRecord(item)) return valueToString(item)
130
131 const amount = valueToString(item.amount)
132 const name = valueToString(item.name)
133 const title = valueToString(item.title)
134 const text = valueToString(item.text)
135 const minutes = valueToString(item.minutes)
136 const pantry = item.pantry === true ? 'pantry' : undefined
137
138 if (amount || name) {
139 return [amount, name, pantry ? `(${pantry})` : undefined]
140 .filter(Boolean)
141 .join(' ')
142 }
143
144 if (title || text || minutes) {
145 const body = [title, text].filter(Boolean).join(': ')
146 return minutes ? `${body} (${minutes} min)` : body
147 }
148
149 return valueToString(item)
150}
151
152function valueToList(value: unknown): Array<string> {
153 if (Array.isArray(value)) {

Callers 1

valueToListFunction · 0.85

Calls 2

valueToStringFunction · 0.85
isRecordFunction · 0.70

Tested by

no test coverage detected