🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@rg-dev/stdlib

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rg-dev/stdlib - npm Package Compare versions

Comparing version
1.0.32
to
1.0.33
+13
-0
lib/common-env.cjs

@@ -27,2 +27,3 @@ var __defProp = Object.defineProperty;

fetchHelperJSON: () => fetchHelperJSON,
fetchHelperPostJSON: () => fetchHelperPostJSON,
fetchHelperText: () => fetchHelperText,

@@ -102,2 +103,14 @@ isNonEmptyString: () => isNonEmptyString,

}
async function fetchHelperPostJSON(url, body, config) {
config = config || {};
config.method = "POST";
config.body = typeof body == "string" ? body : JSON.stringify(body);
config.headers["Content-Type"] = "application/json";
const res = await fetch(url, config);
if (!res.ok) {
const text = await res.text();
throw new Error(`Error ${text || "No content"} Status: ${res.status} Request URL: ${url}`);
}
return res;
}
async function fetchHelperText(url, config) {

@@ -104,0 +117,0 @@ const res = await fetch(url, config);

+2
-1

@@ -45,2 +45,3 @@ type Options = {

declare function fetchHelperJSON<T extends Record<string, any>>(url: string, config?: RequestInit): Promise<T>;
declare function fetchHelperPostJSON(url: string, body: any, config?: RequestInit): Promise<Response>;
declare function fetchHelperText(url: string, config?: RequestInit): Promise<string>;

@@ -77,2 +78,2 @@

export { type AsyncReturnType, type MaybeFunction, type MyFn, Optional, StringBuilder, catchInline, doSafe, fetchHelperJSON, fetchHelperText, isNonEmptyString, isNumber, isRunningOnServer, promiseRetry, promiseWithTimeout, sleep, useServer };
export { type AsyncReturnType, type MaybeFunction, type MyFn, Optional, StringBuilder, catchInline, doSafe, fetchHelperJSON, fetchHelperPostJSON, fetchHelperText, isNonEmptyString, isNumber, isRunningOnServer, promiseRetry, promiseWithTimeout, sleep, useServer };

@@ -45,2 +45,3 @@ type Options = {

declare function fetchHelperJSON<T extends Record<string, any>>(url: string, config?: RequestInit): Promise<T>;
declare function fetchHelperPostJSON(url: string, body: any, config?: RequestInit): Promise<Response>;
declare function fetchHelperText(url: string, config?: RequestInit): Promise<string>;

@@ -77,2 +78,2 @@

export { type AsyncReturnType, type MaybeFunction, type MyFn, Optional, StringBuilder, catchInline, doSafe, fetchHelperJSON, fetchHelperText, isNonEmptyString, isNumber, isRunningOnServer, promiseRetry, promiseWithTimeout, sleep, useServer };
export { type AsyncReturnType, type MaybeFunction, type MyFn, Optional, StringBuilder, catchInline, doSafe, fetchHelperJSON, fetchHelperPostJSON, fetchHelperText, isNonEmptyString, isNumber, isRunningOnServer, promiseRetry, promiseWithTimeout, sleep, useServer };

@@ -64,2 +64,14 @@ // src/promise-retry.ts

}
async function fetchHelperPostJSON(url, body, config) {
config = config || {};
config.method = "POST";
config.body = typeof body == "string" ? body : JSON.stringify(body);
config.headers["Content-Type"] = "application/json";
const res = await fetch(url, config);
if (!res.ok) {
const text = await res.text();
throw new Error(`Error ${text || "No content"} Status: ${res.status} Request URL: ${url}`);
}
return res;
}
async function fetchHelperText(url, config) {

@@ -192,2 +204,3 @@ const res = await fetch(url, config);

fetchHelperJSON,
fetchHelperPostJSON,
fetchHelperText,

@@ -194,0 +207,0 @@ isNonEmptyString,

{
"name": "@rg-dev/stdlib",
"version": "1.0.32",
"version": "1.0.33",
"description": "",

@@ -5,0 +5,0 @@ "scripts": {