@rg-dev/stdlib 1.0.30 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,7 +107,7 @@ async function fetchHelperText(url, config) {
107
107
  return await res.text();
108
108
  }
109
109
  function throwIfNotJSONResponse(res) {
110
- const contentType = res.headers["content-type"] || "";
110
+ const contentType = res.headers.get("content-type");
111
111
  if (!(contentType == null ? void 0 : contentType.toLowerCase().includes("application/json"))) {
112
112
  throw new Error(`Response is not JSON (content-type: ${contentType}, URL: ${res.url})`);
113
113
  }
@@ -41,7 +41,7 @@ declare class StringBuilder implements IStringBuilder {
41
41
  toString(): string;
42
42
  }
43
43
 
44
- declare function fetchHelperJSON(url: string, config?: RequestInit): Promise<any>;
44
+ declare function fetchHelperJSON<T extends Record<string, any>>(url: string, config?: RequestInit): Promise<T>;
45
45
  declare function fetchHelperText(url: string, config?: RequestInit): Promise<string>;
46
46
 
47
47
  type MyFn<T extends Record<string, (...args: any[]) => any>> = {
@@ -41,7 +41,7 @@ declare class StringBuilder implements IStringBuilder {
41
41
  toString(): string;
42
42
  }
43
43
 
44
- declare function fetchHelperJSON(url: string, config?: RequestInit): Promise<any>;
44
+ declare function fetchHelperJSON<T extends Record<string, any>>(url: string, config?: RequestInit): Promise<T>;
45
45
  declare function fetchHelperText(url: string, config?: RequestInit): Promise<string>;
46
46
 
47
47
  type MyFn<T extends Record<string, (...args: any[]) => any>> = {
package/lib/common-env.js CHANGED
@@ -70,7 +70,7 @@ async function fetchHelperText(url, config) {
70
70
  return await res.text();
71
71
  }
72
72
  function throwIfNotJSONResponse(res) {
73
- const contentType = res.headers["content-type"] || "";
73
+ const contentType = res.headers.get("content-type");
74
74
  if (!(contentType == null ? void 0 : contentType.toLowerCase().includes("application/json"))) {
75
75
  throw new Error(`Response is not JSON (content-type: ${contentType}, URL: ${res.url})`);
76
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rg-dev/stdlib",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",