Skip to content

Commit 53513ce

Browse files
committed
Upgrade dependencies
1 parent d95ceea commit 53513ce

17 files changed

+110
-109
lines changed

benchmark/index.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ const suite = new Benchmark.Suite();
6666
// Benchmarking
6767
suite.add('got - promise', {
6868
defer: true,
69-
fn: async (deferred: {resolve: () => void}) => {
69+
async fn(deferred: {resolve: () => void}) {
7070
await got(url, gotOptions);
7171
deferred.resolve();
7272
},
7373
}).add('got - stream', {
7474
defer: true,
75-
fn: async (deferred: {resolve: () => void}) => {
75+
async fn(deferred: {resolve: () => void}) {
7676
got.stream(url, gotOptions).resume().once('end', () => {
7777
deferred.resolve();
7878
});
7979
},
8080
}).add('got - core', {
8181
defer: true,
82-
fn: async (deferred: {resolve: () => void}) => {
82+
async fn(deferred: {resolve: () => void}) {
8383
const stream = new Request(url, gotOptions);
8484
void stream.flush();
8585
stream.resume().once('end', () => {
@@ -88,7 +88,7 @@ suite.add('got - promise', {
8888
},
8989
}).add('got - core - normalized options', {
9090
defer: true,
91-
fn: async (deferred: {resolve: () => void}) => {
91+
async fn(deferred: {resolve: () => void}) {
9292
const stream = new Request(undefined, undefined, normalizedGotOptions);
9393
void stream.flush();
9494
stream.resume().once('end', () => {
@@ -97,7 +97,7 @@ suite.add('got - promise', {
9797
},
9898
}).add('request - callback', {
9999
defer: true,
100-
fn: (deferred: {resolve: () => void}) => {
100+
fn(deferred: {resolve: () => void}) {
101101
request(urlString, requestOptions, (error: Error) => {
102102
if (error) {
103103
throw error;
@@ -108,7 +108,7 @@ suite.add('got - promise', {
108108
},
109109
}).add('request - stream', {
110110
defer: true,
111-
fn: (deferred: {resolve: () => void}) => {
111+
fn(deferred: {resolve: () => void}) {
112112
const stream = request(urlString, requestOptions);
113113
stream.resume();
114114
stream.once('end', () => {
@@ -117,15 +117,15 @@ suite.add('got - promise', {
117117
},
118118
}).add('node-fetch - promise', {
119119
defer: true,
120-
fn: async (deferred: {resolve: () => void}) => {
120+
async fn(deferred: {resolve: () => void}) {
121121
const response = await fetch(urlString, fetchOptions);
122122
await response.text();
123123

124124
deferred.resolve();
125125
},
126126
}).add('node-fetch - stream', {
127127
defer: true,
128-
fn: async (deferred: {resolve: () => void}) => {
128+
async fn(deferred: {resolve: () => void}) {
129129
const {body} = await fetch(urlString, fetchOptions);
130130

131131
body!.resume();
@@ -135,13 +135,13 @@ suite.add('got - promise', {
135135
},
136136
}).add('axios - promise', {
137137
defer: true,
138-
fn: async (deferred: {resolve: () => void}) => {
138+
async fn(deferred: {resolve: () => void}) {
139139
await axios.request(axiosOptions);
140140
deferred.resolve();
141141
},
142142
}).add('axios - stream', {
143143
defer: true,
144-
fn: async (deferred: {resolve: () => void}) => {
144+
async fn(deferred: {resolve: () => void}) {
145145
const result = await axios.request(axiosStreamOptions);
146146
const {data}: any = result;
147147

@@ -152,7 +152,7 @@ suite.add('got - promise', {
152152
},
153153
}).add('https - stream', {
154154
defer: true,
155-
fn: (deferred: {resolve: () => void}) => {
155+
fn(deferred: {resolve: () => void}) {
156156
https.request(urlString, httpsOptions, response => {
157157
response.resume();
158158
response.once('end', () => {
@@ -173,7 +173,7 @@ const internalBenchmark = (): void => {
173173

174174
const internalSuite = new Benchmark.Suite();
175175
internalSuite.add('got - normalize options', {
176-
fn: () => {
176+
fn() {
177177
// eslint-disable-next-line no-new
178178
new Options(url, gotOptions);
179179
},

package.json

+18-18
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"ky"
4545
],
4646
"dependencies": {
47-
"@sindresorhus/is": "^4.2.0",
47+
"@sindresorhus/is": "^4.6.0",
4848
"@szmarczak/http-timer": "^5.0.1",
4949
"@types/cacheable-request": "^6.0.2",
5050
"@types/responselike": "^1.0.0",
@@ -53,55 +53,55 @@
5353
"decompress-response": "^6.0.0",
5454
"form-data-encoder": "1.7.1",
5555
"get-stream": "^6.0.1",
56-
"http2-wrapper": "^2.1.9",
56+
"http2-wrapper": "^2.1.10",
5757
"lowercase-keys": "^3.0.0",
5858
"p-cancelable": "^3.0.0",
5959
"responselike": "^2.0.0"
6060
},
6161
"devDependencies": {
6262
"@hapi/bourne": "^2.0.0",
6363
"@sindresorhus/tsconfig": "^2.0.0",
64-
"@sinonjs/fake-timers": "^8.1.0",
64+
"@sinonjs/fake-timers": "^9.1.1",
6565
"@types/benchmark": "^2.1.1",
6666
"@types/express": "^4.17.13",
67-
"@types/node": "^16.11.12",
67+
"@types/node": "^17.0.21",
6868
"@types/pem": "^1.9.6",
6969
"@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",
7373
"@types/sinonjs__fake-timers": "^8.1.1",
7474
"@types/tough-cookie": "^4.0.1",
7575
"ava": "^3.15.0",
76-
"axios": "^0.24.0",
76+
"axios": "^0.26.1",
7777
"benchmark": "^2.1.4",
7878
"bluebird": "^3.7.2",
79-
"body-parser": "^1.19.0",
79+
"body-parser": "^1.19.2",
8080
"create-cert": "^1.0.6",
8181
"create-test-server": "^3.0.1",
8282
"del-cli": "^4.0.1",
8383
"delay": "^5.0.0",
84-
"express": "^4.17.1",
84+
"express": "^4.17.3",
8585
"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",
8989
"np": "^7.6.0",
9090
"nyc": "^15.1.0",
9191
"p-event": "^5.0.1",
92-
"pem": "^1.14.4",
92+
"pem": "^1.14.6",
9393
"pify": "^5.0.0",
9494
"readable-stream": "^3.6.0",
9595
"request": "^2.88.2",
96-
"sinon": "^12.0.1",
96+
"sinon": "^13.0.1",
9797
"slow-stream": "0.0.4",
9898
"tempy": "^2.0.0",
9999
"then-busboy": "^5.1.1",
100100
"to-readable-stream": "^3.0.0",
101101
"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"
105105
},
106106
"types": "dist/source",
107107
"sideEffects": false,

source/core/index.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,9 @@ export default class Request extends Duplex implements RequestEvents<Request> {
448448
}
449449

450450
let data;
451+
451452
while ((data = response.read()) !== null) {
452-
this._downloadedSize += data.length;
453+
this._downloadedSize += data.length; // eslint-disable-line @typescript-eslint/restrict-plus-operands
453454

454455
const progress = this.downloadProgress;
455456

@@ -462,7 +463,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
462463
}
463464
}
464465

465-
override _write(chunk: unknown, encoding: BufferEncoding | undefined, callback: (error?: Error | null) => void): void {
466+
override _write(chunk: unknown, encoding: BufferEncoding | undefined, callback: (error?: Error | null) => void): void { // eslint-disable-line @typescript-eslint/ban-types
466467
const write = (): void => {
467468
this._writeRequest(chunk, encoding, callback);
468469
};
@@ -474,7 +475,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
474475
}
475476
}
476477

477-
override _final(callback: (error?: Error | null) => void): void {
478+
override _final(callback: (error?: Error | null) => void): void { // eslint-disable-line @typescript-eslint/ban-types
478479
const endRequest = (): void => {
479480
// We need to check if `this._request` is present,
480481
// because it isn't when we use cache.
@@ -483,7 +484,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
483484
return;
484485
}
485486

486-
this._request.end((error?: Error | null) => {
487+
this._request.end((error?: Error | null) => { // eslint-disable-line @typescript-eslint/ban-types
487488
// The request has been destroyed before `_final` finished.
488489
// See https://github.com/nodejs/node/issues/39356
489490
if ((this._request as any)._writableState?.errored) {
@@ -508,7 +509,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
508509
}
509510
}
510511

511-
override _destroy(error: Error | null, callback: (error: Error | null) => void): void {
512+
override _destroy(error: Error | null, callback: (error: Error | null) => void): void { // eslint-disable-line @typescript-eslint/ban-types
512513
this._stopReading = true;
513514
this.flush = async () => {};
514515

@@ -1186,13 +1187,13 @@ export default class Request extends Duplex implements RequestEvents<Request> {
11861187
this.destroy(error);
11871188
}
11881189

1189-
private _writeRequest(chunk: any, encoding: BufferEncoding | undefined, callback: (error?: Error | null) => void): void {
1190+
private _writeRequest(chunk: any, encoding: BufferEncoding | undefined, callback: (error?: Error | null) => void): void { // eslint-disable-line @typescript-eslint/ban-types
11901191
if (!this._request || this._request.destroyed) {
11911192
// Probably the `ClientRequest` instance will throw
11921193
return;
11931194
}
11941195

1195-
this._request.write(chunk, encoding!, (error?: Error | null) => {
1196+
this._request.write(chunk, encoding!, (error?: Error | null) => { // eslint-disable-line @typescript-eslint/ban-types
11961197
if (!error) {
11971198
this._uploadedSize += Buffer.byteLength(chunk, encoding);
11981199

source/core/options.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ export interface Agents {
5656
export type Headers = Record<string, string | string[] | undefined>;
5757

5858
export interface ToughCookieJar {
59-
getCookieString: ((currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookies: string) => void) => void)
60-
& ((url: string, callback: (error: Error | null, cookieHeader: string) => void) => void);
61-
setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookie: unknown) => void) => void)
62-
& ((rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void) => void);
59+
getCookieString: ((currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookies: string) => void) => void) // eslint-disable-line @typescript-eslint/ban-types
60+
& ((url: string, callback: (error: Error | null, cookieHeader: string) => void) => void); // eslint-disable-line @typescript-eslint/ban-types
61+
setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookie: unknown) => void) => void) // eslint-disable-line @typescript-eslint/ban-types
62+
& ((rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void) => void); // eslint-disable-line @typescript-eslint/ban-types
6363
}
6464

6565
export interface PromiseCookieJar {
@@ -621,9 +621,9 @@ export interface PaginationOptions<ElementType, BodyType> {
621621
stackAllItems?: boolean;
622622
}
623623

624-
export type SearchParameters = Record<string, string | number | boolean | null | undefined>;
624+
export type SearchParameters = Record<string, string | number | boolean | null | undefined>; // eslint-disable-line @typescript-eslint/ban-types
625625

626-
function validateSearchParameters(searchParameters: Record<string, unknown>): asserts searchParameters is Record<string, string | number | boolean | null | undefined> {
626+
function validateSearchParameters(searchParameters: Record<string, unknown>): asserts searchParameters is Record<string, string | number | boolean | null | undefined> { // eslint-disable-line @typescript-eslint/ban-types
627627
// eslint-disable-next-line guard-for-in
628628
for (const key in searchParameters) {
629629
const value = searchParameters[key];
@@ -794,14 +794,14 @@ const defaultInternals: Options['_internals'] = {
794794
responseType: 'text',
795795
url: undefined,
796796
pagination: {
797-
transform: (response: Response) => {
797+
transform(response: Response) {
798798
if (response.request.options.responseType === 'json') {
799799
return response.body;
800800
}
801801

802802
return JSON.parse(response.body as string);
803803
},
804-
paginate: ({response}) => {
804+
paginate({response}) {
805805
const rawLinkHeader = response.headers.link;
806806
if (typeof rawLinkHeader !== 'string' || rawLinkHeader.trim() === '') {
807807
return false;

source/core/utils/is-form-data.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import is from '@sindresorhus/is';
33

44
interface FormData extends Readable {
55
getBoundary: () => string;
6-
getLength: (callback: (error: Error | null, length: number) => void) => void;
6+
getLength: (callback: (error: Error | null, length: number) => void) => void; // eslint-disable-line @typescript-eslint/ban-types
77
}
88

99
export default function isFormData(body: unknown): body is FormData {

source/core/utils/url-to-options.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export interface LegacyUrlOptions {
77
protocol: string;
88
hostname: string;
99
host: string;
10-
hash: string | null;
11-
search: string | null;
10+
hash: string | null; // eslint-disable-line @typescript-eslint/ban-types
11+
search: string | null; // eslint-disable-line @typescript-eslint/ban-types
1212
pathname: string;
1313
href: string;
1414
path: string;

test/cancel.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ test.serial('does not retry after cancelation', withServerAndFakeTimers, async (
6868

6969
const gotPromise = got('redirect', {
7070
retry: {
71-
calculateDelay: () => {
71+
calculateDelay() {
7272
t.fail('Makes a new try after cancelation');
7373
return 0;
7474
},
@@ -94,7 +94,7 @@ test.serial('cleans up request timeouts', withServer, async (t, server, got) =>
9494
request: 10,
9595
},
9696
retry: {
97-
calculateDelay: ({computedValue}) => {
97+
calculateDelay({computedValue}) {
9898
process.nextTick(() => {
9999
gotPromise.cancel();
100100
});

test/cookies.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ test('does not throw on invalid cookies when options.ignoreInvalidCookies is set
8686
test('catches store errors', async t => {
8787
const error = 'Some error';
8888
const cookieJar = new toughCookie.CookieJar({
89-
findCookies: (_, __, ___, callback) => {
89+
findCookies(_, __, ___, callback) {
9090
callback(new Error(error), []);
9191
},
92-
findCookie: () => {},
93-
getAllCookies: () => {},
94-
putCookie: () => {},
95-
removeCookies: () => {},
96-
removeCookie: () => {},
97-
updateCookie: () => {},
92+
findCookie() {},
93+
getAllCookies() {},
94+
putCookie() {},
95+
removeCookies() {},
96+
removeCookie() {},
97+
updateCookie() {},
9898
synchronous: false,
9999
});
100100

@@ -132,8 +132,8 @@ test('no unhandled errors', async t => {
132132

133133
const options = {
134134
cookieJar: {
135-
setCookie: async (_rawCookie: string, _url: string) => {},
136-
getCookieString: async (_url: string) => {
135+
async setCookie(_rawCookie: string, _url: string) {},
136+
async getCookieString(_url: string) {
137137
throw new Error(message);
138138
},
139139
},
@@ -183,7 +183,7 @@ test('throws on invalid `options.cookieJar.setCookie`', async t => {
183183
test('throws on invalid `options.cookieJar.getCookieString`', async t => {
184184
await t.throwsAsync(got('https://example.com', {
185185
cookieJar: {
186-
setCookie: async () => {},
186+
async setCookie() {},
187187
// @ts-expect-error Error tests
188188
getCookieString: 123,
189189
},

0 commit comments

Comments
 (0)