read-file-json
v1.1.0
Published
Reads JSON and JSON5 from a file. Returns null if file does not exist (or is a directory) instead of throwing an Error.
Downloads
22
Maintainers
Readme
read-file-json
Reads JSON and JSON5 from a file. Returns null if file does not exist (or is a directory) instead of throwing an Error.
Installation
npm install --save read-file-json@^1.1.0
yarn add read-file-json@^1.1.0
(if configured properly)
npm install --save @jaid/read-file-json@^1.1.0
Example
import readFileJson from "read-file-json"
readFileJson("./exists.json5").then(result => {
})
readFileJson("./doesNotExist.json5").then(result2 => {
})
Variable result
will be:
["a", "b", "c"]
Variable result2
will be:
null
Development
Setting up:
git clone [email protected]:jaid/read-file-json.git
cd read-file-json
npm install
Testing:
npm run test:dev
Testing in production environment:
npm run test
License
MIT License
Copyright © 2021, Jaid <[email protected]> (https://github.com/jaid)