File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,20 @@ import { JsonData } from '@json-edit-react'
3
3
export const truncate = ( string : string , length = 200 ) =>
4
4
string . length < length ? string : `${ string . slice ( 0 , length - 2 ) . trim ( ) } ...`
5
5
6
- export const getLineHeight = ( data : JsonData ) => JSON . stringify ( data , null , 2 ) . split ( '\n' ) . length
6
+ export const getLineHeight = ( data : JsonData ) => jsonStringify ( data ) . split ( '\n' ) . length
7
+
8
+ // Special JSON.stringify with custom replacer functions for special types
9
+ const jsonStringify = ( data : JsonData ) =>
10
+ JSON . stringify (
11
+ data ,
12
+ ( _ , value ) => {
13
+ if ( typeof value === 'bigint' ) {
14
+ return value . toString ( )
15
+ }
16
+ if ( typeof value === 'symbol' ) {
17
+ return value . toString ( )
18
+ }
19
+ return value
20
+ } ,
21
+ 2
22
+ )
You can’t perform that action at this time.
0 commit comments