read-json-sync
Advanced tools
Comparing version 2.0.0-0 to 2.0.0-1
12
index.js
@@ -5,4 +5,12 @@ 'use strict'; | ||
module.exports = function readJsonSync(filePath, options) { | ||
return JSON.parse(readFileSync(filePath, options).toString().replace(/^\ufeff/g, '')); | ||
module.exports = function readJsonSync(...args) { | ||
const argLen = args.length; | ||
if (argLen !== 1 && argLen !== 2) { | ||
throw new RangeError(`Expected 1 or 2 arguments (path[, options]), but got ${ | ||
argLen === 0 ? 'no' : argLen | ||
} arguments.`); | ||
} | ||
return JSON.parse(readFileSync(...args).toString().replace(/^\ufeff/g, '')); | ||
}; |
{ | ||
"name": "read-json-sync", | ||
"version": "2.0.0-0", | ||
"version": "2.0.0-1", | ||
"description": "Read and parse a JSON file synchronously", | ||
@@ -9,4 +9,3 @@ "repository": "shinnn/read-json-sync", | ||
"pretest": "eslint --fix --format=codeframe index.js test/test.js", | ||
"test": "node --throw-deprecation --track-heap-objects test/test.js | tap-spec", | ||
"coverage": "istanbul cover test/test.js" | ||
"test": "istanbul cover test/test.js" | ||
}, | ||
@@ -33,5 +32,4 @@ "license": "CC0-1.0", | ||
"@shinnn/eslint-config-node": "^4.0.2", | ||
"eslint": "^4.4.1", | ||
"eslint": "^4.6.1", | ||
"istanbul": "^0.4.5", | ||
"tap-spec": "^4.1.1", | ||
"tape": "^4.8.0" | ||
@@ -38,0 +36,0 @@ }, |
# read-json-sync | ||
[![NPM version](https://img.shields.io/npm/v/read-json-sync.svg)](https://www.npmjs.com/package/read-json-sync) | ||
[![npm version](https://img.shields.io/npm/v/read-json-sync.svg)](https://www.npmjs.com/package/read-json-sync) | ||
[![Build Status](https://travis-ci.org/shinnn/read-json-sync.svg?branch=master)](https://travis-ci.org/shinnn/read-json-sync) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/t7sjgpku9on12d32?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/read-json-sync) | ||
[![Coverage Status](https://img.shields.io/coveralls/shinnn/read-json-sync.svg)](https://david-dm.org/shinnn/read-json-sync) | ||
@@ -32,7 +31,7 @@ | ||
### readJsonSync(*filePath* [, *options*]) | ||
### readJsonSync(*path* [, *options*]) | ||
*filePath*: `String` (path to a JSON file) | ||
*options*: `Object` ([`fs.readFile`](https://nodejs.org/api/fs.html#fs_fs_readfile_filename_options_callback) options) | ||
Return: `Object` (parsed [JSON](https://tools.ietf.org/html/rfc7159) data) | ||
*path*: `string` [`Buffer`](https://nodejs.org/api/buffer.html#buffer_class_buffer) [`URL`](https://nodejs.org/api/url.html#url_class_url) (JSON filename) or `integer` (file descriptor) | ||
*options*: `Object` ([`fs.readFile`](https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback) options) | ||
Return: `any` (parsed [JSON](https://tools.ietf.org/html/rfc7159) data) | ||
@@ -39,0 +38,0 @@ ## License |
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
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2764
4
11
0
40