pax_global_header00006660000000000000000000000064127111642730014516gustar00rootroot0000000000000052 comment=49620f12bce627dc2459a08f5ef18cd2ff151eb2 load-json-file-2.0.0/000077500000000000000000000000001271116427300143205ustar00rootroot00000000000000load-json-file-2.0.0/.editorconfig000066400000000000000000000002761271116427300170020ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 load-json-file-2.0.0/.gitattributes000066400000000000000000000000141271116427300172060ustar00rootroot00000000000000* text=auto load-json-file-2.0.0/.gitignore000066400000000000000000000000151271116427300163040ustar00rootroot00000000000000node_modules load-json-file-2.0.0/.travis.yml000066400000000000000000000000531271116427300164270ustar00rootroot00000000000000language: node_js node_js: - '6' - '4' load-json-file-2.0.0/index.js000066400000000000000000000006461271116427300157730ustar00rootroot00000000000000'use strict'; const path = require('path'); const fs = require('graceful-fs'); const stripBom = require('strip-bom'); const parseJson = require('parse-json'); const pify = require('pify'); const parse = (data, fp) => parseJson(stripBom(data), path.relative('.', fp)); module.exports = fp => pify(fs.readFile)(fp, 'utf8').then(data => parse(data, fp)); module.exports.sync = fp => parse(fs.readFileSync(fp, 'utf8'), fp); load-json-file-2.0.0/license000066400000000000000000000021371271116427300156700ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. load-json-file-2.0.0/package.json000066400000000000000000000013301271116427300166030ustar00rootroot00000000000000{ "name": "load-json-file", "version": "2.0.0", "description": "Read and parse a JSON file", "license": "MIT", "repository": "sindresorhus/load-json-file", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=4" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "read", "json", "parse", "file", "fs", "graceful", "load" ], "dependencies": { "graceful-fs": "^4.1.2", "parse-json": "^2.2.0", "pify": "^2.0.0", "strip-bom": "^3.0.0" }, "devDependencies": { "ava": "*", "xo": "*" }, "xo": { "esnext": true } } load-json-file-2.0.0/readme.md000066400000000000000000000016531271116427300161040ustar00rootroot00000000000000# load-json-file [![Build Status](https://travis-ci.org/sindresorhus/load-json-file.svg?branch=master)](https://travis-ci.org/sindresorhus/load-json-file) > Read and parse a JSON file [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom), uses [`graceful-fs`](https://github.com/isaacs/node-graceful-fs), and throws more [helpful JSON errors](https://github.com/sindresorhus/parse-json). ## Install ``` $ npm install --save load-json-file ``` ## Usage ```js const loadJsonFile = require('load-json-file'); loadJsonFile('foo.json').then(json => { console.log(json); //=> {foo: true} }); ``` ## API ### loadJsonFile(filepath) Returns a promise for the parsed JSON. ### loadJsonFile.sync(filepath) Returns the parsed JSON. ## Related - [write-json-file](https://github.com/sindresorhus/write-json-file) - Stringify and write JSON to a file atomically ## License MIT © [Sindre Sorhus](https://sindresorhus.com) load-json-file-2.0.0/test.js000066400000000000000000000004501271116427300156340ustar00rootroot00000000000000import path from 'path'; import test from 'ava'; import m from './'; const fixture = path.join(__dirname, 'package.json'); test('async', async t => { const data = await m(fixture); t.is(data.name, 'load-json-file'); }); test('sync', t => { t.is(m.sync(fixture).name, 'load-json-file'); });