Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 3.0.0 to 4.0.0

27

index.js
'use strict';
const errorEx = require('error-ex');
const fallback = require('./vendor/parse');
const fallback = require('json-parse-better-errors');
function appendPosition(message) {
const posRe = / at (\d+:\d+) in/;
const numbers = posRe.exec(message);
return message.replace(posRe, ' in') + ':' + numbers[1];
}
const JSONError = errorEx('JSONError', {
fileName: errorEx.append('in %s'),
appendPosition: {
message: (shouldAppend, original) => {
if (shouldAppend) {
original[0] = appendPosition(original[0]);
}
return original;
}
}
fileName: errorEx.append('in %s')
});

@@ -33,6 +19,3 @@

} catch (err) {
fallback.parse(input, {
mode: 'json',
reviver
});
fallback(input, reviver);

@@ -42,7 +25,7 @@ throw err;

} catch (err) {
err.message = err.message.replace(/\n/g, '');
const jsonErr = new JSONError(err);
if (filename) {
jsonErr.fileName = filename;
jsonErr.appendPosition = true;
}

@@ -49,0 +32,0 @@

8

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

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

"scripts": {
"test": "xo && ava"
"test": "xo && nyc ava"
},

@@ -36,8 +36,10 @@ "files": [

"dependencies": {
"error-ex": "^1.3.1"
"error-ex": "^1.3.1",
"json-parse-better-errors": "^1.0.1"
},
"devDependencies": {
"ava": "*",
"nyc": "^11.2.1",
"xo": "*"
}
}
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