Skip to content

Commit

Permalink
Chore: Big int Support added
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-gupta-ij committed Dec 10, 2023
1 parent f88067f commit e687524
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.1",
"@types/jest": "^28.0.0",
"@types/json-bigint": "^1.0.4",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.31.0",
"codecov": "^3.8.2",
Expand Down Expand Up @@ -109,5 +110,8 @@
"tsc:check": "tsc --noEmit",
"ci:version": "pnpm changeset version && pnpm install --no-frozen-lockfile && git add .",
"ci:release": "pnpm changeset publish"
},
"dependencies": {
"json-bigint": "^1.0.0"
}
}
26 changes: 26 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
_TypedFetch,
TypedFetch,
} from './types.js'
import JSONbig from 'json-bigint'

const sendBody = (method: Method) =>
method === 'post' ||
Expand Down Expand Up @@ -152,11 +153,12 @@ async function getResponseData(response: Response) {
return undefined
}
if (contentType && contentType.indexOf('application/json') !== -1) {
return await response.json()
const text = await response.text()
return JSONbig.parse(text)
}
const text = await response.text()
try {
return JSON.parse(text)
return JSONbig.parse(text)
} catch (e) {
return text
}
Expand Down

0 comments on commit e687524

Please sign in to comment.