rekwest 2.3.3 → 2.3.4
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/dist/helpers.js +9 -13
- package/package.json +1 -1
- package/src/helpers.mjs +11 -15
package/dist/helpers.js
CHANGED
|
@@ -199,35 +199,31 @@ const premix = (res, {
|
|
|
199
199
|
Object.defineProperties(res, {
|
|
200
200
|
arrayBuffer: {
|
|
201
201
|
enumerable: true,
|
|
202
|
-
value:
|
|
202
|
+
value: function () {
|
|
203
203
|
parse &&= false;
|
|
204
|
-
|
|
204
|
+
return this.body().then(({
|
|
205
205
|
buffer,
|
|
206
206
|
byteLength,
|
|
207
207
|
byteOffset
|
|
208
|
-
}
|
|
209
|
-
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
208
|
+
}) => buffer.slice(byteOffset, byteOffset + byteLength));
|
|
210
209
|
}
|
|
211
210
|
},
|
|
212
211
|
blob: {
|
|
213
212
|
enumerable: true,
|
|
214
|
-
value:
|
|
215
|
-
|
|
216
|
-
return new _buffer.Blob([val]);
|
|
213
|
+
value: function () {
|
|
214
|
+
return this.arrayBuffer().then(res => new _buffer.Blob([res]));
|
|
217
215
|
}
|
|
218
216
|
},
|
|
219
217
|
json: {
|
|
220
218
|
enumerable: true,
|
|
221
|
-
value:
|
|
222
|
-
|
|
223
|
-
return JSON.parse(val);
|
|
219
|
+
value: function () {
|
|
220
|
+
return this.text().then(res => JSON.parse(res));
|
|
224
221
|
}
|
|
225
222
|
},
|
|
226
223
|
text: {
|
|
227
224
|
enumerable: true,
|
|
228
|
-
value:
|
|
229
|
-
|
|
230
|
-
return val.toString();
|
|
225
|
+
value: function () {
|
|
226
|
+
return this.blob().then(blob => blob.text());
|
|
231
227
|
}
|
|
232
228
|
}
|
|
233
229
|
});
|
package/package.json
CHANGED
package/src/helpers.mjs
CHANGED
|
@@ -182,35 +182,31 @@ export const premix = (res, { digest = false, parse = false } = {}) => {
|
|
|
182
182
|
Object.defineProperties(res, {
|
|
183
183
|
arrayBuffer: {
|
|
184
184
|
enumerable: true,
|
|
185
|
-
value:
|
|
185
|
+
value: function () {
|
|
186
186
|
parse &&= false;
|
|
187
|
-
const { buffer, byteLength, byteOffset } = await this.body();
|
|
188
187
|
|
|
189
|
-
return
|
|
188
|
+
return this.body().then(({ buffer, byteLength, byteOffset }) => buffer.slice(
|
|
189
|
+
byteOffset,
|
|
190
|
+
byteOffset + byteLength,
|
|
191
|
+
));
|
|
190
192
|
},
|
|
191
193
|
},
|
|
192
194
|
blob: {
|
|
193
195
|
enumerable: true,
|
|
194
|
-
value:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return new Blob([val]);
|
|
196
|
+
value: function () {
|
|
197
|
+
return this.arrayBuffer().then((res) => new Blob([res]));
|
|
198
198
|
},
|
|
199
199
|
},
|
|
200
200
|
json: {
|
|
201
201
|
enumerable: true,
|
|
202
|
-
value:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return JSON.parse(val);
|
|
202
|
+
value: function () {
|
|
203
|
+
return this.text().then((res) => JSON.parse(res));
|
|
206
204
|
},
|
|
207
205
|
},
|
|
208
206
|
text: {
|
|
209
207
|
enumerable: true,
|
|
210
|
-
value:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return val.toString();
|
|
208
|
+
value: function () {
|
|
209
|
+
return this.blob().then((blob) => blob.text());
|
|
214
210
|
},
|
|
215
211
|
},
|
|
216
212
|
});
|