MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / normalizeRows

Function normalizeRows

packages/tools/src/definitions/render-chart.ts:79–86  ·  view source on GitHub ↗
(raw: unknown, maxRows: number)

Source from the content-addressed store, hash-verified

77}
78
79function normalizeRows(raw: unknown, maxRows: number): { rows: Record<string, unknown>[]; truncated: boolean } {
80 if (!Array.isArray(raw)) throw new Error('rows must be an array')
81 const items = raw.filter(
82 (item): item is Record<string, unknown> => typeof item === 'object' && item !== null && !Array.isArray(item)
83 )
84 const truncated = items.length > maxRows
85 return { rows: truncated ? items.slice(0, maxRows) : items, truncated }
86}
87
88function normalizeMaxRows(raw: unknown): number {
89 const value = typeof raw === 'number' ? raw : DEFAULT_MAX_ROWS

Callers 1

handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected