got 12.2.0 → 12.4.0

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.
@@ -1,3 +1,3 @@
1
1
  import Request from '../core/index.js';
2
- import type { CancelableRequest } from './types.js';
2
+ import { type CancelableRequest } from './types.js';
3
3
  export default function asPromise<T>(firstRequest?: Request): CancelableRequest<T>;
@@ -128,6 +128,10 @@ export default function asPromise(firstRequest) {
128
128
  emitter.on(event, fn);
129
129
  return promise;
130
130
  };
131
+ promise.off = (event, fn) => {
132
+ emitter.off(event, fn);
133
+ return promise;
134
+ };
131
135
  const shortcut = (responseType) => {
132
136
  const newPromise = (async () => {
133
137
  // Wait until downloading has ended
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import type { Buffer } from 'node:buffer';
3
- import PCancelable from 'p-cancelable';
3
+ import type PCancelable from 'p-cancelable';
4
4
  import { RequestError } from '../core/errors.js';
5
5
  import type Request from '../core/index.js';
6
6
  import type { RequestEvents } from '../core/index.js';
@@ -12,17 +12,15 @@ import type { Socket } from 'node:net';
12
12
  import CacheableRequest from 'cacheable-request';
13
13
  import type { Timings } from '@szmarczak/http-timer';
14
14
  import type ResponseLike from 'responselike';
15
- import Options from './options.js';
16
- import { Response } from './response.js';
15
+ import Options, { type NativeRequestOptions } from './options.js';
16
+ import { type PlainResponse, type Response } from './response.js';
17
17
  import { RequestError } from './errors.js';
18
- import type { PlainResponse } from './response.js';
19
- import type { NativeRequestOptions } from './options.js';
20
18
  declare type Error = NodeJS.ErrnoException;
21
- export interface Progress {
19
+ export declare type Progress = {
22
20
  percent: number;
23
21
  transferred: number;
24
22
  total?: number;
25
- }
23
+ };
26
24
  export declare type GotEventFunction<T> =
27
25
  /**
28
26
  `request` event to get the request object of the request.
@@ -84,10 +82,11 @@ When this event is emitted, you should reset the stream you were writing to and
84
82
  See `got.options.retry` for more information.
85
83
  */
86
84
  & ((name: 'retry', listener: (retryCount: number, error: RequestError) => void) => T);
87
- export interface RequestEvents<T> {
85
+ export declare type RequestEvents<T> = {
88
86
  on: GotEventFunction<T>;
89
87
  once: GotEventFunction<T>;
90
- }
88
+ off: GotEventFunction<T>;
89
+ };
91
90
  export declare type CacheableRequestFunction = (options: string | URL | NativeRequestOptions, cb?: (response: ServerResponse | ResponseLike) => void) => CacheableRequest.Emitter;
92
91
  declare type UrlType = ConstructorParameters<typeof Options>[0];
93
92
  declare type OptionsType = ConstructorParameters<typeof Options>[1];
@@ -501,7 +501,9 @@ export default class Request extends Duplex {
501
501
  if (noContentType) {
502
502
  headers['content-type'] = encoder.headers['Content-Type'];
503
503
  }
504
- headers['content-length'] = encoder.headers['Content-Length'];
504
+ if ('Content-Length' in encoder.headers) {
505
+ headers['content-length'] = encoder.headers['Content-Length'];
506
+ }
505
507
  options.body = encoder.encode();
506
508
  }
507
509
  // Special case for https://github.com/form-data/form-data
@@ -680,6 +682,10 @@ export default class Request extends Duplex {
680
682
  }
681
683
  return;
682
684
  }
685
+ // `HTTPError`s always have `error.response.body` defined.
686
+ // Therefore we cannot retry if `options.throwHttpErrors` is false.
687
+ // On the last retry, if `options.throwHttpErrors` is false, we would need to return the body,
688
+ // but that wouldn't be possible since the body would be already read in `error.response.body`.
683
689
  if (options.isStream && options.throwHttpErrors && !isResponseOk(typedResponse)) {
684
690
  this._beforeError(new HTTPError(typedResponse));
685
691
  return;
@@ -969,9 +975,16 @@ export default class Request extends Duplex {
969
975
  }
970
976
  async _error(error) {
971
977
  try {
972
- for (const hook of this.options.hooks.beforeError) {
973
- // eslint-disable-next-line no-await-in-loop
974
- error = await hook(error);
978
+ if (error instanceof HTTPError && !this.options.throwHttpErrors) {
979
+ // This branch can be reached only when using the Promise API
980
+ // Skip calling the hooks on purpose.
981
+ // See https://github.com/sindresorhus/got/issues/2103
982
+ }
983
+ else {
984
+ for (const hook of this.options.hooks.beforeError) {
985
+ // eslint-disable-next-line no-await-in-loop
986
+ error = await hook(error);
987
+ }
975
988
  }
976
989
  }
977
990
  catch (error_) {
@@ -7,7 +7,7 @@
7
7
  /// <reference types="node" />
8
8
  /// <reference types="node" />
9
9
  /// <reference types="node" />
10
- import { Buffer } from 'node:buffer';
10
+ import type { Buffer } from 'node:buffer';
11
11
  import { URL, URLSearchParams } from 'node:url';
12
12
  import { checkServerIdentity } from 'node:tls';
13
13
  import http from 'node:http';
@@ -18,7 +18,7 @@ import type { SecureContextOptions, DetailedPeerCertificate } from 'node:tls';
18
18
  import type { Agent as HttpAgent, ClientRequest } from 'node:http';
19
19
  import type { RequestOptions as HttpsRequestOptions, Agent as HttpsAgent } from 'node:https';
20
20
  import CacheableLookup from 'cacheable-lookup';
21
- import http2wrapper, { ClientHttp2Session } from 'http2-wrapper';
21
+ import http2wrapper, { type ClientHttp2Session } from 'http2-wrapper';
22
22
  import type { FormDataLike } from 'form-data-encoder';
23
23
  import type CacheableRequest from 'cacheable-request';
24
24
  import type ResponseLike from 'responselike';
@@ -36,20 +36,20 @@ export declare type NativeRequestOptions = HttpsRequestOptions & CacheOptions &
36
36
  declare type AcceptableResponse = IncomingMessageWithTimings | ResponseLike;
37
37
  declare type AcceptableRequestResult = Promisable<AcceptableResponse | ClientRequest> | undefined;
38
38
  export declare type RequestFunction = (url: URL, options: NativeRequestOptions, callback?: (response: AcceptableResponse) => void) => AcceptableRequestResult;
39
- export interface Agents {
39
+ export declare type Agents = {
40
40
  http?: HttpAgent | false;
41
41
  https?: HttpsAgent | false;
42
42
  http2?: unknown | false;
43
- }
43
+ };
44
44
  export declare type Headers = Record<string, string | string[] | undefined>;
45
- export interface ToughCookieJar {
45
+ export declare type ToughCookieJar = {
46
46
  getCookieString: ((currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookies: string) => void) => void) & ((url: string, callback: (error: Error | null, cookieHeader: string) => void) => void);
47
47
  setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookie: unknown) => void) => void) & ((rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void) => void);
48
- }
49
- export interface PromiseCookieJar {
48
+ };
49
+ export declare type PromiseCookieJar = {
50
50
  getCookieString: (url: string) => Promise<string>;
51
51
  setCookie: (rawCookie: string, url: string) => Promise<unknown>;
52
- }
52
+ };
53
53
  export declare type InitHook = (init: OptionsInit, self: Options) => void;
54
54
  export declare type BeforeRequestHook = (options: Options) => Promisable<void | Response | ResponseLike>;
55
55
  export declare type BeforeRedirectHook = (updatedOptions: Options, plainResponse: PlainResponse) => Promisable<void>;
@@ -59,7 +59,7 @@ export declare type AfterResponseHook<ResponseType = unknown> = (response: Respo
59
59
  /**
60
60
  All available hooks of Got.
61
61
  */
62
- export interface Hooks {
62
+ export declare type Hooks = {
63
63
  /**
64
64
  Called with the plain request options, right before their normalization.
65
65
 
@@ -327,20 +327,20 @@ export interface Hooks {
327
327
  ```
328
328
  */
329
329
  afterResponse: AfterResponseHook[];
330
- }
330
+ };
331
331
  export declare type ParseJsonFunction = (text: string) => unknown;
332
332
  export declare type StringifyJsonFunction = (object: unknown) => string;
333
333
  /**
334
334
  All available HTTP request methods provided by Got.
335
335
  */
336
336
  export declare type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'TRACE' | 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete' | 'options' | 'trace';
337
- export interface RetryObject {
337
+ export declare type RetryObject = {
338
338
  attemptCount: number;
339
339
  retryOptions: RetryOptions;
340
340
  error: RequestError;
341
341
  computedValue: number;
342
342
  retryAfter?: number;
343
- }
343
+ };
344
344
  export declare type RetryFunction = (retryObject: RetryObject) => Promisable<number>;
345
345
  /**
346
346
  An object representing `limit`, `calculateDelay`, `methods`, `statusCodes`, `maxRetryAfter` and `errorCodes` fields for maximum retry count, retry handler, allowed methods, allowed status codes, maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time and allowed error codes.
@@ -364,7 +364,7 @@ __Note:__ Got does not retry on `POST` by default.
364
364
  __Note:__ If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`.
365
365
  __Note:__ If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.
366
366
  */
367
- export interface RetryOptions {
367
+ export declare type RetryOptions = {
368
368
  limit: number;
369
369
  methods: Method[];
370
370
  statusCodes: number[];
@@ -373,21 +373,21 @@ export interface RetryOptions {
373
373
  backoffLimit: number;
374
374
  noise: number;
375
375
  maxRetryAfter?: number;
376
- }
376
+ };
377
377
  export declare type CreateConnectionFunction = (options: NativeRequestOptions, oncreate: (error: NodeJS.ErrnoException, socket: Socket) => void) => Socket;
378
378
  export declare type CheckServerIdentityFunction = (hostname: string, certificate: DetailedPeerCertificate) => NodeJS.ErrnoException | void;
379
- export interface CacheOptions {
379
+ export declare type CacheOptions = {
380
380
  shared?: boolean;
381
381
  cacheHeuristic?: number;
382
382
  immutableMinTimeToLive?: number;
383
383
  ignoreCargoCult?: boolean;
384
- }
384
+ };
385
385
  declare type PfxObject = {
386
386
  buffer: string | Buffer;
387
387
  passphrase?: string | undefined;
388
388
  };
389
389
  declare type PfxType = string | Buffer | Array<string | Buffer | PfxObject> | undefined;
390
- export interface HttpsOptions {
390
+ export declare type HttpsOptions = {
391
391
  alpnProtocols?: string[];
392
392
  rejectUnauthorized?: NativeRequestOptions['rejectUnauthorized'];
393
393
  checkServerIdentity?: CheckServerIdentityFunction;
@@ -438,21 +438,21 @@ export interface HttpsOptions {
438
438
  dhparam?: SecureContextOptions['dhparam'];
439
439
  ecdhCurve?: SecureContextOptions['ecdhCurve'];
440
440
  certificateRevocationLists?: SecureContextOptions['crl'];
441
- }
442
- export interface PaginateData<BodyType, ElementType> {
441
+ };
442
+ export declare type PaginateData<BodyType, ElementType> = {
443
443
  response: Response<BodyType>;
444
444
  currentItems: ElementType[];
445
445
  allItems: ElementType[];
446
- }
447
- export interface FilterData<ElementType> {
446
+ };
447
+ export declare type FilterData<ElementType> = {
448
448
  item: ElementType;
449
449
  currentItems: ElementType[];
450
450
  allItems: ElementType[];
451
- }
451
+ };
452
452
  /**
453
453
  All options accepted by `got.paginate()`.
454
454
  */
455
- export interface PaginationOptions<ElementType, BodyType> {
455
+ export declare type PaginationOptions<ElementType, BodyType> = {
456
456
  /**
457
457
  A function that transform [`Response`](#response) into an array of items.
458
458
  This is where you should do the parsing.
@@ -550,7 +550,7 @@ export interface PaginationOptions<ElementType, BodyType> {
550
550
  @default false
551
551
  */
552
552
  stackAllItems?: boolean;
553
- }
553
+ };
554
554
  export declare type SearchParameters = Record<string, string | number | boolean | null | undefined>;
555
555
  /**
556
556
  All parsing methods supported by Got.
@@ -464,6 +464,7 @@ export default class Options {
464
464
  if (!(key in this._internals.agent)) {
465
465
  throw new TypeError(`Unexpected agent option: ${key}`);
466
466
  }
467
+ // @ts-expect-error - No idea why `value[key]` doesn't work here.
467
468
  assert.any([is.object, is.undefined], value[key]);
468
469
  }
469
470
  if (this._merging) {
@@ -523,6 +524,7 @@ export default class Options {
523
524
  if (!(key in this._internals.timeout)) {
524
525
  throw new Error(`Unexpected timeout option: ${key}`);
525
526
  }
527
+ // @ts-expect-error - No idea why `value[key]` doesn't work here.
526
528
  assert.any([is.number, is.undefined], value[key]);
527
529
  }
528
530
  if (this._merging) {
@@ -976,8 +978,7 @@ export default class Options {
976
978
  throw new Error(`Unexpected hook event: ${knownHookEvent}`);
977
979
  }
978
980
  const typedKnownHookEvent = knownHookEvent;
979
- const typedValue = value;
980
- const hooks = typedValue[typedKnownHookEvent];
981
+ const hooks = value[typedKnownHookEvent];
981
982
  assert.any([is.array, is.undefined], hooks);
982
983
  if (hooks) {
983
984
  for (const hook of hooks) {
@@ -1647,6 +1648,5 @@ export default class Options {
1647
1648
  Object.freeze(options.retry.methods);
1648
1649
  Object.freeze(options.retry.statusCodes);
1649
1650
  Object.freeze(options.context);
1650
- Object.freeze(options.signal);
1651
1651
  }
1652
1652
  }
@@ -6,7 +6,7 @@ import type { IncomingMessageWithTimings, Timings } from '@szmarczak/http-timer'
6
6
  import { RequestError } from './errors.js';
7
7
  import type { ParseJsonFunction, ResponseType } from './options.js';
8
8
  import type Request from './index.js';
9
- export interface PlainResponse extends IncomingMessageWithTimings {
9
+ export declare type PlainResponse = {
10
10
  /**
11
11
  The original request URL.
12
12
  */
@@ -87,8 +87,8 @@ export interface PlainResponse extends IncomingMessageWithTimings {
87
87
  __Note__: Got throws automatically when `response.ok` is `false` and `throwHttpErrors` is `true`.
88
88
  */
89
89
  ok: boolean;
90
- }
91
- export interface Response<T = unknown> extends PlainResponse {
90
+ } & IncomingMessageWithTimings;
91
+ export declare type Response<T = unknown> = {
92
92
  /**
93
93
  The result of the request.
94
94
  */
@@ -97,7 +97,7 @@ export interface Response<T = unknown> extends PlainResponse {
97
97
  The raw result of the request.
98
98
  */
99
99
  rawBody: Buffer;
100
- }
100
+ } & PlainResponse;
101
101
  export declare const isResponseOk: (response: PlainResponse) => boolean;
102
102
  /**
103
103
  An error to be thrown when server response code is 2xx, and parsing body fails.
@@ -1,11 +1,11 @@
1
- import { ClientRequest } from 'node:http';
1
+ import type { ClientRequest } from 'node:http';
2
2
  declare const reentry: unique symbol;
3
- interface TimedOutOptions {
3
+ declare type TimedOutOptions = {
4
4
  host?: string;
5
5
  hostname?: string;
6
6
  protocol?: string;
7
- }
8
- export interface Delays {
7
+ };
8
+ export declare type Delays = {
9
9
  lookup?: number;
10
10
  socket?: number;
11
11
  connect?: number;
@@ -14,7 +14,7 @@ export interface Delays {
14
14
  response?: number;
15
15
  read?: number;
16
16
  request?: number;
17
- }
17
+ };
18
18
  export declare type ErrorCode = 'ETIMEDOUT' | 'ECONNRESET' | 'EADDRINUSE' | 'ECONNREFUSED' | 'EPIPE' | 'ENOTFOUND' | 'ENETUNREACH' | 'EAI_AGAIN';
19
19
  export declare class TimeoutError extends Error {
20
20
  event: string;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="node" />
2
- import { ClientRequestArgs } from 'node:http';
2
+ import type { ClientRequestArgs } from 'node:http';
3
3
  export default function getBodySize(body: unknown, headers: ClientRequestArgs['headers']): Promise<number | undefined>;
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
- import { Readable } from 'node:stream';
3
- interface FormData extends Readable {
2
+ import type { Readable } from 'node:stream';
3
+ declare type FormData = {
4
4
  getBoundary: () => string;
5
5
  getLength: (callback: (error: Error | null, length: number) => void) => void;
6
- }
6
+ } & Readable;
7
7
  export default function isFormData(body: unknown): body is FormData;
8
8
  export {};
@@ -1,3 +1,3 @@
1
1
  /// <reference types="node" />
2
- import { URL } from 'url';
2
+ import type { URL } from 'url';
3
3
  export default function isUnixSocketURL(url: URL): boolean;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { URL } from 'node:url';
3
- export interface URLOptions {
3
+ export declare type URLOptions = {
4
4
  href?: string;
5
5
  protocol?: string;
6
6
  host?: string;
@@ -10,5 +10,5 @@ export interface URLOptions {
10
10
  search?: string;
11
11
  searchParams?: unknown;
12
12
  path?: string;
13
- }
13
+ };
14
14
  export default function optionsToUrl(origin: string, options: URLOptions): URL;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="node" />
2
- import { EventEmitter } from 'node:events';
2
+ import type { EventEmitter } from 'node:events';
3
3
  export default function proxyEvents(from: EventEmitter, to: EventEmitter, events: Readonly<string[]>): () => void;
@@ -1,11 +1,11 @@
1
1
  /// <reference types="node" />
2
- import { EventEmitter } from 'node:events';
2
+ import type { EventEmitter } from 'node:events';
3
3
  declare type Origin = EventEmitter;
4
4
  declare type Event = string | symbol;
5
5
  declare type Fn = (...args: any[]) => void;
6
- interface Unhandler {
6
+ declare type Unhandler = {
7
7
  once: (origin: Origin, event: Event, fn: Fn) => void;
8
8
  unhandleAll: () => void;
9
- }
9
+ };
10
10
  export default function unhandle(): Unhandler;
11
11
  export {};
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { URL, UrlWithStringQuery } from 'node:url';
3
- export interface LegacyUrlOptions {
2
+ import type { URL, UrlWithStringQuery } from 'node:url';
3
+ export declare type LegacyUrlOptions = {
4
4
  protocol: string;
5
5
  hostname: string;
6
6
  host: string;
@@ -11,5 +11,5 @@ export interface LegacyUrlOptions {
11
11
  path: string;
12
12
  port?: number;
13
13
  auth?: string;
14
- }
14
+ };
15
15
  export default function urlToOptions(url: URL | UrlWithStringQuery): LegacyUrlOptions;
@@ -1,3 +1,3 @@
1
- import { Got, InstanceDefaults } from './types.js';
1
+ import type { Got, InstanceDefaults } from './types.js';
2
2
  declare const create: (defaults: InstanceDefaults) => Got;
3
3
  export default create;
@@ -12,7 +12,7 @@ declare type Merge<FirstType, SecondType> = Except<FirstType, Extract<keyof Firs
12
12
  /**
13
13
  Defaults for each Got instance.
14
14
  */
15
- export interface InstanceDefaults {
15
+ export declare type InstanceDefaults = {
16
16
  /**
17
17
  An object containing the default options of Got.
18
18
  */
@@ -32,7 +32,7 @@ export interface InstanceDefaults {
32
32
  @default false
33
33
  */
34
34
  mutableDefaults: boolean;
35
- }
35
+ };
36
36
  /**
37
37
  A Request object returned by calling Got, or any of the Got HTTP alias request functions.
38
38
  */
@@ -45,7 +45,7 @@ export declare type HandlerFunction = <T extends GotReturn>(options: Options, ne
45
45
  /**
46
46
  The options available for `got.extend()`.
47
47
  */
48
- export interface ExtendOptions extends OptionsInit {
48
+ export declare type ExtendOptions = {
49
49
  /**
50
50
  An array of functions. You execute them directly by calling `got()`.
51
51
  They are some sort of "global hooks" - these functions are called first.
@@ -61,7 +61,7 @@ export interface ExtendOptions extends OptionsInit {
61
61
  @default false
62
62
  */
63
63
  mutableDefaults?: boolean;
64
- }
64
+ } & OptionsInit;
65
65
  export declare type OptionsOfTextResponseBody = Merge<OptionsInit, {
66
66
  isStream?: false;
67
67
  resolveBodyOnly?: false;
@@ -94,7 +94,7 @@ export declare type OptionsWithPagination<T = unknown, R = unknown> = Merge<Opti
94
94
  /**
95
95
  An instance of `got.paginate`.
96
96
  */
97
- export interface GotPaginate {
97
+ export declare type GotPaginate = {
98
98
  /**
99
99
  Same as `GotPaginate.each`.
100
100
  */
@@ -146,8 +146,8 @@ export interface GotPaginate {
146
146
  ```
147
147
  */
148
148
  all: (<T, R = unknown>(url: string | URL, options?: OptionsWithPagination<T, R>) => Promise<T[]>) & (<T, R = unknown>(options?: OptionsWithPagination<T, R>) => Promise<T[]>);
149
- }
150
- export interface GotRequestFunction {
149
+ };
150
+ export declare type GotRequestFunction = {
151
151
  (url: string | URL, options?: OptionsOfTextResponseBody): CancelableRequest<Response<string>>;
152
152
  <T>(url: string | URL, options?: OptionsOfJSONResponseBody): CancelableRequest<Response<T>>;
153
153
  (url: string | URL, options?: OptionsOfBufferResponseBody): CancelableRequest<Response<Buffer>>;
@@ -171,7 +171,7 @@ export interface GotRequestFunction {
171
171
  (url: string | URL, options?: OptionsInit): CancelableRequest | Request;
172
172
  (options: OptionsInit): CancelableRequest | Request;
173
173
  (url: undefined, options: undefined, defaults: Options): CancelableRequest | Request;
174
- }
174
+ };
175
175
  /**
176
176
  All available HTTP request methods provided by Got.
177
177
  */
@@ -188,7 +188,7 @@ export declare type GotStream = GotStreamFunction & Record<HTTPAlias, GotStreamF
188
188
  /**
189
189
  An instance of `got`.
190
190
  */
191
- export interface Got extends Record<HTTPAlias, GotRequestFunction>, GotRequestFunction {
191
+ export declare type Got = {
192
192
  /**
193
193
  Sets `options.isStream` to `true`.
194
194
 
@@ -259,5 +259,5 @@ export interface Got extends Record<HTTPAlias, GotRequestFunction>, GotRequestFu
259
259
  ```
260
260
  */
261
261
  extend: (...instancesOrOptions: Array<Got | ExtendOptions>) => Got;
262
- }
262
+ } & Record<HTTPAlias, GotRequestFunction> & GotRequestFunction;
263
263
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "got",
3
- "version": "12.2.0",
3
+ "version": "12.4.0",
4
4
  "description": "Human-friendly and powerful HTTP request library for Node.js",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/got",
@@ -12,7 +12,7 @@
12
12
  "node": ">=14.16"
13
13
  },
14
14
  "scripts": {
15
- "test": "xo && ava",
15
+ "test": "xo && tsc --noEmit && ava",
16
16
  "release": "np",
17
17
  "build": "del-cli dist && tsc",
18
18
  "prepare": "npm run build"
@@ -48,24 +48,23 @@
48
48
  "@sindresorhus/is": "^5.2.0",
49
49
  "@szmarczak/http-timer": "^5.0.1",
50
50
  "@types/cacheable-request": "^6.0.2",
51
- "@types/responselike": "^1.0.0",
52
51
  "cacheable-lookup": "^6.0.4",
53
52
  "cacheable-request": "^7.0.2",
54
53
  "decompress-response": "^6.0.0",
55
- "form-data-encoder": "^2.0.1",
54
+ "form-data-encoder": "^2.1.0",
56
55
  "get-stream": "^6.0.1",
57
56
  "http2-wrapper": "^2.1.10",
58
57
  "lowercase-keys": "^3.0.0",
59
58
  "p-cancelable": "^3.0.0",
60
- "responselike": "^2.0.0"
59
+ "responselike": "^3.0.0"
61
60
  },
62
61
  "devDependencies": {
63
62
  "@hapi/bourne": "^3.0.0",
64
63
  "@sindresorhus/tsconfig": "^2.0.0",
65
64
  "@sinonjs/fake-timers": "^9.1.1",
66
- "@types/benchmark": "^2.1.1",
65
+ "@types/benchmark": "^2.1.2",
67
66
  "@types/express": "^4.17.13",
68
- "@types/node": "^18.0.1",
67
+ "@types/node": "^18.7.13",
69
68
  "@types/pem": "^1.9.6",
70
69
  "@types/pify": "^5.0.1",
71
70
  "@types/readable-stream": "^2.3.13",
@@ -80,7 +79,7 @@
80
79
  "body-parser": "^1.19.2",
81
80
  "create-cert": "^1.0.6",
82
81
  "create-test-server": "^3.0.1",
83
- "del-cli": "^4.0.1",
82
+ "del-cli": "^5.0.0",
84
83
  "delay": "^5.0.0",
85
84
  "express": "^4.17.3",
86
85
  "form-data": "^4.0.0",
@@ -99,10 +98,10 @@
99
98
  "tempy": "^3.0.0",
100
99
  "then-busboy": "^5.1.1",
101
100
  "to-readable-stream": "^3.0.0",
102
- "tough-cookie": "^4.0.0",
101
+ "tough-cookie": "4.0.0",
103
102
  "ts-node": "^10.8.2",
104
- "typescript": "^4.7.4",
105
- "xo": "^0.50.0"
103
+ "typescript": "~4.8.2",
104
+ "xo": "^0.52.2"
106
105
  },
107
106
  "sideEffects": false,
108
107
  "ava": {
package/readme.md CHANGED
@@ -46,41 +46,6 @@
46
46
  <br>
47
47
  <br>
48
48
  <br>
49
- <a href="https://neverinstall.com/spaces/devtools?utm_source=github&utm_medium=sponsor&utm_campaign=sindre#gh-light-mode-only">
50
- <div>
51
- <img src="https://sindresorhus.com/assets/thanks/neverinstall-logo-light.svg" width="200" alt="neverinstall">
52
- </div>
53
- <br>
54
- <b>All your favourite IDE's now available on the cloud</b>
55
- <div>
56
- <sub>
57
- Neverinstall gives you an uninterrupted development experience and improved accessibility,
58
- <br>
59
- allowing you to code faster, better and on-the-go on your favourite IDEs like
60
- <br>
61
- Android Studio, VS Code, Jupyter and PyCharm using your browser.
62
- </sub>
63
- </div>
64
- </a>
65
- <a href="https://neverinstall.com/spaces/devtools?utm_source=github&utm_medium=sponsor&utm_campaign=sindre#gh-dark-mode-only">
66
- <div>
67
- <img src="https://sindresorhus.com/assets/thanks/neverinstall-logo-dark.svg" width="200" alt="neverinstall">
68
- </div>
69
- <br>
70
- <b>All your favourite IDE's now available on the cloud</b>
71
- <div>
72
- <sub>
73
- Neverinstall gives you an uninterrupted development experience and improved accessibility,
74
- <br>
75
- allowing you to code faster, better and on-the-go on your favourite IDEs like
76
- <br>
77
- Android Studio, VS Code, Jupyter and PyCharm using your browser.
78
- </sub>
79
- </div>
80
- </a>
81
- <br>
82
- <br>
83
- <br>
84
49
  <a href="https://www.useanvil.com/?utm_source=sindresorhus#gh-light-mode-only">
85
50
  <div>
86
51
  <img src="https://sindresorhus.com/assets/thanks/anvil-logo-light.svg" width="200" alt="Anvil">
@@ -144,6 +109,8 @@ npm install got
144
109
 
145
110
  ## Take a peek
146
111
 
112
+ **A [quick start](documentation/quick-start.md) guide is available.**
113
+
147
114
  ### JSON mode
148
115
 
149
116
  Got has a dedicated option for handling JSON payload.\
@@ -174,6 +141,8 @@ For advanced JSON usage, check out the [`parseJson`](documentation/2-options.md#
174
141
 
175
142
  ## Documentation
176
143
 
144
+ By default, Got will retry on failure. To disable this option, set [`options.retry.limit`](documentation/7-retry.md#retry) to 0.
145
+
177
146
  #### Main API
178
147
 
179
148
  - [x] [Promise API](documentation/1-promise.md)
@@ -182,7 +151,7 @@ For advanced JSON usage, check out the [`parseJson`](documentation/2-options.md#
182
151
  - [x] [Pagination API](documentation/4-pagination.md)
183
152
  - [x] [Advanced HTTPS API](documentation/5-https.md)
184
153
  - [x] [HTTP/2 support](documentation/2-options.md#http2)
185
- - [x] [`Response` class](documentation/3-streams.md#response-1)
154
+ - [x] [`Response` class](documentation/3-streams.md#response-2)
186
155
 
187
156
  #### Timeouts and retries
188
157