You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@rxap/node-utilities

Package Overview
Dependencies
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rxap/node-utilities - npm Package Compare versions

Comparing version

to
1.2.2

6

CHANGELOG.md

@@ -6,2 +6,8 @@ # Change Log

## [1.2.2](https://gitlab.com/rxap/packages/compare/@rxap/node-utilities@1.2.2-dev.0...@rxap/node-utilities@1.2.2) (2024-05-29)
### Bug Fixes
- support async package json reading ([6b8a163](https://gitlab.com/rxap/packages/commit/6b8a16323b25108a81291ccf976ee7c2aaedacc3))
## [1.2.2-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/node-utilities@1.2.1...@rxap/node-utilities@1.2.2-dev.0) (2024-05-29)

@@ -8,0 +14,0 @@

4

package.json
{
"version": "1.2.2-dev.0",
"version": "1.2.2",
"name": "@rxap/node-utilities",

@@ -36,4 +36,4 @@ "license": "GPL-3.0-or-later",

"type": "commonjs",
"gitHead": "e22fbc92edd1b64c80b0d2d0e42a7756851d1933",
"gitHead": "5fbe2959907b2f431b9bb9309415df831b8ff520",
"main": "./src/index.js"
}
export declare function jsonFile<T = Record<string, unknown>>(jsonFilePath: string): T;
export declare function jsonFileWithRetry<T = Record<string, unknown>>(path: string, retries?: number, sleep?: number): Promise<T>;
export declare function writeJsonFile<T>(jsonFilePath: string, data: T): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeJsonFile = exports.jsonFile = void 0;
exports.writeJsonFile = exports.jsonFileWithRetry = exports.jsonFile = void 0;
const tslib_1 = require("tslib");
const fs_1 = require("fs");

@@ -18,2 +19,25 @@ function jsonFile(jsonFilePath) {

exports.jsonFile = jsonFile;
function jsonFileWithRetry(path, retries = 3, sleep = 3000) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!(0, fs_1.existsSync)(path)) {
throw new Error(`Cannot parse json object. File ${path} not found`);
}
let retryCount = 0;
let lastError;
do {
try {
return jsonFile(path);
}
catch (e) {
lastError = e;
retryCount++;
if (retryCount < retries) {
yield new Promise(resolve => setTimeout(resolve, sleep * retryCount));
}
}
} while (retryCount < retries);
throw new Error(`Failed to parse json file ${path}: ${lastError === null || lastError === void 0 ? void 0 : lastError.message}`);
});
}
exports.jsonFileWithRetry = jsonFileWithRetry;
function writeJsonFile(jsonFilePath, data) {

@@ -20,0 +44,0 @@ (0, fs_1.writeFileSync)(jsonFilePath, JSON.stringify(data, null, 2) + '\n');

Sorry, the diff of this file is not supported yet