|
1 | 1 | # read-file-json |
2 | | -## Under construction |
3 | | -Not much to see right now. Come back lator! :crocodile: |
| 2 | + |
| 3 | + |
| 4 | +Reads JSON and JSON5 from a file. Returns null if file does not exist (or is a directory) instead of throwing an Error. |
| 5 | + |
| 6 | +## Installation |
| 7 | +<a href='https://npmjs.com/package/read-file-json'><img alt='npm logo' src='https://github.com/Jaid/action-readme/raw/master/images/base-assets/npm.png'/></a> |
| 8 | +```bash |
| 9 | +npm install --save read-file-json@^0.1.0 |
| 10 | +``` |
| 11 | +<a href='https://yarnpkg.com/package/read-file-json'><img alt='Yarn logo' src='https://github.com/Jaid/action-readme/raw/master/images/base-assets/yarn.png'/></a> |
| 12 | +```bash |
| 13 | +yarn add read-file-json@^0.1.0 |
| 14 | +``` |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +## Documentation |
| 19 | + |
| 20 | +* [read-file-json](#module_read-file-json) |
| 21 | + * [module.exports(file)](#exp_module_read-file-json--module.exports) ⇒ <code>Promise.<string></code> ⏏ |
| 22 | + * [.readFileJsonSync(file)](#module_read-file-json--module.exports.readFileJsonSync) ⇒ <code>string</code> |
| 23 | + |
| 24 | +**Kind**: Exported function |
| 25 | +**Returns**: <code>Promise.<string></code> - File contents in UTF-8 or null if file could not be read |
| 26 | + |
| 27 | +| Param | Type | Description | |
| 28 | +| --- | --- | --- | |
| 29 | +| file | <code>string</code> | Path to a file | |
| 30 | + |
| 31 | +**Example** |
| 32 | +```javascript |
| 33 | +import readFileJson from "read-file-json" |
| 34 | +const result = await readFileJson("readme.md") |
| 35 | +result === "## Hewwo OwO" |
| 36 | +``` |
| 37 | +**Kind**: static method of [<code>module.exports</code>](#exp_module_read-file-json--module.exports) |
| 38 | +**Returns**: <code>string</code> - File contents in UTF-8 or null if file could not be read |
| 39 | + |
| 40 | +| Param | Type | Description | |
| 41 | +| --- | --- | --- | |
| 42 | +| file | <code>string</code> | Path to a file | |
| 43 | + |
| 44 | +**Example** |
| 45 | +```javascript |
| 46 | +import {readFileJsonSync} from "read-file-json" |
| 47 | +const result = readFileJsonSync("readme.md") |
| 48 | +result === "## Hewwo OwO" |
| 49 | +``` |
| 50 | + |
| 51 | + |
| 52 | +## License |
| 53 | +```text |
| 54 | +MIT License |
| 55 | +
|
| 56 | +Copyright © 2019, Jaid <[email protected]> (github.com/jaid) |
| 57 | +
|
| 58 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 59 | +of this software and associated documentation files (the "Software"), to deal |
| 60 | +in the Software without restriction, including without limitation the rights |
| 61 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 62 | +copies of the Software, and to permit persons to whom the Software is |
| 63 | +furnished to do so, subject to the following conditions: |
| 64 | +
|
| 65 | +The above copyright notice and this permission notice shall be included in all |
| 66 | +copies or substantial portions of the Software. |
| 67 | +
|
| 68 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 69 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 70 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 71 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 72 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 73 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 74 | +SOFTWARE. |
| 75 | +``` |
0 commit comments