Skip to content

Commit 81447e9

Browse files
committed
Tweaks
1 parent 852c312 commit 81447e9

39 files changed

+103
-108
lines changed

.github/workflows/main.yml

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
node-version:
1515
- 18
1616
- 16
17-
- 14
1817
os:
1918
# Ubuntu fails and I don't have time to look into it. PR welcome.
2019
# - ubuntu-latest

documentation/2-options.md

-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ await got('https://httpbin.org/anything');
215215

216216
You can abort the `request` using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
217217

218-
*Requires Node.js 16 or later.*
219-
220218
```js
221219
import got from 'got';
222220

documentation/tips.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ If you're using proxies, you may run into connection issues.\
176176
One way out is to disable proxies when retrying. The solution for the Stream API looks like this:
177177

178178
```js
179-
import https from 'https';
180-
import fs from 'fs';
179+
import https from 'node:https';
180+
import fs from 'node:fs';
181181
import got from 'got';
182182

183183
class MyAgent extends https.Agent {

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@
138138
"@typescript-eslint/no-empty-function": "off",
139139
"n/no-deprecated-api": "off",
140140
"@typescript-eslint/no-implicit-any-catch": "off",
141-
"unicorn/prefer-node-protocol": "off",
142141
"ava/assertion-arguments": "off",
143142
"@typescript-eslint/no-unsafe-member-access": "off",
144143
"@typescript-eslint/no-unsafe-return": "off",

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ npm install got
9494

9595
**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 will 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.
9696

97-
**Got v11 (the previous major version) is no longer maintained and we will not accept any backport requests.**
97+
**Got v11 is no longer maintained and we will not accept any backport requests.**
9898

9999
## Take a peek
100100

source/core/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ export default class Request extends Duplex implements RequestEvents<Request> {
276276
abort();
277277
} else {
278278
this.options.signal.addEventListener('abort', abort);
279+
279280
this._removeListeners = () => {
280-
this.options.signal.removeEventListener('abort', abort);
281+
this.options.signal?.removeEventListener('abort', abort);
281282
};
282283
}
283284
}

source/core/options.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1499,8 +1499,6 @@ export default class Options {
14991499
/**
15001500
You can abort the `request` using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
15011501
1502-
*Requires Node.js 16 or later.*
1503-
15041502
@example
15051503
```
15061504
import got from 'got';
@@ -1516,13 +1514,11 @@ export default class Options {
15161514
}, 100);
15171515
```
15181516
*/
1519-
// TODO: Replace `any` with `AbortSignal` when targeting Node 16.
1520-
get signal(): any | undefined {
1517+
get signal(): AbortSignal | undefined {
15211518
return this._internals.signal;
15221519
}
15231520

1524-
// TODO: Replace `any` with `AbortSignal` when targeting Node 16.
1525-
set signal(value: any | undefined) {
1521+
set signal(value: AbortSignal | undefined) {
15261522
assert.object(value);
15271523

15281524
this._internals.signal = value;

test/abort.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import process from 'process';
2-
import {EventEmitter} from 'events';
3-
import {Readable as ReadableStream} from 'stream';
4-
import {pipeline as streamPipeline} from 'stream/promises';
1+
import process from 'node:process';
2+
import {EventEmitter} from 'node:events';
3+
import {Readable as ReadableStream} from 'node:stream';
4+
import {pipeline as streamPipeline} from 'node:stream/promises';
55
import test from 'ava';
66
import delay from 'delay';
77
import {pEvent} from 'p-event';

test/agent.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Agent as HttpAgent} from 'http';
2-
import {Agent as HttpsAgent} from 'https';
1+
import {Agent as HttpAgent} from 'node:http';
2+
import {Agent as HttpsAgent} from 'node:https';
33
import test from 'ava';
44
import sinon from 'sinon';
55
import type {Constructor} from 'type-fest';

test/arguments.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {parse} from 'url';
1+
import {parse} from 'node:url';
22
import test from 'ava';
33
import type {Handler} from 'express';
44
import {pEvent} from 'p-event';

test/cache.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {Buffer} from 'buffer';
2-
import {promisify} from 'util';
3-
import {Readable as ReadableStream} from 'stream';
4-
import {Agent} from 'http';
5-
import {gzip} from 'zlib';
6-
import process from 'process';
1+
import {Buffer} from 'node:buffer';
2+
import {promisify} from 'node:util';
3+
import {Readable as ReadableStream} from 'node:stream';
4+
import {Agent} from 'node:http';
5+
import {gzip} from 'node:zlib';
6+
import process from 'node:process';
77
import test from 'ava';
88
import {pEvent} from 'p-event';
99
import getStream from 'get-stream';
@@ -561,7 +561,8 @@ test.failing('revalidated compressed responses are retrieved from cache', withSe
561561
});
562562
});
563563

564-
test.failing('revalidated uncompressed responses from github are retrieved from cache', async t => {
564+
// eslint-disable-next-line ava/no-skip-test -- Unreliable
565+
test.skip('revalidated uncompressed responses from github are retrieved from cache', async t => {
565566
const client = got.extend({
566567
cache: new Map(),
567568
cacheOptions: {shared: false},
@@ -590,7 +591,8 @@ test.failing('revalidated uncompressed responses from github are retrieved from
590591
});
591592
});
592593

593-
test.failing('revalidated compressed responses from github are retrieved from cache', async t => {
594+
// eslint-disable-next-line ava/no-skip-test -- Unreliable
595+
test.skip('revalidated compressed responses from github are retrieved from cache', async t => {
594596
const client = got.extend({
595597
cache: new Map(),
596598
cacheOptions: {shared: false},

test/cancel.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import process from 'process';
2-
import {EventEmitter} from 'events';
3-
import {Readable as ReadableStream} from 'stream';
4-
import {pipeline as streamPipeline} from 'stream/promises';
1+
import process from 'node:process';
2+
import {EventEmitter} from 'node:events';
3+
import {Readable as ReadableStream} from 'node:stream';
4+
import {pipeline as streamPipeline} from 'node:stream/promises';
55
import test from 'ava';
66
import delay from 'delay';
77
import {pEvent} from 'p-event';

test/cookies.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import net from 'net';
1+
import net from 'node:net';
22
import test from 'ava';
33
import toughCookie from 'tough-cookie';
44
import delay from 'delay';

test/create.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
request as httpRequest,
44
type IncomingMessage,
55
type RequestOptions,
6-
} from 'http';
6+
} from 'node:http';
77
import test from 'ava';
88
import is from '@sindresorhus/is';
99
import type {Handler} from 'express';

test/encoding.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Buffer} from 'buffer';
1+
import {Buffer} from 'node:buffer';
22
import test from 'ava';
33
import withServer from './helpers/with-server.js';
44

test/error.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {Buffer} from 'buffer';
2-
import {promisify} from 'util';
3-
import net from 'net';
4-
import http from 'http';
5-
import stream from 'stream';
6-
import {pipeline as streamPipeline} from 'stream/promises';
1+
import {Buffer} from 'node:buffer';
2+
import {promisify} from 'node:util';
3+
import net from 'node:net';
4+
import http from 'node:http';
5+
import stream from 'node:stream';
6+
import {pipeline as streamPipeline} from 'node:stream/promises';
77
import test from 'ava';
88
import getStream from 'get-stream';
99
import is from '@sindresorhus/is';

test/gzip.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {Buffer} from 'buffer';
2-
import {promisify} from 'util';
3-
import zlib from 'zlib';
1+
import {Buffer} from 'node:buffer';
2+
import {promisify} from 'node:util';
3+
import zlib from 'node:zlib';
44
import test from 'ava';
55
import getStream from 'get-stream';
66
import {ReadError, type HTTPError} from '../source/index.js';

test/headers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import process from 'process';
2-
import {Buffer} from 'buffer';
3-
import fs from 'fs';
4-
import path from 'path';
1+
import process from 'node:process';
2+
import {Buffer} from 'node:buffer';
3+
import fs from 'node:fs';
4+
import path from 'node:path';
55
import test from 'ava';
66
import type {Handler} from 'express';
77
import FormData from 'form-data';

test/helpers/create-http-test-server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import http from 'http';
2-
import type net from 'net';
1+
import http from 'node:http';
2+
import type net from 'node:net';
33
import express, {type Express, type NextFunction} from 'express';
44
import pify from 'pify';
55
import bodyParser from 'body-parser';

test/helpers/create-https-test-server.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type {Buffer} from 'buffer';
2-
import https from 'https';
3-
import type net from 'net';
4-
import type {SecureContextOptions} from 'tls';
1+
import type {Buffer} from 'node:buffer';
2+
import https from 'node:https';
3+
import type net from 'node:net';
4+
import type {SecureContextOptions} from 'node:tls';
55
import express from 'express';
66
import pify from 'pify';
77
import pem from 'pem';

test/helpers/slow-data-stream.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Readable} from 'stream';
1+
import {Readable} from 'node:stream';
22
import type {Clock} from '@sinonjs/fake-timers';
33
import delay from 'delay';
44

test/helpers/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {Server} from 'http';
1+
import type {Server} from 'node:http';
22
// @ts-expect-error Fails to locate ../types/create-test-server/index.d.ts
33
import type {TestServer} from 'create-test-server';
44

test/helpers/with-server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import http from 'http';
2-
import {promisify} from 'util';
1+
import http from 'node:http';
2+
import {promisify} from 'node:util';
33
import type {ExecutionContext, Macro} from 'ava';
44
import is from '@sindresorhus/is';
55
import {temporaryFile} from 'tempy';

test/hooks.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Buffer} from 'buffer';
2-
import {Agent as HttpAgent} from 'http';
1+
import {Buffer} from 'node:buffer';
2+
import {Agent as HttpAgent} from 'node:http';
33
import test from 'ava';
44
import nock from 'nock';
55
import getStream from 'get-stream';

test/http.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import process from 'process';
2-
import {Buffer} from 'buffer';
3-
import {STATUS_CODES, Agent} from 'http';
4-
import os from 'os';
5-
import {isIPv4, isIPv6, isIP} from 'net';
1+
import process from 'node:process';
2+
import {Buffer} from 'node:buffer';
3+
import {STATUS_CODES, Agent} from 'node:http';
4+
import os from 'node:os';
5+
import {isIPv4, isIPv6, isIP} from 'node:net';
66
import test from 'ava';
77
import type {Handler} from 'express';
88
import nock from 'nock';

test/https.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import process from 'process';
2-
import tls, {type DetailedPeerCertificate} from 'tls';
1+
import process from 'node:process';
2+
import tls, {type DetailedPeerCertificate} from 'node:tls';
33
import test from 'ava';
44
import {pEvent} from 'p-event';
55
import pify from 'pify';

test/pagination.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Buffer} from 'buffer';
1+
import {Buffer} from 'node:buffer';
22
import test from 'ava';
33
import delay from 'delay';
44
import getStream from 'get-stream';

test/post.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import process from 'process';
2-
import {Buffer} from 'buffer';
3-
import stream from 'stream';
4-
import {pipeline as streamPipeline} from 'stream/promises';
5-
import fs from 'fs';
6-
import fsPromises from 'fs/promises';
7-
import path from 'path';
1+
import process from 'node:process';
2+
import {Buffer} from 'node:buffer';
3+
import stream from 'node:stream';
4+
import {pipeline as streamPipeline} from 'node:stream/promises';
5+
import fs from 'node:fs';
6+
import fsPromises from 'node:fs/promises';
7+
import path from 'node:path';
88
import test from 'ava';
99
import delay from 'delay';
1010
import {pEvent} from 'p-event';

test/progress.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import process from 'process';
2-
import {Buffer} from 'buffer';
3-
import {promisify} from 'util';
4-
import stream from 'stream';
1+
import process from 'node:process';
2+
import {Buffer} from 'node:buffer';
3+
import {promisify} from 'node:util';
4+
import stream from 'node:stream';
55
import {pipeline as streamPipeline} from 'node:stream/promises';
6-
import fs from 'fs';
6+
import fs from 'node:fs';
77
// @ts-expect-error Fails to find slow-stream/index.d.ts
88
import SlowStream from 'slow-stream';
99
import getStream from 'get-stream';

test/promise.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {Buffer} from 'buffer';
2-
import {ReadStream} from 'fs';
3-
import {ClientRequest, IncomingMessage} from 'http';
1+
import {Buffer} from 'node:buffer';
2+
import {ReadStream} from 'node:fs';
3+
import {ClientRequest, IncomingMessage} from 'node:http';
44
import test from 'ava';
55
import {type Response, CancelError} from '../source/index.js';
66
import withServer from './helpers/with-server.js';

test/redirects.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Buffer} from 'buffer';
1+
import {Buffer} from 'node:buffer';
22
import test from 'ava';
33
import type {Handler} from 'express';
44
import nock from 'nock';

test/response-parse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Buffer} from 'buffer';
1+
import {Buffer} from 'node:buffer';
22
import test from 'ava';
33
import type {Handler} from 'express';
44
import getStream from 'get-stream';

test/retry.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import process from 'process';
2-
import {EventEmitter} from 'events';
3-
import {PassThrough as PassThroughStream} from 'stream';
4-
import type {Socket} from 'net';
5-
import http from 'http';
1+
import process from 'node:process';
2+
import {EventEmitter} from 'node:events';
3+
import {PassThrough as PassThroughStream} from 'node:stream';
4+
import type {Socket} from 'node:net';
5+
import http from 'node:http';
66
import test from 'ava';
77
import is from '@sindresorhus/is';
88
import type {Handler} from 'express';

test/stream.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import process from 'process';
2-
import {Buffer} from 'buffer';
3-
import fs from 'fs';
4-
import {Agent as HttpAgent} from 'http';
5-
import stream, {Readable as ReadableStream, Writable} from 'stream';
6-
import {pipeline as streamPipeline} from 'stream/promises';
1+
import process from 'node:process';
2+
import {Buffer} from 'node:buffer';
3+
import fs from 'node:fs';
4+
import {Agent as HttpAgent} from 'node:http';
5+
import stream, {Readable as ReadableStream, Writable} from 'node:stream';
6+
import {pipeline as streamPipeline} from 'node:stream/promises';
77
import {Readable as Readable2} from 'readable-stream';
88
import test from 'ava';
99
import type {Handler} from 'express';

test/timeout.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import process from 'process';
2-
import {EventEmitter} from 'events';
3-
import stream, {PassThrough as PassThroughStream} from 'stream';
4-
import {pipeline as streamPipeline} from 'stream/promises';
5-
import http from 'http';
6-
import net from 'net';
1+
import process from 'node:process';
2+
import {EventEmitter} from 'node:events';
3+
import stream, {PassThrough as PassThroughStream} from 'node:stream';
4+
import {pipeline as streamPipeline} from 'node:stream/promises';
5+
import http from 'node:http';
6+
import net from 'node:net';
77
import getStream from 'get-stream';
88
import test from 'ava';
99
import delay from 'delay';

test/types/create-test-server/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {Buffer} from 'buffer';
1+
import type {Buffer} from 'node:buffer';
22

33
declare module 'create-test-server' {
44
import type {Express} from 'express';

0 commit comments

Comments
 (0)