Skip to content

Reads JSON and JSON5 from a file. Returns null if file does not exist (or is a directory) instead of throwing an Error.

License

Notifications You must be signed in to change notification settings

Jaid/read-file-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

70b83c2 · Sep 17, 2021
May 14, 2021
May 23, 2021
May 23, 2021
Dec 19, 2019
Sep 17, 2021
Dec 19, 2019
Dec 21, 2019
Jan 20, 2020
Sep 17, 2021
May 22, 2021
Sep 17, 2021
May 23, 2021
May 23, 2021
May 23, 2021
May 23, 2021
Oct 1, 2020
Sep 17, 2021

Repository files navigation

read-file-json

License Sponsor read-file-json
Build status Commits since v1.1.0 Last commit Issues
Latest version on npm Dependents Downloads

Reads JSON and JSON5 from a file. Returns null if file does not exist (or is a directory) instead of throwing an Error.

Installation

read-file-json on npm

npm install --save read-file-json@^1.1.0

read-file-json on Yarn

yarn add read-file-json@^1.1.0

@jaid/read-file-json on GitHub Packages
(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 git@github.com: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 <jaid.jsx@gmail.com> (https://github.com/jaid)