Skip to content

Commit 3bea520

Browse files
authored
isInteger return false for Infinity and NaN
Signed-off-by: francesco <[email protected]>
1 parent 7caca28 commit 3bea520

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/serializer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ module.exports = class Serializer {
2525

2626
asInteger (i) {
2727
if (typeof i === 'number') {
28-
if (i === Infinity || i === -Infinity || Number.isNaN(i)) {
29-
throw new Error(`The value "${i}" cannot be converted to an integer.`)
30-
}
3128
if (Number.isInteger(i)) {
3229
return '' + i
3330
}
31+
if (i === Infinity || i === -Infinity || Number.isNaN(i)) {
32+
throw new Error(`The value "${i}" cannot be converted to an integer.`)
33+
}
3434
return this.parseInteger(i)
3535
} else if (i === null) {
3636
return '0'

0 commit comments

Comments
 (0)