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 5.3.0 to 6.0.0

3

index.d.ts

@@ -53,7 +53,4 @@ import {JsonValue} from 'type-fest';

sync<T = JsonValue>(filePath: string, options?: loadJsonFile.Options): T;
// TODO: Remove this for the next major release
default: typeof loadJsonFile;
};
export = loadJsonFile;

8

index.js
'use strict';
const path = require('path');
const {promisify} = require('util');
const fs = require('graceful-fs');
const stripBom = require('strip-bom');
const parseJson = require('parse-json');
const pify = require('pify');

@@ -18,7 +18,3 @@ const parse = (data, filePath, options = {}) => {

const loadJsonFile = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options));
module.exports = loadJsonFile;
// TODO: Remove this for the next major release
module.exports.default = loadJsonFile;
module.exports = async (filePath, options) => parse(await promisify(fs.readFile)(filePath, 'utf8'), filePath, options);
module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options);
{
"name": "load-json-file",
"version": "5.3.0",
"version": "6.0.0",
"description": "Read and parse a JSON file",

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

"engines": {
"node": ">=6"
"node": ">=8"
},

@@ -35,5 +35,4 @@ "scripts": {

"parse-json": "^4.0.0",
"pify": "^4.0.1",
"strip-bom": "^3.0.0",
"type-fest": "^0.3.0"
"type-fest": "^0.4.1"
},

@@ -40,0 +39,0 @@ "devDependencies": {

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

loadJsonFile('foo.json').then(json => {
console.log(json);
(async () => {
console.log(await loadJsonFile('foo.json'));
//=> {foo: true}
});
})();
```

@@ -32,3 +32,3 @@

Returns a promise for the parsed JSON.
Returns a `Promise<unknown>` with the parsed JSON.

@@ -41,3 +41,3 @@ ### loadJsonFile.sync(filepath, [options])

Type: `Object`
Type: `object`

@@ -44,0 +44,0 @@ ##### beforeParse

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