read-json-safe
Read JSON files without try catch
Last updated 6 years ago by bconnorwhite .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install read-json-safe 
SYNC missed versions from official npm registry.

read-json-safe

NPM TypeScript Coverage Status GitHub Stars Twitter Follow

Read JSON files without try catch.

Returns undefined on errors, for example if the file does not exist.

Installation

yarn add read-json-safe
npm install read-json-safe

API

Read a JSONValue:

import { readJSON, readJSONSync, JSONValue } from "read-json-safe";

function readJSON(path: string): Promise<JSONValue | undefined>;

function readJSONSync(path: string): JSONValue | undefined;

type JSONValue = string | number | boolean | JSONObject | JSONArray | null;

Read a JSONObject:

import { readJSONObject, readJSONObjectSync, JSONObject } from "read-json-safe";

function readJSONObject(path: string): Promise<JSONObject| undefined>;

function readJSONObjectSync(path: string): JSONObject| undefined;

type JSONObject = {
    [key: string]: JSONValue;
}

Read a JSONArray:

import { readJSONArray, readJSONArraySync, JSONArray } from "read-json-safe";

function readJSONArray(path: string): Promise<JSONArray | undefined>;

function readJSONArraySync(path: string): JSONArray | undefined;

type JSONArray = Array<JSONValue>;

Dependenciesdependencies


Dev DependenciesDavid


License license

MIT


Related Packages

Current Tags

  • 2.0.2                                ...           latest (6 years ago)

9 Versions

  • 2.0.2                                ...           6 years ago
  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.0.5                                ...           6 years ago
  • 1.0.4                                ...           6 years ago
  • 1.0.3                                ...           6 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 8
Last Day 0
Last Week 8
Last Month 1
Dependencies (2)
Dev Dependencies (4)

Copyright 2013 - present © cnpmjs.org | Home |