got 12.0.1 → 12.0.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.
@@ -410,7 +410,7 @@ export default class Request extends Duplex {
410
410
  }
411
411
  let data;
412
412
  while ((data = response.read()) !== null) {
413
- this._downloadedSize += data.length;
413
+ this._downloadedSize += data.length; // eslint-disable-line @typescript-eslint/restrict-plus-operands
414
414
  const progress = this.downloadProgress;
415
415
  if (progress.percent < 1) {
416
416
  this.emit('downloadProgress', progress);
@@ -1117,7 +1117,6 @@ export default class Request extends Duplex {
1117
1117
  return this._isFromCache;
1118
1118
  }
1119
1119
  get reusedSocket() {
1120
- // @ts-expect-error `@types/node` has incomplete types
1121
1120
  return this._request?.reusedSocket;
1122
1121
  }
1123
1122
  }
@@ -151,13 +151,13 @@ const defaultInternals = {
151
151
  responseType: 'text',
152
152
  url: undefined,
153
153
  pagination: {
154
- transform: (response) => {
154
+ transform(response) {
155
155
  if (response.request.options.responseType === 'json') {
156
156
  return response.body;
157
157
  }
158
158
  return JSON.parse(response.body);
159
159
  },
160
- paginate: ({ response }) => {
160
+ paginate({ response }) {
161
161
  const rawLinkHeader = response.headers.link;
162
162
  if (typeof rawLinkHeader !== 'string' || rawLinkHeader.trim() === '') {
163
163
  return false;
@@ -23,7 +23,7 @@ export const parseBody = (response, responseType, parseJson, encoding) => {
23
23
  return rawBody.toString(encoding);
24
24
  }
25
25
  if (responseType === 'json') {
26
- return rawBody.length === 0 ? '' : parseJson(rawBody.toString());
26
+ return rawBody.length === 0 ? '' : parseJson(rawBody.toString(encoding));
27
27
  }
28
28
  if (responseType === 'buffer') {
29
29
  return rawBody;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "got",
3
- "version": "12.0.1",
3
+ "version": "12.0.2",
4
4
  "description": "Human-friendly and powerful HTTP request library for Node.js",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/got",
@@ -44,7 +44,7 @@
44
44
  "ky"
45
45
  ],
46
46
  "dependencies": {
47
- "@sindresorhus/is": "^4.2.0",
47
+ "@sindresorhus/is": "^4.6.0",
48
48
  "@szmarczak/http-timer": "^5.0.1",
49
49
  "@types/cacheable-request": "^6.0.2",
50
50
  "@types/responselike": "^1.0.0",
@@ -53,7 +53,7 @@
53
53
  "decompress-response": "^6.0.0",
54
54
  "form-data-encoder": "1.7.1",
55
55
  "get-stream": "^6.0.1",
56
- "http2-wrapper": "^2.1.9",
56
+ "http2-wrapper": "^2.1.10",
57
57
  "lowercase-keys": "^3.0.0",
58
58
  "p-cancelable": "^3.0.0",
59
59
  "responselike": "^2.0.0"
@@ -61,47 +61,47 @@
61
61
  "devDependencies": {
62
62
  "@hapi/bourne": "^2.0.0",
63
63
  "@sindresorhus/tsconfig": "^2.0.0",
64
- "@sinonjs/fake-timers": "^8.1.0",
64
+ "@sinonjs/fake-timers": "^9.1.1",
65
65
  "@types/benchmark": "^2.1.1",
66
66
  "@types/express": "^4.17.13",
67
- "@types/node": "^16.11.12",
67
+ "@types/node": "^17.0.21",
68
68
  "@types/pem": "^1.9.6",
69
69
  "@types/pify": "^5.0.1",
70
- "@types/readable-stream": "^2.3.12",
71
- "@types/request": "^2.48.7",
72
- "@types/sinon": "^10.0.6",
70
+ "@types/readable-stream": "^2.3.13",
71
+ "@types/request": "^2.48.8",
72
+ "@types/sinon": "^10.0.11",
73
73
  "@types/sinonjs__fake-timers": "^8.1.1",
74
74
  "@types/tough-cookie": "^4.0.1",
75
75
  "ava": "^3.15.0",
76
- "axios": "^0.24.0",
76
+ "axios": "^0.26.1",
77
77
  "benchmark": "^2.1.4",
78
78
  "bluebird": "^3.7.2",
79
- "body-parser": "^1.19.0",
79
+ "body-parser": "^1.19.2",
80
80
  "create-cert": "^1.0.6",
81
81
  "create-test-server": "^3.0.1",
82
82
  "del-cli": "^4.0.1",
83
83
  "delay": "^5.0.0",
84
- "express": "^4.17.1",
84
+ "express": "^4.17.3",
85
85
  "form-data": "^4.0.0",
86
- "formdata-node": "^4.3.1",
87
- "nock": "^13.2.1",
88
- "node-fetch": "^3.1.0",
86
+ "formdata-node": "^4.3.2",
87
+ "nock": "^13.2.4",
88
+ "node-fetch": "^3.2.3",
89
89
  "np": "^7.6.0",
90
90
  "nyc": "^15.1.0",
91
91
  "p-event": "^5.0.1",
92
- "pem": "^1.14.4",
92
+ "pem": "^1.14.6",
93
93
  "pify": "^5.0.0",
94
94
  "readable-stream": "^3.6.0",
95
95
  "request": "^2.88.2",
96
- "sinon": "^12.0.1",
96
+ "sinon": "^13.0.1",
97
97
  "slow-stream": "0.0.4",
98
98
  "tempy": "^2.0.0",
99
99
  "then-busboy": "^5.1.1",
100
100
  "to-readable-stream": "^3.0.0",
101
101
  "tough-cookie": "^4.0.0",
102
- "ts-node": "^10.4.0",
103
- "typescript": "4.5.3",
104
- "xo": "^0.47.0"
102
+ "ts-node": "^10.7.0",
103
+ "typescript": "4.6.2",
104
+ "xo": "^0.48.0"
105
105
  },
106
106
  "types": "dist/source",
107
107
  "sideEffects": false,
package/readme.md CHANGED
@@ -70,9 +70,11 @@ For browser usage, we recommend [Ky](https://github.com/sindresorhus/ky) by the
70
70
 
71
71
  ## Install
72
72
 
73
+ ```sh
74
+ npm install got
73
75
  ```
74
- $ npm install got
75
- ```
76
+
77
+ **Warning:** This package is native [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and no longer provides a CommonJS export. If your project uses CommonJS, you'll have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function. Please don't open issues for questions regarding CommonJS / ESM. You can also use [Got v11](https://github.com/sindresorhus/got/tree/v11.8.3) instead which is pretty stable.
76
78
 
77
79
  ## Take a peek
78
80