Skip to content

Commit 14173d4

Browse files
committed
upgrade to hightable 0.13.1 and use its exported stringify function
1 parent 580803a commit 14173d4

File tree

5 files changed

+4
-33
lines changed

5 files changed

+4
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"watch:url": "NODE_ENV=development nodemon bin/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet"
4848
},
4949
"dependencies": {
50-
"hightable": "0.13.0",
50+
"hightable": "0.13.1",
5151
"hyparquet": "1.9.1",
5252
"hyparquet-compressors": "1.0.0",
5353
"icebird": "0.1.8",

src/components/Cell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { stringify } from 'hightable'
12
import { asyncBufferFromUrl, parquetMetadataAsync } from 'hyparquet'
23
import { useEffect, useState } from 'react'
34
import type { FileSource } from '../lib/sources/types.js'
45
import { parquetDataFrame } from '../lib/tableProvider.js'
5-
import { stringify } from '../lib/utils.js'
66
import Breadcrumb, { BreadcrumbConfig } from './Breadcrumb.js'
77
import Layout from './Layout.js'
88

src/components/viewers/CellPanel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { DataFrame } from 'hightable'
1+
import { DataFrame, stringify } from 'hightable'
22
import { useEffect, useState } from 'react'
3-
import { stringify } from '../../lib/utils.js'
43
import ContentHeader from './ContentHeader.js'
54

65
interface ViewerProps {

src/components/viewers/ParquetView.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import HighTable, { DataFrame, rowCache } from 'hightable'
1+
import HighTable, { DataFrame, rowCache, stringify } from 'hightable'
22
import { asyncBufferFromUrl, parquetMetadataAsync } from 'hyparquet'
33
import React, { useCallback, useEffect, useState } from 'react'
44
import { RoutesConfig, appendSearchParams } from '../../lib/routes.js'
55
import { FileSource } from '../../lib/sources/types.js'
66
import { parquetDataFrame } from '../../lib/tableProvider.js'
7-
import { stringify } from '../../lib/utils.js'
87
import styles from '../../styles/ParquetView.module.css'
98
import { Spinner } from '../Layout.js'
109
import CellPanel from './CellPanel.js'

src/lib/utils.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,30 +97,3 @@ export const contentTypes: Record<string, string> = {
9797
}
9898

9999
export const imageTypes = ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.tiff', '.webp']
100-
101-
/**
102-
* Robust stringification of any value, including json and bigints.
103-
*/
104-
export function stringify(value: unknown): string {
105-
if (typeof value === 'string') return value
106-
if (typeof value === 'number' || typeof value === 'bigint') return value.toLocaleString('en-US')
107-
if (Array.isArray(value)) {
108-
return `[\n${value.map((v) => indent(stringify(v), 2)).join(',\n')}\n]`
109-
}
110-
if (value === null || value === undefined) return JSON.stringify(value)
111-
if (value instanceof Date) return value.toISOString()
112-
if (typeof value === 'object') {
113-
return `{${Object.entries(value)
114-
.filter((d) => d[1] !== undefined)
115-
.map(([k, v]) => `${k}: ${stringify(v)}`)
116-
.join(', ')}}`
117-
}
118-
return '{}'
119-
}
120-
121-
function indent(text: string | undefined, spaces: number) {
122-
return text
123-
?.split('\n')
124-
.map((line) => ' '.repeat(spaces) + line)
125-
.join('\n')
126-
}

0 commit comments

Comments
 (0)