Skip to content

Commit

Permalink
copy json with bigint
Browse files Browse the repository at this point in the history
Summary:
Addresses support post
https://fb.workplace.com/groups/flippersupport/posts/1879751489172167

Reviewed By: LukeDefeo

Differential Revision: D60112240

fbshipit-source-id: 916a3d296a4d24e398bb42fc36a7153226d77eb6
  • Loading branch information
antonk52 authored and facebook-github-bot committed Jul 23, 2024
1 parent 86095c9 commit ebdc89f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ function defaultOnCopyRows<T extends object>(
.join('\n')}`;
}

function rowsToJson<T>(items: T[]) {
return JSON.stringify(items.length > 1 ? items : items[0], null, 2);
function rowsToJson(items: any[]) {
return JSON.stringify(
items.length > 1 ? items : items[0],
function (_key, value) {
if (typeof value === 'bigint') {
return `${value.toString()}n`;
}
return value;
},
2,
);
}
13 changes: 11 additions & 2 deletions desktop/flipper-plugin/src/ui/data-table/TableContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ function defaultOnCopyRows<T extends object>(
.join('\n')}`;
}

function rowsToJson<T>(items: T[]) {
return JSON.stringify(items.length > 1 ? items : items[0], null, 2);
function rowsToJson(items: any[]) {
return JSON.stringify(
items.length > 1 ? items : items[0],
function (_key, value) {
if (typeof value === 'bigint') {
return `${value.toString()}n`;
}
return value;
},
2,
);
}

0 comments on commit ebdc89f

Please sign in to comment.