🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@rg-dev/stdlib

Package Overview
Dependencies
Maintainers
1
Versions
69
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.33
to
1.0.34
+8
-4
lib/common-env.cjs

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

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

@@ -103,7 +103,11 @@ isNonEmptyString: () => isNonEmptyString,

}
async function fetchHelperPostJSON(url, body, config) {
async function fetchHelperPost(url, body, config) {
const isObject = typeof body == "object";
config = config || {};
config.method = "POST";
config.body = typeof body == "string" ? body : JSON.stringify(body);
config.headers["Content-Type"] = "application/json";
config.body = isObject ? JSON.stringify(body) : body;
config.headers = config.headers || {};
if (isObject) {
config.headers["Content-Type"] = "application/json";
}
const res = await fetch(url, config);

@@ -110,0 +114,0 @@ if (!res.ok) {

@@ -45,3 +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 fetchHelperPost(url: string, body: any, config?: RequestInit): Promise<Response>;
declare function fetchHelperText(url: string, config?: RequestInit): Promise<string>;

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

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

@@ -45,3 +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 fetchHelperPost(url: string, body: any, config?: RequestInit): Promise<Response>;
declare function fetchHelperText(url: string, config?: RequestInit): Promise<string>;

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

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

@@ -64,7 +64,11 @@ // src/promise-retry.ts

}
async function fetchHelperPostJSON(url, body, config) {
async function fetchHelperPost(url, body, config) {
const isObject = typeof body == "object";
config = config || {};
config.method = "POST";
config.body = typeof body == "string" ? body : JSON.stringify(body);
config.headers["Content-Type"] = "application/json";
config.body = isObject ? JSON.stringify(body) : body;
config.headers = config.headers || {};
if (isObject) {
config.headers["Content-Type"] = "application/json";
}
const res = await fetch(url, config);

@@ -204,3 +208,3 @@ if (!res.ok) {

fetchHelperJSON,
fetchHelperPostJSON,
fetchHelperPost,
fetchHelperText,

@@ -207,0 +211,0 @@ isNonEmptyString,

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

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