Socket
Socket
Sign inDemoInstall

@expo/json-file

Package Overview
Dependencies
Maintainers
26
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expo/json-file - npm Package Compare versions

Comparing version 8.2.37 to 8.3.0

6

build/JsonFile.d.ts

@@ -1,2 +0,2 @@

export declare type JSONValue = boolean | number | string | null | JSONArray | JSONObject;
export type JSONValue = boolean | number | string | null | JSONArray | JSONObject;
export interface JSONArray extends Array<JSONValue> {

@@ -7,4 +7,4 @@ }

}
declare type Defined<T> = T extends undefined ? never : T;
declare type Options<TJSONObject extends JSONObject> = {
type Defined<T> = T extends undefined ? never : T;
type Options<TJSONObject extends JSONObject> = {
badJsonDefault?: TJSONObject;

@@ -11,0 +11,0 @@ jsonParseErrorDefault?: TJSONObject;

@@ -55,2 +55,14 @@ "use strict";

class JsonFile {
file;
options;
static read = read;
static readAsync = readAsync;
static parseJsonString = parseJsonString;
static writeAsync = writeAsync;
static getAsync = getAsync;
static setAsync = setAsync;
static mergeAsync = mergeAsync;
static deleteKeyAsync = deleteKeyAsync;
static deleteKeysAsync = deleteKeysAsync;
static rewriteAsync = rewriteAsync;
constructor(file, options = {}) {

@@ -98,12 +110,2 @@ this.file = file;

exports.default = JsonFile;
JsonFile.read = read;
JsonFile.readAsync = readAsync;
JsonFile.parseJsonString = parseJsonString;
JsonFile.writeAsync = writeAsync;
JsonFile.getAsync = getAsync;
JsonFile.setAsync = setAsync;
JsonFile.mergeAsync = mergeAsync;
JsonFile.deleteKeyAsync = deleteKeyAsync;
JsonFile.deleteKeysAsync = deleteKeysAsync;
JsonFile.rewriteAsync = rewriteAsync;
function read(file, options) {

@@ -175,3 +177,3 @@ let json;

if (defaultValue === undefined) {
throw new JsonFileError_1.default(`No value at key path "${key}" in JSON object from: ${file}`);
throw new JsonFileError_1.default(`No value at key path "${String(key)}" in JSON object from: ${file}`);
}

@@ -181,3 +183,3 @@ return defaultValue;

async function writeAsync(file, object, options) {
if (options === null || options === void 0 ? void 0 : options.ensureDir) {
if (options?.ensureDir) {
await fs_1.default.promises.mkdir(path_1.default.dirname(file), { recursive: true });

@@ -281,3 +283,3 @@ }

function assertEmptyJsonString(json, file) {
if ((json === null || json === void 0 ? void 0 : json.trim()) === '') {
if (json?.trim() === '') {
throw new JsonFileError_1.EmptyJsonFileError(file);

@@ -284,0 +286,0 @@ }

@@ -8,2 +8,6 @@ "use strict";

class JsonFileError extends Error {
cause;
code;
fileName;
isJsonFileError;
constructor(message, cause, code, fileName) {

@@ -10,0 +14,0 @@ let fullMessage = message;

{
"name": "@expo/json-file",
"version": "8.2.37",
"version": "8.3.0",
"description": "A module for reading, writing, and manipulating JSON files",
"main": "build/JsonFile.js",
"scripts": {
"watch": "tsc --watch --preserveWatchOutput",
"build": "tsc",
"prepare": "yarn run clean && yarn build",
"clean": "rimraf build ./tsconfig.tsbuildinfo",
"lint": "eslint .",
"test": "jest"
"build": "expo-module tsc",
"clean": "expo-module clean",
"lint": "expo-module lint",
"prepare": "expo-module clean && expo-module tsc",
"prepublishOnly": "expo-module prepublishOnly",
"test": "expo-module test",
"typecheck": "expo-module typecheck",
"watch": "expo-module tsc --watch --preserveWatchOutput"
},
"repository": {
"type": "git",
"url": "https://github.com/expo/expo-cli.git",
"directory": "packages/json-file"
"url": "https://github.com/expo/expo.git",
"directory": "packages/@expo/json-file"
},

@@ -24,5 +26,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/expo/expo-cli/issues"
"url": "https://github.com/expo/expo/issues"
},
"homepage": "https://github.com/expo/expo-cli/tree/main/packages/json-file#readme",
"homepage": "https://github.com/expo/expo/tree/main/packages/@expo/json-file#readme",
"files": [

@@ -39,7 +41,9 @@ "build"

"@types/json5": "^2.2.0",
"@types/write-file-atomic": "^2.1.1"
"@types/write-file-atomic": "^2.1.1",
"expo-module-scripts": "^3.3.0"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "2763e9cc6f2317b40da73382fe2595f8deebff46"
}

@@ -8,10 +8,23 @@ <!-- Title -->

<p align="center">
<img src="https://flat.badgen.net/packagephobia/install/@expo/json-file">
<!-- Body -->
<a href="https://www.npmjs.com/package/@expo/json-file">
<img src="https://flat.badgen.net/npm/dw/@expo/json-file" target="_blank" />
</a>
</p>
## 🏁 Setup
<!-- Body -->
Install `@expo/json-file` in your project.
```sh
yarn add @expo/json-file
```
## ⚽️ Usage
```ts
import JsonFile, { JSONObject } from '@expo/json-file';
// Create a file instance
const jsonFile = new JsonFile<JSONObject>(filePath);
// Interact with the file
await jsonFile.readAsync();
await jsonFile.writeAsync({ some: 'data' });
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc