Skip to content

Commit

Permalink
isInteger return false for Infinity and NaN
Browse files Browse the repository at this point in the history
Signed-off-by: francesco <[email protected]>
  • Loading branch information
cesco69 authored Mar 14, 2024
1 parent 7caca28 commit 3bea520
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ module.exports = class Serializer {

asInteger (i) {
if (typeof i === 'number') {
if (i === Infinity || i === -Infinity || Number.isNaN(i)) {
throw new Error(`The value "${i}" cannot be converted to an integer.`)
}
if (Number.isInteger(i)) {
return '' + i
}
if (i === Infinity || i === -Infinity || Number.isNaN(i)) {
throw new Error(`The value "${i}" cannot be converted to an integer.`)
}
return this.parseInteger(i)
} else if (i === null) {
return '0'
Expand Down

0 comments on commit 3bea520

Please sign in to comment.