Skip to content

Commit 71933e2

Browse files
authored
feat: support bigint type (#35)
1 parent 5cf618d commit 71933e2

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

examples/basic/pages/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ const example = {
7171
string_number: '1234',
7272
timer: 0,
7373
avatar,
74-
date: new Date('Tue Sep 13 2022 14:07:44 GMT-0500 (Central Daylight Time)')
74+
date: new Date('Tue Sep 13 2022 14:07:44 GMT-0500 (Central Daylight Time)'),
75+
bigint: 123456789087654321n
7576
}
7677

7778
const KeyRenderer: JsonViewerKeyRenderer = ({ path }) => {

src/components/DataTypes/createEasyType.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function createEasyType<Value> (
4646
store => store.colorspace[config.colorKey])
4747
return (
4848
<InputBase
49-
value={value}
49+
value={`${value}`}
5050
onChange={
5151
useCallback<React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>>(
5252
(event) => {

src/stores/typeRegistry.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,17 @@ registerType<number>(
242242
)
243243
}
244244
)
245+
246+
registerType<bigint>(
247+
{
248+
is: (value): value is bigint => typeof value === 'bigint',
249+
...createEasyType(
250+
'bigint',
251+
({ value }) => <>{`${value}n`}</>,
252+
{
253+
colorKey: 'base0F',
254+
fromString: value => BigInt(value.replace(/\D/g, ''))
255+
}
256+
)
257+
}
258+
)

0 commit comments

Comments
 (0)