Skip to content

Commit

Permalink
Release v3.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Aug 12, 2024
1 parent e01ea8a commit 7a05322
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ interesting approach to organizing build tasks.
- 🪺 [recursive-exec](https://github.com/center-key/recursive-exec):  _Run a command on each file in a folder and its subfolders_
- 🔍 [replacer-util](https://github.com/center-key/replacer-util):  _Find and replace strings or template outputs in text files_
- 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):  _Revision web asset filenames with cache busting content hash fingerprints_
- 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):  _Organize npm package.json scripts into named groups of easy to manage commands_
- 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):  _Organize npm package.json scripts into groups of easy to manage commands_
- 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):  _Check the markup validity of HTML files using the W3C validator_

<br>
Expand Down
18 changes: 8 additions & 10 deletions dist/fetch-json.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! fetch-json v3.3.1 ~~ https://fetch-json.js.org ~~ MIT License
//! fetch-json v3.3.2 ~~ https://fetch-json.js.org ~~ MIT License

export type Json = string | number | boolean | null | undefined | JsonObject | Json[];
export type JsonObject = {
Expand All @@ -13,7 +13,6 @@ export type FetchJsonMethod = string;
export type FetchJsonParams = {
[field: string]: string | number | boolean | null | undefined;
};
export type FetchJsonParsedResponse = Json | any;
export type FetchJsonAltResponse = {
ok: boolean;
error: boolean;
Expand All @@ -23,20 +22,19 @@ export type FetchJsonAltResponse = {
data: Json | null;
response: Response;
};
export type FetchJsonResponse = FetchJsonParsedResponse | FetchJsonAltResponse;
export type FetchJsonLogger = (dateIso: string, type?: 'response' | 'request', method?: FetchJsonMethod, domain?: string, url?: string, ok?: boolean, status?: number, statusText?: string, contentType?: string | null) => void;
declare const fetchJson: {
version: string;
baseOptions: FetchJsonOptions;
getBaseOptions(): FetchJsonOptions;
setBaseOptions(options: FetchJsonOptions): FetchJsonOptions;
request<T>(method: FetchJsonMethod, url: string, data?: FetchJsonParams | Json | T, options?: FetchJsonOptions): Promise<FetchJsonResponse>;
get(url: string, params?: FetchJsonParams, options?: FetchJsonOptions): Promise<FetchJsonResponse>;
post<T>(url: string, resource?: Json | T, options?: FetchJsonOptions): Promise<FetchJsonResponse>;
put<T>(url: string, resource?: Json | T, options?: FetchJsonOptions): Promise<FetchJsonResponse>;
patch<T>(url: string, resource?: Json | T, options?: FetchJsonOptions): Promise<FetchJsonResponse>;
delete<T>(url: string, resource?: Json | T, options?: FetchJsonOptions): Promise<FetchJsonResponse>;
head(url: string, params?: FetchJsonParams, options?: FetchJsonOptions): Promise<FetchJsonResponse>;
request(method: FetchJsonMethod, url: string, data?: unknown, options?: FetchJsonOptions): Promise<any>;
get(url: string, params?: FetchJsonParams, options?: FetchJsonOptions): Promise<any>;
post(url: string, resource?: unknown, options?: FetchJsonOptions): Promise<any>;
put(url: string, resource?: unknown, options?: FetchJsonOptions): Promise<any>;
patch(url: string, resource?: unknown, options?: FetchJsonOptions): Promise<any>;
delete(url: string, resource?: unknown, options?: FetchJsonOptions): Promise<any>;
head(url: string, params?: FetchJsonParams, options?: FetchJsonOptions): Promise<any>;
logger: FetchJsonLogger | null;
getLogHeaders(): string[];
getLogHeaderIndexMap(): {
Expand Down
10 changes: 5 additions & 5 deletions dist/fetch-json.dev.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! fetch-json v3.3.1 ~~ https://fetch-json.js.org ~~ MIT License
//! fetch-json v3.3.2 ~~ https://fetch-json.js.org ~~ MIT License

const fetchJson = {
version: '3.3.1',
version: '3.3.2',
baseOptions: {},
getBaseOptions() {
return this.baseOptions;
Expand All @@ -18,9 +18,9 @@ const fetchJson = {
};
const settings = { ...defaults, ...this.baseOptions, ...options };
if (!settings.method || typeof settings.method !== 'string')
throw Error('[fetch-json] HTTP method missing or invalid.');
throw new Error('[fetch-json] HTTP method missing or invalid.');
if (typeof url !== 'string')
throw Error('[fetch-json] URL must be a string.');
throw new Error('[fetch-json] URL must be a string.');
const httpMethod = settings.method.trim().toUpperCase();
const isGetRequest = httpMethod === 'GET';
const jsonHeaders = { Accept: 'application/json' };
Expand Down Expand Up @@ -66,7 +66,7 @@ const fetchJson = {
});
log('response', response.ok, response.status, response.statusText, contentType);
if (settings.strictErrors && !response.ok)
throw Error('[fetch-json] HTTP response status ("strictErrors" mode enabled): ' + response.status);
throw new Error(`[fetch-json] HTTP response status ("strictErrors" mode enabled): ${response.status}`);
return isHead ? response.text().then(headersObj) :
isJson ? response.json().then(jsonToObj).catch(errToObj) : response.text().then(textToObj);
};
Expand Down
10 changes: 5 additions & 5 deletions dist/fetch-json.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! fetch-json v3.3.1 ~~ https://fetch-json.js.org ~~ MIT License
//! fetch-json v3.3.2 ~~ https://fetch-json.js.org ~~ MIT License

const fetchJson = {
version: '3.3.1',
version: '3.3.2',
baseOptions: {},
getBaseOptions() {
return this.baseOptions;
Expand All @@ -18,9 +18,9 @@ const fetchJson = {
};
const settings = { ...defaults, ...this.baseOptions, ...options };
if (!settings.method || typeof settings.method !== 'string')
throw Error('[fetch-json] HTTP method missing or invalid.');
throw new Error('[fetch-json] HTTP method missing or invalid.');
if (typeof url !== 'string')
throw Error('[fetch-json] URL must be a string.');
throw new Error('[fetch-json] URL must be a string.');
const httpMethod = settings.method.trim().toUpperCase();
const isGetRequest = httpMethod === 'GET';
const jsonHeaders = { Accept: 'application/json' };
Expand Down Expand Up @@ -66,7 +66,7 @@ const fetchJson = {
});
log('response', response.ok, response.status, response.statusText, contentType);
if (settings.strictErrors && !response.ok)
throw Error('[fetch-json] HTTP response status ("strictErrors" mode enabled): ' + response.status);
throw new Error(`[fetch-json] HTTP response status ("strictErrors" mode enabled): ${response.status}`);
return isHead ? response.text().then(headersObj) :
isJson ? response.json().then(jsonToObj).catch(errToObj) : response.text().then(textToObj);
};
Expand Down
4 changes: 2 additions & 2 deletions dist/fetch-json.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<title>fetch-json &bull; A wrapper around Fetch just for JSON</title>
<link rel=icon href=https://centerkey.com/graphics/bookmark.png>
<link rel=apple-touch-icon href=logos.png>
<link rel=stylesheet href=https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5/css/all.min.css>
<link rel=stylesheet href=https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.6/css/all.min.css>
<link rel=stylesheet href=https://cdn.jsdelivr.net/npm/dna-engine@3.2/dist/dna-engine.css>
<link rel=stylesheet href=https://cdn.jsdelivr.net/npm/web-ignition@2.2/dist/reset.min.css>
<link rel=stylesheet href=https://cdn.jsdelivr.net/npm/web-ignition@2.2/dist/layouts/letterbox.css>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fetch-json",
"description": "A wrapper around Fetch just for JSON",
"version": "3.3.1",
"version": "3.3.2",
"license": "MIT",
"type": "module",
"module": "dist/fetch-json.js",
Expand Down

0 comments on commit 7a05322

Please sign in to comment.