Comparing version 10.0.1 to 10.0.2
/// <reference types="node" /> | ||
import { Merge, PartialDeep } from 'type-fest'; | ||
import { Merge } from 'type-fest'; | ||
import { ProxyStream } from './as-stream'; | ||
import * as errors from './errors'; | ||
import { CancelableRequest, Defaults, ExtendOptions, HandlerFunction, Options, Response, URLOrOptions } from './utils/types'; | ||
import { CancelableRequest, Defaults, ExtendOptions, HandlerFunction, NormalizedOptions, Options, Response, URLOrOptions } from './utils/types'; | ||
export declare type HTTPAlias = 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete'; | ||
@@ -66,3 +66,3 @@ export declare type ReturnStream = <T>(url: string | Merge<Options, { | ||
mergeInstances(parent: Got, ...instances: Got[]): Got; | ||
mergeOptions<T extends PartialDeep<Options>>(...sources: T[]): T; | ||
mergeOptions(...sources: Options[]): NormalizedOptions; | ||
} | ||
@@ -69,0 +69,0 @@ export interface GotStream extends Record<HTTPAlias, ReturnStream> { |
@@ -19,8 +19,2 @@ "use strict"; | ||
}); | ||
Object.defineProperty(this, "options", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Error.captureStackTrace(this, this.constructor); | ||
@@ -75,8 +69,2 @@ this.name = 'GotError'; | ||
super(`${error.message} in "${options.url.toString()}"`, error, options); | ||
Object.defineProperty(this, "response", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.name = 'ParseError'; | ||
@@ -93,8 +81,2 @@ Object.defineProperty(this, 'response', { | ||
super(`Response code ${response.statusCode} (${response.statusMessage})`, {}, options); | ||
Object.defineProperty(this, "response", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.name = 'HTTPError'; | ||
@@ -111,8 +93,2 @@ Object.defineProperty(this, 'response', { | ||
super(`Redirected ${maxRedirects} times. Aborting.`, {}, options); | ||
Object.defineProperty(this, "response", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.name = 'MaxRedirectsError'; | ||
@@ -119,0 +95,0 @@ Object.defineProperty(this, 'response', { |
@@ -10,3 +10,2 @@ "use strict"; | ||
super(`Timeout awaiting '${event}' for ${threshold}ms`); | ||
this.event = event; | ||
Object.defineProperty(this, "event", { | ||
@@ -16,3 +15,3 @@ enumerable: true, | ||
writable: true, | ||
value: void 0 | ||
value: event | ||
}); | ||
@@ -59,2 +58,6 @@ Object.defineProperty(this, "code", { | ||
const timeoutHandler = (delay, event) => { | ||
if (request.socket) { | ||
// @ts-ignore We do not want the `socket hang up` error | ||
request.socket._hadError = true; | ||
} | ||
request.abort(); | ||
@@ -70,5 +73,3 @@ request.emit('error', new TimeoutError(delay, event)); | ||
request.once('error', error => { | ||
if (error.message !== 'socket hang up') { | ||
cancelTimeouts(); | ||
} | ||
cancelTimeouts(); | ||
// Save original behavior | ||
@@ -75,0 +76,0 @@ if (request.listenerCount('error') === 0) { |
@@ -181,2 +181,39 @@ /// <reference types="node" /> | ||
} | ||
declare global { | ||
class URL { | ||
readonly origin: string; | ||
readonly searchParams: URLSearchParams; | ||
hash: string; | ||
host: string; | ||
hostname: string; | ||
href: string; | ||
password: string; | ||
pathname: string; | ||
port: string; | ||
protocol: string; | ||
search: string; | ||
username: string; | ||
constructor(input: string, base?: string | URL); | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
class URLSearchParams implements Iterable<[string, string]> { | ||
constructor(init?: URLSearchParams | string | { | ||
[key: string]: string | string[] | undefined; | ||
} | Iterable<[string, string]> | Array<[string, string]>); | ||
append(name: string, value: string): void; | ||
delete(name: string): void; | ||
entries(): IterableIterator<[string, string]>; | ||
forEach(callback: (value: string, name: string, searchParams: this) => void): void; | ||
get(name: string): string | null; | ||
getAll(name: string): string[]; | ||
has(name: string): boolean; | ||
keys(): IterableIterator<string>; | ||
set(name: string, value: string): void; | ||
sort(): void; | ||
toString(): string; | ||
values(): IterableIterator<string>; | ||
[Symbol.iterator](): IterableIterator<[string, string]>; | ||
} | ||
} | ||
export {}; |
{ | ||
"name": "got", | ||
"version": "10.0.1", | ||
"version": "10.0.2", | ||
"description": "Human-friendly and powerful HTTP request library for Node.js", | ||
@@ -45,3 +45,3 @@ "license": "MIT", | ||
"@sindresorhus/is": "^1.0.0", | ||
"@szmarczak/http-timer": "^3.1.0", | ||
"@szmarczak/http-timer": "^3.1.1", | ||
"@types/cacheable-request": "^6.0.1", | ||
@@ -69,4 +69,4 @@ "cacheable-lookup": "^0.2.1", | ||
"@types/tough-cookie": "^2.3.5", | ||
"@typescript-eslint/eslint-plugin": "^2.9.0", | ||
"@typescript-eslint/parser": "^2.9.0", | ||
"@typescript-eslint/eslint-plugin": "2.10.0", | ||
"@typescript-eslint/parser": "2.10.0", | ||
"ava": "^2.4.0", | ||
@@ -128,4 +128,7 @@ "coveralls": "^3.0.4", | ||
"documentation/examples/*" | ||
] | ||
], | ||
"rules": { | ||
"@typescript-eslint/no-empty-function": "off" | ||
} | ||
} | ||
} |
@@ -183,7 +183,7 @@ <div align="center"> | ||
**Note:** The `body` option cannot be used with the `json` or `form` option. | ||
**Note #1:** The `body` option cannot be used with the `json` or `form` option. | ||
**Note:** If you provide this option, `got.stream()` will be read-only. | ||
**Note #2:** If you provide this option, `got.stream()` will be read-only. | ||
If present in `options` and `options.method` is not set, it will throw a `TypeError`. | ||
**Note #3:** If you provide a payload with the `GET` or `HEAD` method, it will throw a `TypeError`. | ||
@@ -808,3 +808,3 @@ The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / `fs.createReadStream` instance / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`. | ||
client.get('/demo'); | ||
client.get('demo'); | ||
@@ -826,3 +826,3 @@ /* HTTP Request => | ||
}); | ||
const {headers} = await client.get('/headers').json(); | ||
const {headers} = await client.get('headers').json(); | ||
//=> headers['x-foo'] === 'bar' | ||
@@ -837,3 +837,3 @@ | ||
}); | ||
const {headers: headers2} = await jsonClient.get('/headers'); | ||
const {headers: headers2} = await jsonClient.get('headers'); | ||
//=> headers2['x-foo'] === 'bar' | ||
@@ -1345,3 +1345,3 @@ //=> headers2['x-baz'] === 'qux' | ||
const body = await got.post('https://httpbin.org/anything', { | ||
body: { | ||
json: { | ||
hello: 'world' | ||
@@ -1399,3 +1399,3 @@ } | ||
(async () => { | ||
const list = await custom('/v1/users/list'); | ||
const list = await custom('v1/users/list'); | ||
})(); | ||
@@ -1402,0 +1402,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152116
2225
Updated@szmarczak/http-timer@^3.1.1