Socket
Socket
Sign inDemoInstall

parse-json

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-json - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

16

index.js

@@ -9,3 +9,8 @@ 'use strict';

module.exports = function (x, reviver) {
module.exports = function (x, reviver, filename) {
if (typeof reviver === 'string') {
filename = reviver;
reviver = null;
}
try {

@@ -23,5 +28,10 @@ try {

} catch (err) {
JSONError.call(err);
throw err;
var jsonErr = new JSONError(err);
if (filename) {
jsonErr.fileName = filename;
}
throw jsonErr;
}
};

4

package.json
{
"name": "parse-json",
"version": "2.1.0",
"version": "2.2.0",
"description": "Parse JSON with more helpful errors",

@@ -35,3 +35,3 @@ "license": "MIT",

"dependencies": {
"error-ex": "^1.1.0"
"error-ex": "^1.2.0"
},

@@ -38,0 +38,0 @@ "devDependencies": {

@@ -19,2 +19,3 @@ # parse-json [![Build Status](https://travis-ci.org/sindresorhus/parse-json.svg?branch=master)](https://travis-ci.org/sindresorhus/parse-json)

JSON.parse(json);

@@ -28,2 +29,3 @@ /*

parseJson(json);

@@ -36,2 +38,12 @@ /*

parseJson(json, 'foo.json');
/*
JSONError: Trailing comma in object at 3:1 in foo.json
}
^
*/
// you can also add the filename at a later point
try {

@@ -43,3 +55,2 @@ parseJson(json);

}
/*

@@ -54,3 +65,3 @@ JSONError: Trailing comma in object at 3:1 in foo.json

### parseJson(input, [reviver])
### parseJson(input, [reviver], [filename])

@@ -68,5 +79,11 @@ #### input

#### filename
Type: `string`
Filename displayed in the error message.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
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