@@ -2,6 +2,7 @@ import { asyncBufferFromUrl, parquetMetadataAsync } from 'hyparquet'
22import { useEffect , useState } from 'react'
33import type { FileSource } from '../lib/sources/types.js'
44import { parquetDataFrame } from '../lib/tableProvider.js'
5+ import { stringify } from '../lib/utils.js'
56import Breadcrumb , { BreadcrumbConfig } from './Breadcrumb.js'
67import Layout from './Layout.js'
78
@@ -75,30 +76,3 @@ export default function CellView({ source, row, col, config }: CellProps) {
7576 </ Layout >
7677 )
7778}
78-
79- /**
80- * Robust stringification of any value, including json and bigints.
81- */
82- function stringify ( value : unknown ) : string {
83- if ( typeof value === 'string' ) return value
84- if ( typeof value === 'number' ) return value . toLocaleString ( 'en-US' )
85- if ( Array . isArray ( value ) ) {
86- return `[\n${ value . map ( ( v ) => indent ( stringify ( v ) , 2 ) ) . join ( ',\n' ) } \n]`
87- }
88- if ( value === null || value === undefined ) return JSON . stringify ( value )
89- if ( value instanceof Date ) return value . toISOString ( )
90- if ( typeof value === 'object' ) {
91- return `{${ Object . entries ( value )
92- . filter ( ( d ) => d [ 1 ] !== undefined )
93- . map ( ( [ k , v ] ) => `${ k } : ${ stringify ( v ) } ` )
94- . join ( ', ' ) } }`
95- }
96- return '{}'
97- }
98-
99- function indent ( text : string | undefined , spaces : number ) {
100- return text
101- ?. split ( '\n' )
102- . map ( ( line ) => ' ' . repeat ( spaces ) + line )
103- . join ( '\n' )
104- }
0 commit comments