Showing with 47 additions and 8 deletions.
  1. +15 −0 CHANGELOG.md
  2. +5 −5 lib/util.js
  3. +1 −1 package-lock.json
  4. +1 −1 package.json
  5. +1 −1 package.json5
  6. +24 −0 test/parse.js
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
### v2.1.3 [[code][c2.1.3], [diff][d2.1.3]]

[c2.1.3]: https://github.com/json5/json5/tree/v2.1.3
[d2.1.3]: https://github.com/json5/json5/compare/v2.1.2...v2.1.3

- Fix: An out of memory bug when parsing numbers has been fixed. ([#228],
[#229])

### v2.1.2 [[code][c2.1.2], [diff][d2.1.2]]

[c2.1.2]: https://github.com/json5/json5/tree/v2.1.2
[d2.1.2]: https://github.com/json5/json5/compare/v2.1.1...v2.1.2

- Fix: Bump `minimist` to `v1.2.5`. ([#222])

### v2.1.1 [[code][c2.1.1], [diff][d2.1.1]]

[c2.1.1]: https://github.com/json5/json5/tree/v2.1.1
Expand Down
10 changes: 5 additions & 5 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ const unicode = require('../lib/unicode')

module.exports = {
isSpaceSeparator (c) {
return unicode.Space_Separator.test(c)
return typeof c === 'string' && unicode.Space_Separator.test(c)
},

isIdStartChar (c) {
return (
return typeof c === 'string' && (
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c === '$') || (c === '_') ||
Expand All @@ -15,7 +15,7 @@ module.exports = {
},

isIdContinueChar (c) {
return (
return typeof c === 'string' && (
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') ||
Expand All @@ -26,10 +26,10 @@ module.exports = {
},

isDigit (c) {
return /[0-9]/.test(c)
return typeof c === 'string' && /[0-9]/.test(c)
},

isHexDigit (c) {
return /[0-9A-Fa-f]/.test(c)
return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
},
}
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "json5",
"version": "2.1.2",
"version": "2.1.3",
"description": "JSON for humans.",
"main": "lib/index.js",
"module": "dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion package.json5
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This is a generated file. Do not edit.
{
name: 'json5',
version: '2.1.2',
version: '2.1.3',
description: 'JSON for humans.',
main: 'lib/index.js',
module: 'dist/index.mjs',
Expand Down
24 changes: 24 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,30 @@ t.test('parse(text)', t => {
'parses signed NaN'
)

t.strictSame(
JSON5.parse('1'),
1,
'parses 1'
)

t.strictSame(
JSON5.parse('+1.23e100'),
1.23e100,
'parses +1.23e100'
)

t.strictSame(
JSON5.parse('0x1'),
0x1,
'parses bare hexadecimal number'
)

t.strictSame(
JSON5.parse('-0x0123456789abcdefABCDEF'),
-0x0123456789abcdefABCDEF,
'parses bare long hexadecimal number'
)

t.end()
})

Expand Down