@shakerquiz/utilities 0.3.10 → 0.3.11
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.
- package/package.json +1 -1
- package/source/functions/fetch.d.ts +2 -5
- package/source/functions/fetch.js +25 -10
- package/source/index.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { URLOptions } from '@yurkimus/url'
|
|
2
2
|
|
|
3
|
-
export function
|
|
3
|
+
export function getFeatureFetch<
|
|
4
4
|
F extends Feature,
|
|
5
5
|
S extends Service,
|
|
6
6
|
N extends Network,
|
|
7
7
|
K extends Kind,
|
|
8
8
|
>(
|
|
9
|
-
feature: F,
|
|
10
|
-
kind?: K,
|
|
11
|
-
service?: S,
|
|
12
|
-
network?: N,
|
|
9
|
+
configuration: F | { feature: F; kind?: K; service?: S; network?: N },
|
|
13
10
|
): (input: URLOptions, init: RequestInit) => Promise<any>
|
|
@@ -42,17 +42,32 @@ var fulfillment = (kind, [response, body]) => {
|
|
|
42
42
|
* @template {Network} N
|
|
43
43
|
* @template {Kind} K
|
|
44
44
|
*
|
|
45
|
-
* @param {F}
|
|
46
|
-
* @param {S} service
|
|
47
|
-
* @param {N} network
|
|
48
|
-
* @param {K} kind
|
|
45
|
+
* @param {F | { feature: F, kind?: K, service?: S, network?: N }} configuration
|
|
49
46
|
*/
|
|
50
|
-
export var
|
|
51
|
-
feature,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
export var getFeatureFetch = configuration => {
|
|
48
|
+
var feature,
|
|
49
|
+
kind = Kinds.Unit,
|
|
50
|
+
service = FeatureServiceDefaults[feature],
|
|
51
|
+
network = Networks.Public
|
|
52
|
+
|
|
53
|
+
switch (type(configuration)) {
|
|
54
|
+
case 'String':
|
|
55
|
+
feature = configuration
|
|
56
|
+
break
|
|
57
|
+
|
|
58
|
+
case 'Object':
|
|
59
|
+
feature = configuration.feature
|
|
60
|
+
kind = configuration.kind ?? kind
|
|
61
|
+
service = configuration.service ?? service
|
|
62
|
+
network = configuration.network ?? network
|
|
63
|
+
break
|
|
64
|
+
|
|
65
|
+
default:
|
|
66
|
+
throw TypeError(
|
|
67
|
+
`Parameter configuration '${configuration}' must be either 'String' or 'Object'.`,
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
56
71
|
if (!(feature in Features))
|
|
57
72
|
throw TypeError(
|
|
58
73
|
`Feature '${feature}' must be a member of 'Features'.`,
|
package/source/index.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ export * from './enumerations/regexps.js'
|
|
|
27
27
|
export * from './enumerations/requirements.js'
|
|
28
28
|
export * from './enumerations/roles.js'
|
|
29
29
|
export * from './enumerations/services.js'
|
|
30
|
-
|
|
31
30
|
export * from './functions/fetch.js'
|
|
32
31
|
export * from './functions/origin.js'
|
|
33
32
|
export * from './functions/pathname.js'
|