| 54 | |
| 55 | function extractRows(result: unknown): Array<Record<string, unknown>> { |
| 56 | const fromRowsObject = ( |
| 57 | rows: SQLiteResultWithRows[`rows`], |
| 58 | ): Array<Record<string, unknown>> | null => { |
| 59 | if (!rows) return null |
| 60 | if (Array.isArray(rows._array)) { |
| 61 | return rows._array |
| 62 | } |
| 63 | if (typeof rows.length === `number` && typeof rows.item === `function`) { |
| 64 | const item = rows.item as (index: number) => unknown |
| 65 | const extracted: Array<Record<string, unknown>> = [] |
| 66 | for (let i = 0; i < rows.length; i++) { |
| 67 | const row = item(i) |
| 68 | if (row && typeof row === `object`) { |
| 69 | extracted.push(row as Record<string, unknown>) |
| 70 | } |
| 71 | } |
| 72 | return extracted |
| 73 | } |
| 74 | return null |
| 75 | } |
| 76 | |
| 77 | if (Array.isArray(result)) { |
| 78 | if (result.length === 0) return [] |