Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

read-json-sync

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-json-sync - npm Package Compare versions

Comparing version 2.0.0-1 to 2.0.0-2

4

index.js

@@ -14,3 +14,5 @@ 'use strict';

return JSON.parse(readFileSync(...args).toString().replace(/^\ufeff/g, ''));
const str = readFileSync(...args).toString();
return JSON.parse(str.charCodeAt(0) === 65279 ? /* 0xFEFF */ str.slice(1) : str);
};
{
"name": "read-json-sync",
"version": "2.0.0-1",
"version": "2.0.0-2",
"description": "Read and parse a JSON file synchronously",

@@ -8,3 +8,4 @@ "repository": "shinnn/read-json-sync",

"scripts": {
"pretest": "eslint --fix --format=codeframe index.js test/test.js",
"bench": "node benchmark/runner string-slice && node benchmark/runner string-replace && node benchmark/runner buffer-string-slice",
"pretest": "eslint --fix --format=codeframe benchmark index.js test",
"test": "istanbul cover test/test.js"

@@ -32,3 +33,4 @@ },

"@shinnn/eslint-config-node": "^4.0.2",
"eslint": "^4.6.1",
"chalk": "^2.3.0",
"eslint": "^4.10.0",
"istanbul": "^0.4.5",

@@ -35,0 +37,0 @@ "tape": "^4.8.0"

@@ -15,7 +15,7 @@ # read-json-sync

Node.js built-in [`require`](https://nodejs.org/api/globals.html#globals_require) can do almost the same thing, but this module doesn't [cache](https://nodejs.org/api/modules.html#modules_caching) results.
Node.js built-in [`require`](https://nodejs.org/api/globals.html#globals_require) and [`import`](https://nodejs.org/api/esm.html#esm_interop_with_existing_modules) can do almost the same thing, but this module doesn't [cache](https://nodejs.org/api/modules.html#modules_caching) results.
## Installation
[Use npm](https://docs.npmjs.com/cli/install).
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).

@@ -35,7 +35,17 @@ ```

*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)
*options*: `Object` `string` ([`fs.readFile`](https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback) options or an encoding of the file)
Return: `any` (parsed [JSON](https://tools.ietf.org/html/rfc7159) data)
It automatically ignores the leading [byte order mark](https://www.unicode.org/faq/utf_bom.html).
```javascript
// with-bom.json: '\uFEFF{"a": 1}'
JSON.parse('\uFEFF{"a": 1}'); // throws a SyntaxError
readJsonSync('with-bom.json'); //=> {a: 1}
```
## License
[Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/deed)
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