alfy 0.12.2 → 0.12.3
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/index.d.ts +1 -0
- package/index.js +9 -4
- package/package.json +1 -1
- package/readme.md +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -116,12 +116,17 @@ alfy.fetch = async (url, options) => {
|
|
|
116
116
|
...options,
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
// Deprecated, but left for backwards-compatibility.
|
|
120
|
+
if (options.query) {
|
|
121
|
+
options.searchParams = options.query;
|
|
122
|
+
}
|
|
123
|
+
|
|
119
124
|
if (typeof url !== 'string') {
|
|
120
|
-
|
|
125
|
+
throw new TypeError(`Expected \`url\` to be a \`string\`, got \`${typeof url}\``);
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
if (options.transform && typeof options.transform !== 'function') {
|
|
124
|
-
|
|
129
|
+
throw new TypeError(`Expected \`transform\` to be a \`function\`, got \`${typeof options.transform}\``);
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
const rawKey = url + JSON.stringify(options);
|
|
@@ -129,12 +134,12 @@ alfy.fetch = async (url, options) => {
|
|
|
129
134
|
const cachedResponse = alfy.cache.get(key, {ignoreMaxAge: true});
|
|
130
135
|
|
|
131
136
|
if (cachedResponse && !alfy.cache.isExpired(key)) {
|
|
132
|
-
return
|
|
137
|
+
return cachedResponse;
|
|
133
138
|
}
|
|
134
139
|
|
|
135
140
|
let response;
|
|
136
141
|
try {
|
|
137
|
-
response = await got(url,
|
|
142
|
+
response = await got(url, options).json();
|
|
138
143
|
} catch (error) {
|
|
139
144
|
if (cachedResponse) {
|
|
140
145
|
return cachedResponse;
|
package/package.json
CHANGED
package/readme.md
CHANGED