Skip to content

Commit

Permalink
Applied requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Giotino committed Jun 2, 2020
1 parent fd0cd5b commit a46920a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
20 changes: 1 addition & 19 deletions documentation/migration-guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const gotInstance = got.extend({
gotInstance(url, options);
```

- No `jsonReviver`/`jsonReplacer` option, but you can use hooks for that too:
- No `jsonReplacer` option, but you can use hooks for that too:

This comment has been minimized.

Copy link
@szmarczak

szmarczak Jun 2, 2020

Collaborator

You need to mention that jsonReviver has been renamed.

This comment has been minimized.

Copy link
@Giotino

Giotino Jun 2, 2020

Author Collaborator

jsonReviver never existed, I don't think we need to say anything about it.

This comment has been minimized.

Copy link
@szmarczak

szmarczak Jun 2, 2020

Collaborator

But it does now, and the Renamed options section stands for something :)

This comment has been minimized.

Copy link
@Giotino

Giotino Jun 2, 2020

Author Collaborator

Oh, yes, sorry

This comment has been minimized.

Copy link
@szmarczak

szmarczak Jun 2, 2020

Collaborator

No problem, I sometimes overlook things too.


```js
const gotInstance = got.extend({
Expand All @@ -109,24 +109,6 @@ const gotInstance = got.extend({
delete options.json;
}
}
],
beforeRequest: [
options => {
if (options.responseType === 'json' && options.jsonReviver) {
options.responseType = 'text';
options.customJsonResponse = true;
}
}
],
afterResponse: [
response => {
const {options} = response.request;
if (options.jsonReviver && options.customJsonResponse) {
response.body = JSON.parse(response.body, options.jsonReviver);
}

return response;
}
]
}
});
Expand Down
10 changes: 5 additions & 5 deletions source/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ export type RequestFunction = (url: URL, options: RequestOptions, callback?: (re

export type Headers = Record<string, string | string[] | undefined>;

type CacheableRequestFn = (
type CacheableRequestFunction = (
opts: string | URL | RequestOptions,
cb?: (response: ServerResponse | ResponseLike) => void
) => CacheableRequest.Emitter;

type CheckServerIdentityFn = (hostname: string, certificate: DetailedPeerCertificate) => Error | void;
type CheckServerIdentityFunction = (hostname: string, certificate: DetailedPeerCertificate) => Error | void;
export type ParseJsonFunction = (text: string) => unknown;

interface RealRequestOptions extends https.RequestOptions {
checkServerIdentity: CheckServerIdentityFn;
checkServerIdentity: CheckServerIdentityFunction;
}

export interface Options extends URLOptions {
Expand Down Expand Up @@ -170,7 +170,7 @@ export interface HTTPSOptions {
rejectUnauthorized?: https.RequestOptions['rejectUnauthorized'];

// From `tls.ConnectionOptions`
checkServerIdentity?: CheckServerIdentityFn;
checkServerIdentity?: CheckServerIdentityFunction;

// From `tls.SecureContextOptions`
certificateAuthority?: SecureContextOptions['ca'];
Expand Down Expand Up @@ -284,7 +284,7 @@ function isClientRequest(clientRequest: unknown): clientRequest is ClientRequest
return is.object(clientRequest) && !('statusCode' in clientRequest);
}

const cacheableStore = new WeakableMap<string | CacheableRequest.StorageAdapter, CacheableRequestFn>();
const cacheableStore = new WeakableMap<string | CacheableRequest.StorageAdapter, CacheableRequestFunction>();

const waitForOpenFile = async (file: ReadStream): Promise<void> => new Promise((resolve, reject) => {
const onError = (error: Error): void => {
Expand Down

0 comments on commit a46920a

Please sign in to comment.