New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tiny-jsonc

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-jsonc - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

4

dist/index.js
/* HELPERS */
const stringOrCommentRe = /("(?:\\?.)*?")|(\/\/.*)|(\/\*[^]*?\*\/)/g;
const stringOrTrailingCommaRe = /("(?:\\?.)*?")|(,\s*)(?=]|})/g;
const stringOrCommentRe = /("(?:\\?[^])*?")|(\/\/.*)|(\/\*[^]*?\*\/)/g;
const stringOrTrailingCommaRe = /("(?:\\?[^])*?")|(,\s*)(?=]|})/g;
/* MAIN */

@@ -5,0 +5,0 @@ const JSONC = {

@@ -5,3 +5,3 @@ {

"description": "An absurdly small JSONC parser.",
"version": "1.0.0",
"version": "1.0.1",
"type": "module",

@@ -8,0 +8,0 @@ "main": "dist/index.js",

/* HELPERS */
const stringOrCommentRe = /("(?:\\?.)*?")|(\/\/.*)|(\/\*[^]*?\*\/)/g;
const stringOrTrailingCommaRe = /("(?:\\?.)*?")|(,\s*)(?=]|})/g;
const stringOrCommentRe = /("(?:\\?[^])*?")|(\/\/.*)|(\/\*[^]*?\*\/)/g;
const stringOrTrailingCommaRe = /("(?:\\?[^])*?")|(,\s*)(?=]|})/g;

@@ -7,0 +7,0 @@ /* MAIN */

@@ -9,502 +9,6 @@

prefix: 'invalid 123',
suffix: '123 invalid'
suffix: '123 invalid',
multiLineString: `{ "foo": "/*
*/" }`
},
ast: {
input: `
// Example // Yes
/* EXAMPLE */ /* YES */
{
"one": {},
"two" :{},
"three": {
"one": null,
"two" :true,
"three": false,
"four": "asd\\n\\u0022\\"",
"five": -123.123e10,
"six": [ 123, true, [],],
},
}
// Example // Yes
/* EXAMPLE */ /* YES */
`,
output: {
type: 'Root',
children: [
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'CommentLine',
source: '// Example // Yes'
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'CommentBlock',
source: '/* EXAMPLE */'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'CommentBlock',
source: '/* YES */'
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Object',
children: [
{
type: 'ObjectOpen',
source: '{'
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"one"'
},
{
type: 'Colon',
source: ':'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Object',
children: [
{
type: 'ObjectOpen',
source: '{'
},
{
type: 'ObjectClose',
source: '}'
}
]
},
{
type: 'Comma',
source: ','
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"two"'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Colon',
source: ':'
},
{
type: 'Object',
children: [
{
type: 'ObjectOpen',
source: '{'
},
{
type: 'ObjectClose',
source: '}'
}
]
},
{
type: 'Comma',
source: ','
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"three"'
},
{
type: 'Colon',
source: ':'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Object',
children: [
{
type: 'ObjectOpen',
source: '{'
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"one"'
},
{
type: 'Colon',
source: ':'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Null',
source: 'null'
},
{
type: 'Comma',
source: ','
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"two"'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Colon',
source: ':'
},
{
type: 'True',
source: 'true'
},
{
type: 'Comma',
source: ','
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"three"'
},
{
type: 'Colon',
source: ':'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'False',
source: 'false'
},
{
type: 'Comma',
source: ','
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"four"'
},
{
type: 'Colon',
source: ':'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"asd\\n\\u0022\\""'
},
{
type: 'Comma',
source: ','
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"five"'
},
{
type: 'Colon',
source: ':'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Number',
source: '-123.123e10'
},
{
type: 'Comma',
source: ','
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'String',
source: '"six"'
},
{
type: 'Colon',
source: ':'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Array',
children: [
{
type: 'ArrayOpen',
source: '['
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Number',
source: '123'
},
{
type: 'Comma',
source: ','
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'True',
source: 'true'
},
{
type: 'Comma',
source: ','
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'Array',
children: [
{
type: 'ArrayOpen',
source: '['
},
{
type: 'ArrayClose',
source: ']'
}
]
},
{
type: 'CommaTrailing',
source: ','
},
{
type: 'ArrayClose',
source: ']'
}
]
},
{
type: 'CommaTrailing',
source: ','
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'ObjectClose',
source: '}'
}
]
},
{
type: 'CommaTrailing',
source: ','
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'ObjectClose',
source: '}'
}
]
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'CommentLine',
source: '// Example // Yes'
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'CommentBlock',
source: '/* EXAMPLE */'
},
{
type: 'Whitespace',
source: ' '
},
{
type: 'CommentBlock',
source: '/* YES */'
},
{
type: 'Newline',
source: '\n'
},
{
type: 'Whitespace',
source: ' '
}
]
}
},
lookup: {
object: `
// Example // Yes
/* EXAMPLE */ /* YES */
{
"one": {},
"two" :{},
"three": {
"one": null,
"two" :true,
"three": false,
"four": "asd\\n\\u0022\\"",
"five": -123.123e10,
"six": [ 123, true, [],],
},
}
// Example // Yes
/* EXAMPLE */ /* YES */
`,
objectPartial: `{ "foo" }`,
array: `
// Example // Yes
/* EXAMPLE */ /* YES */
[
{ "foo": 123,
"bar": [123] }
]
// Example // Yes
/* EXAMPLE */ /* YES */
`
},
parse: {

@@ -541,14 +45,2 @@ input: `

}
},
strip: {
input: `
{ // This is an example // Example
"foo" : 123,
"// tricky": "/* tricky */",
/* TRAILING COMMAS BELOW */ /* EXAMPLE */
"bar": [1, 2 , 3,],
/* TRAILING COMMAS ABOVE */
}
`,
output: '{"foo":123,"// tricky":"/* tricky */","bar":[1,2,3]}'
}

@@ -555,0 +47,0 @@ };

@@ -39,2 +39,10 @@

it ( 'throws on multi-line strings', t => {
const {multiLineString} = Fixtures.errors;
t.throws ( () => JSONC.parse ( multiLineString ), { instanceOf: SyntaxError, message: 'Unexpected token \n in JSON at position 12' } );
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc