@hkdigital/lib-sveltekit 0.0.65 → 0.0.66

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.
@@ -1,20 +1,22 @@
1
1
  /**
2
2
  * Make GET request
3
3
  *
4
- * @param {string|URL} url - Url string or URL object
4
+ * @paramm {object} _
5
5
  *
6
- * @param {object} [urlSearchParams]
6
+ * @param {string|URL} _.url - Url string or URL object
7
+ *
8
+ * @param {object} [_.urlSearchParams]
7
9
  * Parameters that should be added to the request url
8
10
  *
9
- * @param {object} [headers]
11
+ * @param {object} [_.headers]
10
12
  * Object that contains custom headers. A header is a name, value pair.
11
13
  *
12
14
  * e.g. options.headers = { "content-type": "application/json" }
13
15
  *
14
- * @param {function} [requestHandler]
16
+ * @param {function} [_.requestHandler]
15
17
  * If defined, this function will receive the abort handler function
16
18
  *
17
- * @param {number} [timeoutMs]
19
+ * @param {number} [_.timeoutMs]
18
20
  * If defined, this request will abort after the specified number of
19
21
  * milliseconds. Values above the the built-in request timeout won't work.
20
22
  *
@@ -24,19 +26,21 @@ export function httpGet({ url, urlSearchParams, headers, requestHandler, timeout
24
26
  /**
25
27
  * Make POST request
26
28
  *
27
- * @param {string|URL} url - Url string or URL object
29
+ * @paramm {object} _
30
+ *
31
+ * @param {string|URL} _.url - Url string or URL object
28
32
  *
29
- * @param {any} [body] - POST data
33
+ * @param {any} [_.body] - POST data
30
34
  *
31
- * @param {object} [headers]
35
+ * @param {object} [_.headers]
32
36
  * Object that contains custom headers. A header is a name, value pair.
33
37
  *
34
38
  * e.g. options.headers = { "content-type": "application/json" }
35
39
  *
36
- * @param {function} [requestHandler]
40
+ * @param {function} [_.requestHandler]
37
41
  * If defined, this function will receive the abort handler function
38
42
  *
39
- * @param {number} [timeoutMs]
43
+ * @param {number} [_.timeoutMs]
40
44
  * If defined, this request will abort after the specified number of
41
45
  * milliseconds. Values above the the built-in request timeout won't work.
42
46
  *
@@ -48,23 +52,25 @@ export function httpPost({ url, body, headers, requestHandler, timeoutMs }: stri
48
52
  * - This is a low level function, consider using
49
53
  * httpGet, httpPost, jsonGet or jsonPost instead
50
54
  *
51
- * @param {string|URL} url - Url string or URL object
55
+ * @paramm {object} _
56
+ *
57
+ * @param {string|URL} _.url - Url string or URL object
52
58
  *
53
- * @param {string} method - Request method: METHOD_GET | METHOD_POST
59
+ * @param {string} _.method - Request method: METHOD_GET | METHOD_POST
54
60
  *
55
- * @param {object} [urlSearchParams] - URL search parameters as key-value pairs
61
+ * @param {object} [_.urlSearchParams] - URL search parameters as key-value pairs
56
62
  *
57
- * @param {any} [body] - POST data
63
+ * @param {any} [_.body] - POST data
58
64
  *
59
- * @param {object} [headers]
65
+ * @param {object} [_.headers]
60
66
  * Object that contains custom headers. A header is a name, value pair.
61
67
  *
62
68
  * e.g. options.headers = { "content-type": "application/json" }
63
69
  *
64
- * @param {function} [requestHandler]
70
+ * @param {( { controller: AbortController, abort: ( reason?: Error ) => void, timeout: number } )=> void} [_.requestHandler]
65
71
  * If defined, this function will receive the abort handler function
66
72
  *
67
- * @param {number} [timeoutMs]
73
+ * @param {number} [_.timeoutMs]
68
74
  * If defined, this request will abort after the specified number of
69
75
  * milliseconds. Values above the the built-in request timeout won't work.
70
76
  *
@@ -14,20 +14,22 @@ import { waitForAndCheckResponse } from './response.js';
14
14
  /**
15
15
  * Make GET request
16
16
  *
17
- * @param {string|URL} url - Url string or URL object
17
+ * @paramm {object} _
18
18
  *
19
- * @param {object} [urlSearchParams]
19
+ * @param {string|URL} _.url - Url string or URL object
20
+ *
21
+ * @param {object} [_.urlSearchParams]
20
22
  * Parameters that should be added to the request url
21
23
  *
22
- * @param {object} [headers]
24
+ * @param {object} [_.headers]
23
25
  * Object that contains custom headers. A header is a name, value pair.
24
26
  *
25
27
  * e.g. options.headers = { "content-type": "application/json" }
26
28
  *
27
- * @param {function} [requestHandler]
29
+ * @param {function} [_.requestHandler]
28
30
  * If defined, this function will receive the abort handler function
29
31
  *
30
- * @param {number} [timeoutMs]
32
+ * @param {number} [_.timeoutMs]
31
33
  * If defined, this request will abort after the specified number of
32
34
  * milliseconds. Values above the the built-in request timeout won't work.
33
35
  *
@@ -49,19 +51,21 @@ export async function httpGet({ url, urlSearchParams, headers, requestHandler, t
49
51
  /**
50
52
  * Make POST request
51
53
  *
52
- * @param {string|URL} url - Url string or URL object
54
+ * @paramm {object} _
55
+ *
56
+ * @param {string|URL} _.url - Url string or URL object
53
57
  *
54
- * @param {any} [body] - POST data
58
+ * @param {any} [_.body] - POST data
55
59
  *
56
- * @param {object} [headers]
60
+ * @param {object} [_.headers]
57
61
  * Object that contains custom headers. A header is a name, value pair.
58
62
  *
59
63
  * e.g. options.headers = { "content-type": "application/json" }
60
64
  *
61
- * @param {function} [requestHandler]
65
+ * @param {function} [_.requestHandler]
62
66
  * If defined, this function will receive the abort handler function
63
67
  *
64
- * @param {number} [timeoutMs]
68
+ * @param {number} [_.timeoutMs]
65
69
  * If defined, this request will abort after the specified number of
66
70
  * milliseconds. Values above the the built-in request timeout won't work.
67
71
  *
@@ -87,23 +91,25 @@ export async function httpPost({ url, body = null, headers, requestHandler, time
87
91
  * - This is a low level function, consider using
88
92
  * httpGet, httpPost, jsonGet or jsonPost instead
89
93
  *
90
- * @param {string|URL} url - Url string or URL object
94
+ * @paramm {object} _
95
+ *
96
+ * @param {string|URL} _.url - Url string or URL object
91
97
  *
92
- * @param {string} method - Request method: METHOD_GET | METHOD_POST
98
+ * @param {string} _.method - Request method: METHOD_GET | METHOD_POST
93
99
  *
94
- * @param {object} [urlSearchParams] - URL search parameters as key-value pairs
100
+ * @param {object} [_.urlSearchParams] - URL search parameters as key-value pairs
95
101
  *
96
- * @param {any} [body] - POST data
102
+ * @param {any} [_.body] - POST data
97
103
  *
98
- * @param {object} [headers]
104
+ * @param {object} [_.headers]
99
105
  * Object that contains custom headers. A header is a name, value pair.
100
106
  *
101
107
  * e.g. options.headers = { "content-type": "application/json" }
102
108
  *
103
- * @param {function} [requestHandler]
109
+ * @param {( { controller: AbortController, abort: ( reason?: Error ) => void, timeout: number } )=> void} [_.requestHandler]
104
110
  * If defined, this function will receive the abort handler function
105
111
  *
106
- * @param {number} [timeoutMs]
112
+ * @param {number} [_.timeoutMs]
107
113
  * If defined, this request will abort after the specified number of
108
114
  * milliseconds. Values above the the built-in request timeout won't work.
109
115
  *
@@ -219,7 +225,7 @@ export async function httpRequest({
219
225
  const promise = fetch(request, { signal });
220
226
 
221
227
  if (requestHandler || timeoutMs) {
222
- const abort = (reason) => {
228
+ const abort = (/** @type {Error?} */ reason) => {
223
229
  if (!reason) {
224
230
  reason = new AbortError(`Request [${url.href}] aborted`);
225
231
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.0.65",
3
+ "version": "0.0.66",
4
4
  "author": "Jens Kleinhout, HKdigital (https://hkdigital.nl)",
5
5
  "license": "ISC",
6
6
  "repository": {