Socket
Socket
Sign inDemoInstall

load-json-file

Package Overview
Dependencies
7
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 5.0.0

14

index.js

@@ -8,5 +8,13 @@ 'use strict';

const parse = (data, fp) => parseJson(stripBom(data), path.relative('.', fp));
const parse = (data, filePath, options = {}) => {
data = stripBom(data);
module.exports = fp => pify(fs.readFile)(fp, 'utf8').then(data => parse(data, fp));
module.exports.sync = fp => parse(fs.readFileSync(fp, 'utf8'), fp);
if (typeof options.beforeParse === 'function') {
data = options.beforeParse(data);
}
return parseJson(data, options.reviver, path.relative(process.cwd(), filePath));
};
module.exports = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options));
module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options);
{
"name": "load-json-file",
"version": "4.0.0",
"description": "Read and parse a JSON file",
"license": "MIT",
"repository": "sindresorhus/load-json-file",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"read",
"json",
"parse",
"file",
"fs",
"graceful",
"load"
],
"dependencies": {
"graceful-fs": "^4.1.2",
"parse-json": "^4.0.0",
"pify": "^3.0.0",
"strip-bom": "^3.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "load-json-file",
"version": "5.0.0",
"description": "Read and parse a JSON file",
"license": "MIT",
"repository": "sindresorhus/load-json-file",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"read",
"json",
"parse",
"file",
"fs",
"graceful",
"load"
],
"dependencies": {
"graceful-fs": "^4.1.2",
"parse-json": "^4.0.0",
"pify": "^3.0.0",
"strip-bom": "^3.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
}

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

```
$ npm install --save load-json-file
$ npm install load-json-file
```

@@ -30,11 +30,27 @@

### loadJsonFile(filepath)
### loadJsonFile(filePath, [options])
Returns a promise for the parsed JSON.
### loadJsonFile.sync(filepath)
### loadJsonFile.sync(filepath, [options])
Returns the parsed JSON.
#### options
Type: `Object`
##### beforeParse
Type: `Function`
Applies a function to the JSON string before parsing.
##### reviver
Type: `Function`
Prescribes how the value originally produced by parsing is transformed, before being returned. See the [`JSON.parse` docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more.
## Related

@@ -41,0 +57,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc