keq 1.6.2 → 1.6.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.6.3](https://www.github.com/keq-request/keq/compare/v1.6.2...v1.6.3) (2021-12-07)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * cannot invoke .blob() on the proxy response ([4e21c90](https://www.github.com/keq-request/keq/commit/4e21c90e47c8e84dfb3637e9aab5c8dd63a6e43f))
11
+
5
12
  ### [1.6.2](https://www.github.com/keq-request/keq/compare/v1.6.1...v1.6.2) (2021-11-30)
6
13
 
7
14
 
package/es/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "keq",
3
3
  "main": "lib/index.js",
4
4
  "module": "es/index.js",
5
- "version": "1.6.2",
5
+ "version": "1.6.3",
6
6
  "license": "MIT",
7
7
  "types": "lib/index.d.ts",
8
8
  "scripts": {
package/es/src/keq.js CHANGED
@@ -267,12 +267,18 @@ export class Keq {
267
267
  const cache = {};
268
268
  ctx.res = new Proxy(res, {
269
269
  get(target, property) {
270
- if (!(typeof property === 'string' && ['json', 'formData', 'text'].includes(property)))
270
+ if (!(typeof property === 'string' && ['json', 'formData', 'text', 'blob'].includes(property)))
271
271
  return target[property];
272
272
  return () => {
273
273
  if (!(property in cache))
274
274
  cache[property] = target[property]();
275
- return cache[property].then(data => R.clone(data));
275
+ return cache[property].then(data => {
276
+ if (!isBrowser && data instanceof Buffer)
277
+ return Buffer.from(data);
278
+ else if (isBrowser && data instanceof Blob)
279
+ return data.slice();
280
+ return R.clone(data);
281
+ });
276
282
  };
277
283
  },
278
284
  });
package/es/src/utils.js CHANGED
@@ -16,6 +16,7 @@
16
16
  // typeof object.sort === 'function'
17
17
  // )
18
18
  // }
19
+ import { isBlob } from "./form-data-node/util/is";
19
20
  export function isFormData(object) {
20
21
  return (typeof object === 'object' &&
21
22
  typeof object.append === 'function' &&
@@ -28,19 +29,9 @@ export function isFormData(object) {
28
29
  typeof object.keys === 'function' &&
29
30
  typeof object.values === 'function');
30
31
  }
31
- // export function isBlob(object): boolean {
32
- // return (
33
- // typeof object === 'object' &&
34
- // typeof object.slice === 'function' &&
35
- // typeof object.stream === 'function' &&
36
- // typeof object.text === 'function' &&
37
- // typeof object.arrayBuffer === 'function'
38
- // )
39
- // }
40
32
  export const isBrowser = typeof window !== 'undefined';
41
33
  export function isFile(object) {
42
34
  if (isBrowser)
43
35
  return object instanceof Blob;
44
- else
45
- return object instanceof Buffer;
36
+ return object instanceof Buffer || isBlob(object);
46
37
  }
package/lib/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "keq",
3
3
  "main": "lib/index.js",
4
4
  "module": "es/index.js",
5
- "version": "1.6.2",
5
+ "version": "1.6.3",
6
6
  "license": "MIT",
7
7
  "types": "lib/index.d.ts",
8
8
  "scripts": {
package/lib/src/keq.js CHANGED
@@ -270,12 +270,18 @@ class Keq {
270
270
  const cache = {};
271
271
  ctx.res = new Proxy(res, {
272
272
  get(target, property) {
273
- if (!(typeof property === 'string' && ['json', 'formData', 'text'].includes(property)))
273
+ if (!(typeof property === 'string' && ['json', 'formData', 'text', 'blob'].includes(property)))
274
274
  return target[property];
275
275
  return () => {
276
276
  if (!(property in cache))
277
277
  cache[property] = target[property]();
278
- return cache[property].then(data => R.clone(data));
278
+ return cache[property].then(data => {
279
+ if (!utils_1.isBrowser && data instanceof Buffer)
280
+ return Buffer.from(data);
281
+ else if (utils_1.isBrowser && data instanceof Blob)
282
+ return data.slice();
283
+ return R.clone(data);
284
+ });
279
285
  };
280
286
  },
281
287
  });
package/lib/src/utils.js CHANGED
@@ -19,6 +19,7 @@
19
19
  // }
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.isFile = exports.isBrowser = exports.isFormData = void 0;
22
+ const is_1 = require("./form-data-node/util/is");
22
23
  function isFormData(object) {
23
24
  return (typeof object === 'object' &&
24
25
  typeof object.append === 'function' &&
@@ -32,20 +33,10 @@ function isFormData(object) {
32
33
  typeof object.values === 'function');
33
34
  }
34
35
  exports.isFormData = isFormData;
35
- // export function isBlob(object): boolean {
36
- // return (
37
- // typeof object === 'object' &&
38
- // typeof object.slice === 'function' &&
39
- // typeof object.stream === 'function' &&
40
- // typeof object.text === 'function' &&
41
- // typeof object.arrayBuffer === 'function'
42
- // )
43
- // }
44
36
  exports.isBrowser = typeof window !== 'undefined';
45
37
  function isFile(object) {
46
38
  if (exports.isBrowser)
47
39
  return object instanceof Blob;
48
- else
49
- return object instanceof Buffer;
40
+ return object instanceof Buffer || (0, is_1.isBlob)(object);
50
41
  }
51
42
  exports.isFile = isFile;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "keq",
3
3
  "main": "lib/index.js",
4
4
  "module": "es/index.js",
5
- "version": "1.6.2",
5
+ "version": "1.6.3",
6
6
  "license": "MIT",
7
7
  "types": "lib/index.d.ts",
8
8
  "scripts": {