Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fastify/fast-json-stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Feb 23, 2023
2 parents 3abb72d + a9adf56 commit 8160985
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = class Serializer {
if (i === Infinity || i === -Infinity) {
throw new Error(`The value "${i}" cannot be converted to an integer.`)
}
if ((i | 0) === i) {
if (Number.isInteger(i)) {
return '' + i
}
if (Number.isNaN(i)) {
Expand Down
1 change: 1 addition & 0 deletions test/integer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test('render a float as an integer', (t) => {
{ input: 42, output: '42' },
{ input: 1.99999, output: '1' },
{ input: -45.05, output: '-45' },
{ input: 3333333333333333, output: '3333333333333333' },
{ input: Math.PI, output: '3', rounding: 'trunc' },
{ input: 5.0, output: '5', rounding: 'trunc' },
{ input: null, output: '0', rounding: 'trunc' },
Expand Down

0 comments on commit 8160985

Please sign in to comment.