Socket
Socket
Sign inDemoInstall

parse-json

Package Overview
Dependencies
Maintainers
2
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 1.0.1 to 2.0.0

license

38

index.js
'use strict';
var fallback = require('./vendor/parse');
var promise = require('cb2promise');
var Errorifier = require('errorifier');
var ensureAsync = require('ensure-async');
module.exports = function (x, reviver) {
try {
return JSON.parse(x, reviver);
} catch (err) {
fallback.parse(x, {
mode: 'json',
reviver: reviver
});
var parseAsync = ensureAsync(function(data, cb) {
var content;
var error;
try {
content = JSON.parse(data);
} catch (err) {
content = {};
error = new Errorifier({
code: 'ENOVALIDJSON',
message: err.message
});
} finally {
return cb(error, content);
}
});
function parseJSON(data, cb) {
if (arguments.length === 1) return promise(parseAsync, data);
return parseAsync(data, cb);
}
module.exports = parseJSON;
throw err;
}
};
{
"name": "parse-json",
"description": "The missing JSON.parse async interface.",
"homepage": "https://github.com/Kikobeats/parse-json",
"version": "1.0.1",
"main": "./index.js",
"version": "2.0.0",
"description": "Parse JSON with more helpful errors",
"license": "MIT",
"repository": "sindresorhus/parse-json",
"author": {
"name": "Kiko Beats",
"email": "josefrancisco.verdu@gmail.com",
"url": "https://github.com/Kikobeats"
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"repository": "Kikobeats/parse-json",
"bugs": {
"url": "https://github.com/Kikobeats/parse-json/issues"
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && node test.js"
},
"files": [
"index.js",
"vendor"
],
"keywords": [
"JSON",
"parse",
"async",
"promise"
"json",
"graceful",
"error",
"message",
"humanize",
"friendly",
"helpful",
"string",
"str"
],
"dependencies": {
"cb2promise": "~1.0.0",
"ensure-async": "~1.0.0",
"errorifier": "~0.1.3"
},
"devDependencies": {
"browserify": "*",
"coffee-script": "*",
"coffeeify": "*",
"gulp": "*",
"gulp-header": "*",
"gulp-uglify": "*",
"gulp-util": "*",
"mocha": "*",
"should": "*",
"vinyl-buffer": "*",
"vinyl-source-stream": "*"
"ava": "0.0.4",
"xo": "*"
},
"engines": {
"node": ">= 0.10.0",
"npm": ">= 1.4.0"
},
"scripts": {
"test": "sh test/test.sh"
},
"license": "MIT"
"xo": {
"ignores": [
"vendor/**"
]
}
}
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