rekwest 3.3.1 → 3.3.2
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/utils.js +13 -17
- package/package.json +7 -7
- package/src/utils.mjs +12 -11
package/dist/utils.js
CHANGED
|
@@ -187,44 +187,40 @@ const mixin = (res, {
|
|
|
187
187
|
Object.defineProperties(res, {
|
|
188
188
|
arrayBuffer: {
|
|
189
189
|
enumerable: true,
|
|
190
|
-
|
|
191
|
-
value() {
|
|
190
|
+
value: async function () {
|
|
192
191
|
collate(this, res?.constructor);
|
|
193
192
|
parse &&= false;
|
|
194
|
-
|
|
193
|
+
const {
|
|
195
194
|
buffer,
|
|
196
195
|
byteLength,
|
|
197
196
|
byteOffset
|
|
198
|
-
}
|
|
197
|
+
} = await this.body();
|
|
198
|
+
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
199
199
|
}
|
|
200
|
-
|
|
201
200
|
},
|
|
202
201
|
blob: {
|
|
203
202
|
enumerable: true,
|
|
204
|
-
|
|
205
|
-
value() {
|
|
203
|
+
value: async function () {
|
|
206
204
|
collate(this, res?.constructor);
|
|
207
|
-
|
|
205
|
+
const val = await this.arrayBuffer();
|
|
206
|
+
return new _nodeBuffer.Blob([val]);
|
|
208
207
|
}
|
|
209
|
-
|
|
210
208
|
},
|
|
211
209
|
json: {
|
|
212
210
|
enumerable: true,
|
|
213
|
-
|
|
214
|
-
value() {
|
|
211
|
+
value: async function () {
|
|
215
212
|
collate(this, res?.constructor);
|
|
216
|
-
|
|
213
|
+
const val = await this.text();
|
|
214
|
+
return JSON.parse(val);
|
|
217
215
|
}
|
|
218
|
-
|
|
219
216
|
},
|
|
220
217
|
text: {
|
|
221
218
|
enumerable: true,
|
|
222
|
-
|
|
223
|
-
value() {
|
|
219
|
+
value: async function () {
|
|
224
220
|
collate(this, res?.constructor);
|
|
225
|
-
|
|
221
|
+
const blob = await this.blob();
|
|
222
|
+
return blob.text();
|
|
226
223
|
}
|
|
227
|
-
|
|
228
224
|
}
|
|
229
225
|
});
|
|
230
226
|
}
|
package/package.json
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"url": "https://github.com/bricss/rekwest/issues"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@babel/cli": "^7.
|
|
12
|
-
"@babel/core": "^7.
|
|
13
|
-
"@babel/eslint-parser": "^7.
|
|
14
|
-
"@babel/preset-env": "^7.
|
|
15
|
-
"c8": "^7.
|
|
16
|
-
"eslint": "^8.
|
|
11
|
+
"@babel/cli": "^7.18.10",
|
|
12
|
+
"@babel/core": "^7.18.10",
|
|
13
|
+
"@babel/eslint-parser": "^7.18.9",
|
|
14
|
+
"@babel/preset-env": "^7.18.10",
|
|
15
|
+
"c8": "^7.12.0",
|
|
16
|
+
"eslint": "^8.21.0",
|
|
17
17
|
"eslint-config-ultra-refined": "^2.5.0",
|
|
18
18
|
"mocha": "^10.0.0"
|
|
19
19
|
},
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"test:bail": "mocha --bail",
|
|
66
66
|
"test:cover": "c8 --include=src --reporter=lcov --reporter=text npm test"
|
|
67
67
|
},
|
|
68
|
-
"version": "3.3.
|
|
68
|
+
"version": "3.3.2"
|
|
69
69
|
}
|
package/src/utils.mjs
CHANGED
|
@@ -169,38 +169,39 @@ export const mixin = (res, { digest = false, parse = false } = {}) => {
|
|
|
169
169
|
Object.defineProperties(res, {
|
|
170
170
|
arrayBuffer: {
|
|
171
171
|
enumerable: true,
|
|
172
|
-
value() {
|
|
172
|
+
value: async function () {
|
|
173
173
|
collate(this, res?.constructor);
|
|
174
174
|
parse &&= false;
|
|
175
|
+
const { buffer, byteLength, byteOffset } = await this.body();
|
|
175
176
|
|
|
176
|
-
return
|
|
177
|
-
byteOffset,
|
|
178
|
-
byteOffset + byteLength,
|
|
179
|
-
));
|
|
177
|
+
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
180
178
|
},
|
|
181
179
|
},
|
|
182
180
|
blob: {
|
|
183
181
|
enumerable: true,
|
|
184
|
-
value() {
|
|
182
|
+
value: async function () {
|
|
185
183
|
collate(this, res?.constructor);
|
|
184
|
+
const val = await this.arrayBuffer();
|
|
186
185
|
|
|
187
|
-
return
|
|
186
|
+
return new Blob([val]);
|
|
188
187
|
},
|
|
189
188
|
},
|
|
190
189
|
json: {
|
|
191
190
|
enumerable: true,
|
|
192
|
-
value() {
|
|
191
|
+
value: async function () {
|
|
193
192
|
collate(this, res?.constructor);
|
|
193
|
+
const val = await this.text();
|
|
194
194
|
|
|
195
|
-
return
|
|
195
|
+
return JSON.parse(val);
|
|
196
196
|
},
|
|
197
197
|
},
|
|
198
198
|
text: {
|
|
199
199
|
enumerable: true,
|
|
200
|
-
value() {
|
|
200
|
+
value: async function () {
|
|
201
201
|
collate(this, res?.constructor);
|
|
202
|
+
const blob = await this.blob();
|
|
202
203
|
|
|
203
|
-
return
|
|
204
|
+
return blob.text();
|
|
204
205
|
},
|
|
205
206
|
},
|
|
206
207
|
});
|