Skip to content

Commit f65c9ef

Browse files
committedOct 20, 2020
Upgrade dependencies
1 parent 7acd380 commit f65c9ef

File tree

7 files changed

+27
-31
lines changed

7 files changed

+27
-31
lines changed
 

‎package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"ky"
4444
],
4545
"dependencies": {
46-
"@sindresorhus/is": "^3.1.1",
46+
"@sindresorhus/is": "^4.0.0",
4747
"@szmarczak/http-timer": "^4.0.5",
4848
"@types/cacheable-request": "^6.0.1",
4949
"@types/responselike": "^1.0.0",
@@ -61,7 +61,7 @@
6161
"@sinonjs/fake-timers": "^6.0.1",
6262
"@types/benchmark": "^1.0.33",
6363
"@types/express": "^4.17.7",
64-
"@types/node": "^14.6.0",
64+
"@types/node": "^14.14.0",
6565
"@types/node-fetch": "^2.5.7",
6666
"@types/pem": "^1.9.5",
6767
"@types/pify": "^3.0.2",
@@ -87,11 +87,11 @@
8787
"pify": "^5.0.0",
8888
"sinon": "^9.0.3",
8989
"slow-stream": "0.0.4",
90-
"tempy": "^0.6.0",
90+
"tempy": "^1.0.0",
9191
"to-readable-stream": "^2.1.0",
9292
"tough-cookie": "^4.0.0",
93-
"typescript": "^4.0.2",
94-
"xo": "^0.33.0"
93+
"typescript": "4.0.3",
94+
"xo": "^0.34.1"
9595
},
9696
"types": "dist/source",
9797
"sideEffects": false,
@@ -123,7 +123,7 @@
123123
"node/prefer-global/url": "off",
124124
"node/prefer-global/url-search-params": "off",
125125
"import/no-anonymous-default-export": "off",
126-
"@typescript-eslint/no-invalid-void-type": "off"
126+
"@typescript-eslint/no-implicit-any-catch": "off"
127127
}
128128
},
129129
"runkitExampleFilename": "./documentation/examples/runkit-example.js"

‎source/core/index.ts

+11-15
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ export interface Agents {
6666
export const withoutBody: ReadonlySet<string> = new Set(['GET', 'HEAD']);
6767

6868
export interface ToughCookieJar {
69-
getCookieString: ((currentUrl: string, options: {[key: string]: unknown}, cb: (err: Error | null, cookies: string) => void) => void)
69+
getCookieString: ((currentUrl: string, options: Record<string, unknown>, cb: (err: Error | null, cookies: string) => void) => void)
7070
& ((url: string, callback: (error: Error | null, cookieHeader: string) => void) => void);
71-
setCookie: ((cookieOrString: unknown, currentUrl: string, options: {[key: string]: unknown}, cb: (err: Error | null, cookie: unknown) => void) => void)
71+
setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, cb: (err: Error | null, cookie: unknown) => void) => void)
7272
& ((rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void) => void);
7373
}
7474

@@ -250,7 +250,7 @@ export type RequestFunction = (url: URL, options: RequestOptions, callback?: (re
250250
export type Headers = Record<string, string | string[] | undefined>;
251251

252252
type CacheableRequestFunction = (
253-
opts: string | URL | RequestOptions,
253+
options: string | URL | RequestOptions,
254254
cb?: (response: ServerResponse | ResponseLike) => void
255255
) => CacheableRequest.Emitter;
256256

@@ -436,7 +436,7 @@ interface PlainOptions extends URLOptions {
436436
437437
__Note #2__: This option is not enumerable and will not be merged with the instance defaults.
438438
*/
439-
form?: {[key: string]: any};
439+
form?: Record<string, any>;
440440

441441
/**
442442
JSON body. If the `Content-Type` header is not set, it will be set to `application/json`.
@@ -445,7 +445,7 @@ interface PlainOptions extends URLOptions {
445445
446446
__Note #2__: This option is not enumerable and will not be merged with the instance defaults.
447447
*/
448-
json?: {[key: string]: any};
448+
json?: Record<string, any>;
449449

450450
/**
451451
The URL to request, as a string, a [`https.request` options object](https://nodejs.org/api/https.html#https_https_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url).
@@ -500,7 +500,7 @@ interface PlainOptions extends URLOptions {
500500
//=> 'key=a&key=b'
501501
```
502502
*/
503-
searchParams?: string | {[key: string]: string | number | boolean | null | undefined} | URLSearchParams;
503+
searchParams?: string | Record<string, string | number | boolean | null | undefined> | URLSearchParams;
504504

505505
/**
506506
An instance of [`CacheableLookup`](https://github.com/szmarczak/cacheable-lookup) used for making DNS lookups.
@@ -1805,7 +1805,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
18051805
for (const event of knownHookEvents) {
18061806
const defaultHooks = defaults.hooks[event];
18071807

1808-
if (defaultHooks.length !== 0) {
1808+
if (defaultHooks.length > 0) {
18091809
// See https://github.com/microsoft/TypeScript/issues/31445#issuecomment-576929044
18101810
(options.hooks as any)[event] = [
18111811
...defaults.hooks[event],
@@ -2206,11 +2206,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
22062206
// Node.js <= 12.18.2 mistakenly emits the response `end` first.
22072207
(request as ClientRequest & {res: IncomingMessage | undefined}).res?.removeAllListeners('end');
22082208

2209-
if (error instanceof TimedOutTimeoutError) {
2210-
error = new TimeoutError(error, this.timings!, this);
2211-
} else {
2212-
error = new RequestError(error.message, error, this);
2213-
}
2209+
error = error instanceof TimedOutTimeoutError ? new TimeoutError(error, this.timings!, this) : new RequestError(error.message, error, this);
22142210

22152211
this._beforeError(error as RequestError);
22162212
});
@@ -2652,7 +2648,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
26522648
// TODO: What happens if it's from cache? Then this[kRequest] won't be defined.
26532649

26542650
this[kRequest]!.write(chunk, encoding!, (error?: Error | null) => {
2655-
if (!error && this._progressCallbacks.length !== 0) {
2651+
if (!error && this._progressCallbacks.length > 0) {
26562652
this._progressCallbacks.shift()!();
26572653
}
26582654

@@ -2729,7 +2725,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
27292725
The remote IP address.
27302726
*/
27312727
get ip(): string | undefined {
2732-
return this[kRequest]?.socket.remoteAddress;
2728+
return this.socket?.remoteAddress;
27332729
}
27342730

27352731
/**
@@ -2740,7 +2736,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
27402736
}
27412737

27422738
get socket(): Socket | undefined {
2743-
return this[kRequest]?.socket;
2739+
return this[kRequest]?.socket ?? undefined;
27442740
}
27452741

27462742
/**

‎source/core/utils/proxy-events.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {EventEmitter} from 'events';
22

33
type Fn = (...args: unknown[]) => void;
4-
type Fns = {[key: string]: Fn};
4+
type Fns = Record<string, Fn>;
55

66
export default function (from: EventEmitter, to: EventEmitter, events: string[]): () => void {
77
const fns: Fns = {};

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default (url: URL | UrlWithStringQuery): LegacyUrlOptions => {
3131
path: `${url.pathname || ''}${url.search || ''}`
3232
};
3333

34-
if (is.string(url.port) && url.port.length !== 0) {
34+
if (is.string(url.port) && url.port.length > 0) {
3535
options.port = Number(url.port);
3636
}
3737

‎test/create.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ test('ability to pass a custom request method', withServer, async (t, server, go
193193

194194
const request: RequestFunction = (...args: [
195195
string | URL | RequestOptions,
196-
(RequestOptions | ((res: IncomingMessage) => void))?,
197-
((res: IncomingMessage) => void)?
196+
(RequestOptions | ((response: IncomingMessage) => void))?,
197+
((response: IncomingMessage) => void)?
198198
]) => {
199199
isCalled = true;
200200
// @ts-expect-error Overload error
@@ -214,8 +214,8 @@ test('does not include the `request` option in normalized `http` options', withS
214214

215215
const request: RequestFunction = (...args: [
216216
string | URL | RequestOptions,
217-
(RequestOptions | ((res: IncomingMessage) => void))?,
218-
((res: IncomingMessage) => void)?
217+
(RequestOptions | ((response: IncomingMessage) => void))?,
218+
((response: IncomingMessage) => void)?
219219
]) => {
220220
isCalled = true;
221221

‎test/retry.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ test('works on timeout', withServer, async (t, server, got) => {
4646
},
4747
request: (...args: [
4848
string | URL | http.RequestOptions,
49-
(http.RequestOptions | ((res: http.IncomingMessage) => void))?,
50-
((res: http.IncomingMessage) => void)?
49+
(http.RequestOptions | ((response: http.IncomingMessage) => void))?,
50+
((response: http.IncomingMessage) => void)?
5151
]) => {
5252
if (knocks === 1) {
5353
// @ts-expect-error Overload error
@@ -413,7 +413,7 @@ test('does not destroy the socket on HTTP error', withServer, async (t, server,
413413
http: agent
414414
}
415415
}).on('request', request => {
416-
sockets.push(request.socket);
416+
sockets.push(request.socket!);
417417
});
418418

419419
t.is(sockets.length, 2);

‎test/timeout.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ test.serial('no unhandled timeout errors', withServer, async (t, _server, got) =
444444
const result = http.request(...args);
445445

446446
result.once('socket', () => {
447-
result.socket.destroy();
447+
result.socket?.destroy();
448448
});
449449

450450
return result;

0 commit comments

Comments
 (0)
Please sign in to comment.