parse-json
Advanced tools
Comparing version 1.0.1 to 2.0.0
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/**" | ||
] | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
32687
0
2
731
0
1
6
1
- Removedcb2promise@~1.0.0
- Removedensure-async@~1.0.0
- Removederrorifier@~0.1.3
- Removedcb2promise@1.0.7(transitive)
- Removedcoffee-script@1.9.3(transitive)
- Removedensure-async@1.0.0(transitive)
- Removederrorifier@0.1.3(transitive)
- Removedlodash.restparam@3.6.1(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedsliced@1.0.1(transitive)