id int64 0 3.78k | code stringlengths 13 37.9k | declarations stringlengths 16 64.6k |
|---|---|---|
300 | async function outputInterface(entry: Interface, currentNamespace: INamespace | undefined) {
let output = '';
if (entry.export) {
output += 'export ';
}
if (isInterfaceProperties(entry)) {
const extendList = entry.extends.map(extend => extend.name + stringifyGenerics(extend.generics)).join(', ');
o... | type Interface = IInterfaceProperties | IInterfaceFallback; |
301 | function outputDeclaration(entry: IDeclaration, currentNamespace: INamespace | undefined) {
let output = '';
if (entry.export) {
output += 'export ';
}
output += `type ${
entry.name + stringifyGenerics(entry.generics, entry.export, stringifySimpleTypes)
} = ${stringifyTypes(entry.types, currentNamesp... | interface IDeclaration {
name: string;
export: boolean;
types: DeclarableType[];
generics: IGenerics[];
namespace: INamespace | undefined;
} |
302 | (dataTypes: IDataTypeDictionary) => Promise<TReturn> | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
303 | async function resolveDataTypes(
dictionary: IDataTypeDictionary,
types: TypeType[],
minTypesInDataTypes: number,
resolver: (
dataTypes: IDataTypeDictionary,
dataType: IDataType,
min: number,
) => Promise<ResolvedType[]> = simpleDataTypeResolver,
): Promise<ResolvedType[]> {
const resolvedDataTy... | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
304 | async function resolveDataTypes(
dictionary: IDataTypeDictionary,
types: TypeType[],
minTypesInDataTypes: number,
resolver: (
dataTypes: IDataTypeDictionary,
dataType: IDataType,
min: number,
) => Promise<ResolvedType[]> = simpleDataTypeResolver,
): Promise<ResolvedType[]> {
const resolvedDataTy... | interface IDataType<TTypeKind = Type.DataType | Type.PropertyReference> {
type: TTypeKind;
name: string;
} |
305 | (
dataTypes: IDataTypeDictionary,
dataType: IDataType,
min: number,
) => Promise<ResolvedType[]> | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
306 | (
dataTypes: IDataTypeDictionary,
dataType: IDataType,
min: number,
) => Promise<ResolvedType[]> | interface IDataType<TTypeKind = Type.DataType | Type.PropertyReference> {
type: TTypeKind;
name: string;
} |
307 | async function simpleDataTypeResolver(
dictionary: IDataTypeDictionary,
dataType: IDataType,
minTypesInDataTypes: number,
): Promise<ResolvedType[]> {
const syntax = await getSyntax(dataType.name);
return syntax
? resolveDataTypes(dictionary, typer(parse(syntax)), minTypesInDataTypes, simpleDataTypeResolv... | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
308 | async function simpleDataTypeResolver(
dictionary: IDataTypeDictionary,
dataType: IDataType,
minTypesInDataTypes: number,
): Promise<ResolvedType[]> {
const syntax = await getSyntax(dataType.name);
return syntax
? resolveDataTypes(dictionary, typer(parse(syntax)), minTypesInDataTypes, simpleDataTypeResolv... | interface IDataType<TTypeKind = Type.DataType | Type.PropertyReference> {
type: TTypeKind;
name: string;
} |
309 | (
dictionary: IDataTypeDictionary,
dataType: IDataType,
min: number,
) => Promise<ResolvedType[]> | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
310 | (
dictionary: IDataTypeDictionary,
dataType: IDataType,
min: number,
) => Promise<ResolvedType[]> | interface IDataType<TTypeKind = Type.DataType | Type.PropertyReference> {
type: TTypeKind;
name: string;
} |
311 | function createDataType(dictionary: IDataTypeDictionary, name: string, types: ResolvedType[], index = 0): DataType {
const realName = name + (index > 0 ? index + 1 : '');
// Rename in case of conflict
if (realName in dictionary) {
const existingDataType = dictionary[realName];
for (const type of types) ... | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
312 | async function getAtRules(dataTypeDictionary: IDataTypeDictionary, minTypesInDataTypes: number) {
const literals: IStringLiteral[] = [];
const rules: { [name: string]: IAtRuleDescriptors } = {};
for (const atName in atRules) {
const atRule = atRules[atName];
// Without the `@`
const name = atName.sl... | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
313 | async function getGlobals(
dataTypeDictionary: IDataTypeDictionary,
minTypesInDataTypes: number,
): Promise<ResolvedType[]> {
const dataTypes = await resolveDataTypes(
dataTypeDictionary,
typer(compatSyntax(await getGlobalCompatibilityData(), parse(await getPropertySyntax(ALL)))),
minTypesInDataTypes,... | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
314 | async function getHtmlProperties(dataTypeDictionary: IDataTypeDictionary, minTypesInDataTypes: number) {
const propertiesMap = await getProperties();
const allPropertyData = await getPropertyData(ALL);
let getAllComment = async () => {
const comment = await composeCommentBlock(allPropertyData, propertiesMap[... | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
315 | async function getSvgProperties(dataTypeDictionary: IDataTypeDictionary, minTypesInDataTypes: number) {
for (const name in rawSvgProperties) {
const compatibilityData = await getPropertyData(name);
const syntax = rawSvgProperties[name].syntax;
if (syntax) {
svgPropertiesMap[name] = {
name,
... | interface IDataTypeDictionary {
[key: string]: ResolvedType[];
} |
316 | (type: SimpleType) => string | type SimpleType = Exclude<DeclarableType, IAlias>; |
317 | (type: IAlias) => string | interface IAlias {
type: Type.Alias;
name: string;
generics: IGenerics[];
namespace: INamespace | undefined;
} |
318 | (type: DeclarableType) => string | type DeclarableType = TypeType<IAlias> | IArray; |
319 | (type: IAlias, currentNamespace: INamespace | undefined) => string | interface IAlias {
type: Type.Alias;
name: string;
generics: IGenerics[];
namespace: INamespace | undefined;
} |
320 | (type: DeclarableType) => {
switch (type.type) {
case Type.String:
return 'string';
case Type.Number:
return 'number';
case Type.StringLiteral:
return JSON.stringify(type.literal);
case Type.NumericLiteral:
return type.literal;
case Type.Array:
r... | type DeclarableType = TypeType<IAlias> | IArray; |
321 | function message(error: IError) {
const {
loc: {
start: { line, column },
},
descr,
} = error.message[0];
return `${line}:${column} - ${descr}`;
} | interface IError {
kind: string;
level: string;
suppressions: any[];
extra: IExtra[];
message: IMessage[];
} |
322 | (server: ExtendedHttpTestServer, clock: GlobalClock): {emitter: EventEmitter; promise: Promise<unknown>} => {
const emitter = new EventEmitter();
const promise = new Promise<void>((resolve, reject) => {
server.all('/abort', async (request, response) => {
emitter.emit('connection');
request.once('aborte... | type ExtendedHttpTestServer = {
http: http.Server;
url: string;
port: number;
hostname: string;
close: () => Promise<any>;
} & Express; |
323 | (server: ExtendedHttpTestServer, clock: GlobalClock): {emitter: EventEmitter; promise: Promise<unknown>} => {
const emitter = new EventEmitter();
const promise = new Promise<void>((resolve, reject) => {
server.all('/abort', async (request, response) => {
emitter.emit('connection');
request.once('aborte... | type GlobalClock = any; |
324 | (clock?: GlobalClock): Handler => (_request, response) => {
response.writeHead(200, {
'transfer-encoding': 'chunked',
});
response.flushHeaders();
stream.pipeline(
slowDataStream(clock),
response,
() => {
response.end();
},
);
} | type GlobalClock = any; |
325 | (error: Error) => {
if (controller.signal.aborted) {
return;
}
throw error;
} | type Error = NodeJS.ErrnoException; |
326 | (error: Error) => {
if (controller.signal.aborted) {
return;
}
throw error;
} | type Error = NodeJS.ErrnoException; |
327 | (error: Error) => {
if (error.message === 'This operation was aborted.') {
return;
}
throw error;
} | type Error = NodeJS.ErrnoException; |
328 | (error: Error) => {
if (error.message === 'This operation was aborted.') {
return;
}
throw error;
} | type Error = NodeJS.ErrnoException; |
329 | (options: OptionsInit) => {
options.headers = {
foo: 'bar',
};
} | type OptionsInit =
Except<Partial<InternalsType>, 'hooks' | 'retry'>
& {
hooks?: Partial<Hooks>;
retry?: Partial<RetryOptions>;
}; |
330 | (event: Progress) => events.push(event) | type Progress = {
percent: number;
transferred: number;
total?: number;
}; |
331 | (event: Progress) => {
events.push(event);
void promise.off('uploadProgress', listener);
} | type Progress = {
percent: number;
transferred: number;
total?: number;
}; |
332 | (server: ExtendedHttpTestServer, clock: GlobalClock): {emitter: EventEmitter; promise: Promise<unknown>} => {
const emitter = new EventEmitter();
const promise = new Promise<void>((resolve, reject) => {
server.all('/abort', async (request, response) => {
emitter.emit('connection');
request.once('aborted', r... | type ExtendedHttpTestServer = {
http: http.Server;
url: string;
port: number;
hostname: string;
close: () => Promise<any>;
} & Express; |
333 | (server: ExtendedHttpTestServer, clock: GlobalClock): {emitter: EventEmitter; promise: Promise<unknown>} => {
const emitter = new EventEmitter();
const promise = new Promise<void>((resolve, reject) => {
server.all('/abort', async (request, response) => {
emitter.emit('connection');
request.once('aborted', r... | type GlobalClock = any; |
334 | (clock?: GlobalClock): Handler => (_request, response) => {
response.writeHead(200, {
'transfer-encoding': 'chunked',
});
response.flushHeaders();
stream.pipeline(
slowDataStream(clock),
response,
() => {
response.end();
},
);
} | type GlobalClock = any; |
335 | (error: Error) => {
if (p.isCanceled) {
return;
}
throw error;
} | type Error = NodeJS.ErrnoException; |
336 | (error: Error) => {
if (p.isCanceled) {
return;
}
throw error;
} | type Error = NodeJS.ErrnoException; |
337 | (error: Error) => {
if (error instanceof CancelError) {
return;
}
throw error;
} | type Error = NodeJS.ErrnoException; |
338 | (error: Error) => {
if (error instanceof CancelError) {
return;
}
throw error;
} | type Error = NodeJS.ErrnoException; |
339 | (instance: Got): BeforeRequestHook[] => instance.defaults.options.hooks.beforeRequest | type Got = {
/**
Sets `options.isStream` to `true`.
Returns a [duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with additional events:
- request
- response
- redirect
- uploadProgress
- downloadProgress
- error
*/
stream: GotStream;
/**
Returns an async iterator.
See pagin... |
340 | (clock: GlobalClock): Handler => (request, response) => {
request.resume();
request.on('end', () => {
clock.tick(requestDelay);
response.end('OK');
});
} | type GlobalClock = any; |
341 | (clock?: GlobalClock): Handler => (_request, response) => {
response.writeHead(200, {
'transfer-encoding': 'chunked',
});
response.flushHeaders();
setImmediate(async () => {
await pStreamPipeline(slowDataStream(clock), response);
});
} | type GlobalClock = any; |
342 | (server: ExtendedHttpTestServer, count: number, {relative} = {relative: false}): void => {
server.get('/', (request, response) => {
// eslint-disable-next-line unicorn/prevent-abbreviations
const searchParams = new URLSearchParams(request.url.split('?')[1]);
const page = Number(searchParams.get('page')) || 1;
... | type ExtendedHttpTestServer = {
http: http.Server;
url: string;
port: number;
hostname: string;
close: () => Promise<any>;
} & Express; |
343 | (request: ClientRequest) => {
t.true(request instanceof ClientRequest);
} | interface ClientRequest {
[reentry]?: boolean;
} |
344 | (response: Response) => {
t.true(response instanceof IncomingMessage);
t.false(response.readable);
t.is(response.statusCode, 200);
t.true(response.ip === '127.0.0.1' || response.ip === '::1');
} | type Response<T = unknown> = {
/**
The result of the request.
*/
body: T;
/**
The raw result of the request.
*/
rawBody: Buffer;
} & PlainResponse; |
345 | (retryStream?: Request) => {
const stream = retryStream ?? got.stream('');
globalRetryCount = stream.retryCount;
if (writeStream) {
writeStream.destroy();
}
writeStream = new PassThroughStream();
stream.pipe(writeStream);
stream.once('retry', (_retryCount, _error, createRetryStream) => {
... | class Request extends Duplex implements RequestEvents<Request> {
// @ts-expect-error - Ignoring for now.
override ['constructor']: typeof Request;
_noPipe?: boolean;
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/9568
options: Options;
response?: PlainResponse;
requestUrl?: URL;
redirectUr... |
346 | (retryStream?: Request) => {
const stream = retryStream ?? got.stream('');
globalRetryCount = stream.retryCount;
stream.resume();
stream.once('retry', (_retryCount, _error, createRetryStream) => {
fn(createRetryStream());
});
stream.once('data', () => {
stream.destroy(new Error('data event ... | class Request extends Duplex implements RequestEvents<Request> {
// @ts-expect-error - Ignoring for now.
override ['constructor']: typeof Request;
_noPipe?: boolean;
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/9568
options: Options;
response?: PlainResponse;
requestUrl?: URL;
redirectUr... |
347 | async (options: HttpServerOptions = {}): Promise<ExtendedHttpTestServer> => {
const server = express() as ExtendedHttpTestServer;
server.http = http.createServer(server);
server.set('etag', false);
if (options.bodyParser !== false) {
server.use(bodyParser.json({limit: '1mb', type: 'application/json', ...options... | type HttpServerOptions = {
bodyParser?: NextFunction | false;
}; |
348 | (t: ExecutionContext, server: ExtendedHttpTestServer, got: Got, clock: GlobalClock) => Promise<void> | void | type Got = {
/**
Sets `options.isStream` to `true`.
Returns a [duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with additional events:
- request
- response
- redirect
- uploadProgress
- downloadProgress
- error
*/
stream: GotStream;
/**
Returns an async iterator.
See pagin... |
349 | (t: ExecutionContext, server: ExtendedHttpTestServer, got: Got, clock: GlobalClock) => Promise<void> | void | type ExtendedHttpTestServer = {
http: http.Server;
url: string;
port: number;
hostname: string;
close: () => Promise<any>;
} & Express; |
350 | (t: ExecutionContext, server: ExtendedHttpTestServer, got: Got, clock: GlobalClock) => Promise<void> | void | type GlobalClock = any; |
351 | (t: ExecutionContext, server: ExtendedHttpsTestServer, got: Got, fakeTimer?: GlobalClock) => Promise<void> | void | type Got = {
/**
Sets `options.isStream` to `true`.
Returns a [duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with additional events:
- request
- response
- redirect
- uploadProgress
- downloadProgress
- error
*/
stream: GotStream;
/**
Returns an async iterator.
See pagin... |
352 | (t: ExecutionContext, server: ExtendedHttpsTestServer, got: Got, fakeTimer?: GlobalClock) => Promise<void> | void | type ExtendedHttpsTestServer = {
https: https.Server;
caKey: Buffer;
caCert: Buffer;
url: string;
port: number;
close: () => Promise<any>;
} & express.Express; |
353 | (t: ExecutionContext, server: ExtendedHttpsTestServer, got: Got, fakeTimer?: GlobalClock) => Promise<void> | void | type GlobalClock = any; |
354 | (t: ExecutionContext, server: ExtendedHttpServer) => Promise<void> | void | type ExtendedHttpServer = {
socketPath: string;
} & Server; |
355 | (options?: HttpsServerOptions, installFakeTimer = false): Macro<[RunTestWithHttpsServer]> => ({
async exec(t, run) {
const fakeTimer = installFakeTimer ? FakeTimers.install() as GlobalClock : undefined;
const server = await createHttpsTestServer(options);
const preparedGot = got.extend({
context: {
avaT... | type HttpsServerOptions = {
commonName?: string;
days?: number;
ciphers?: SecureContextOptions['ciphers'];
honorCipherOrder?: SecureContextOptions['honorCipherOrder'];
minVersion?: SecureContextOptions['minVersion'];
maxVersion?: SecureContextOptions['maxVersion'];
}; |
356 | async (options: HttpsServerOptions = {}): Promise<ExtendedHttpsTestServer> => {
const createCsr = pify(pem.createCSR as CreateCsr);
const createCertificate = pify(pem.createCertificate as CreateCertificate);
const caCsrResult = await createCsr({commonName: 'authority'});
const caResult = await createCertificate({
... | type HttpsServerOptions = {
commonName?: string;
days?: number;
ciphers?: SecureContextOptions['ciphers'];
honorCipherOrder?: SecureContextOptions['honorCipherOrder'];
minVersion?: SecureContextOptions['minVersion'];
maxVersion?: SecureContextOptions['maxVersion'];
}; |
357 | (error: Error) => {
if (error) {
throw error;
}
deferred.resolve();
} | type Error = NodeJS.ErrnoException; |
358 | (error: Error) => {
if (error) {
throw error;
}
deferred.resolve();
} | type Error = NodeJS.ErrnoException; |
359 | <T extends GotReturn>(options: Options, next: (options: Options) => T) => T | Promise<T> | class Options {
private _unixOptions?: NativeRequestOptions;
private _internals: InternalsType;
private _merging: boolean;
private readonly _init: OptionsInit[];
constructor(input?: string | URL | OptionsInit, options?: OptionsInit, defaults?: Options) {
assert.any([is.string, is.urlInstance, is.object, is.unde... |
360 | (options: Options) => T | class Options {
private _unixOptions?: NativeRequestOptions;
private _internals: InternalsType;
private _merging: boolean;
private readonly _init: OptionsInit[];
constructor(input?: string | URL | OptionsInit, options?: OptionsInit, defaults?: Options) {
assert.any([is.string, is.urlInstance, is.object, is.unde... |
361 | (options: OptionsOfTextResponseBody): CancelableRequest<Response<string>> | type OptionsOfTextResponseBody = Merge<OptionsInit, {isStream?: false; resolveBodyOnly?: false; responseType?: 'text'}>; |
362 | <T>(options: OptionsOfJSONResponseBody): CancelableRequest<Response<T>> | type OptionsOfJSONResponseBody = Merge<OptionsInit, {isStream?: false; resolveBodyOnly?: false; responseType?: 'json'}>; |
363 | (options: OptionsOfBufferResponseBody): CancelableRequest<Response<Buffer>> | type OptionsOfBufferResponseBody = Merge<OptionsInit, {isStream?: false; resolveBodyOnly?: false; responseType: 'buffer'}>; |
364 | (options: OptionsOfUnknownResponseBody): CancelableRequest<Response> | type OptionsOfUnknownResponseBody = Merge<OptionsInit, {isStream?: false; resolveBodyOnly?: false}>; |
365 | (options: OptionsInit): CancelableRequest | Request | type OptionsInit =
Except<Partial<InternalsType>, 'hooks' | 'retry'>
& {
hooks?: Partial<Hooks>;
retry?: Partial<RetryOptions>;
}; |
366 | (defaults: InstanceDefaults): Got => {
defaults = {
options: new Options(undefined, undefined, defaults.options),
handlers: [...defaults.handlers],
mutableDefaults: defaults.mutableDefaults,
};
Object.defineProperty(defaults, 'mutableDefaults', {
enumerable: true,
configurable: false,
writable: false,
... | type InstanceDefaults = {
/**
An object containing the default options of Got.
*/
options: Options;
/**
An array of functions. You execute them directly by calling `got()`.
They are some sort of "global hooks" - these functions are called first.
The last handler (*it's hidden*) is either `asPromise` or `asStre... |
367 | (normalized: Options): GotReturn => {
// Note: `options` is `undefined` when `new Options(...)` fails
request.options = normalized;
request._noPipe = !normalized.isStream;
void request.flush();
if (normalized.isStream) {
return request;
}
if (!promise) {
promise = asPromise(request);
}... | class Options {
private _unixOptions?: NativeRequestOptions;
private _internals: InternalsType;
private _merging: boolean;
private readonly _init: OptionsInit[];
constructor(input?: string | URL | OptionsInit, options?: OptionsInit, defaults?: Options) {
assert.any([is.string, is.urlInstance, is.object, is.unde... |
368 | (newOptions: Options): GotReturn => {
const handler = defaults.handlers[iteration++] ?? lastHandler;
const result = handler(newOptions, iterateHandlers) as GotReturn;
if (is.promise(result) && !request.options.isStream) {
if (!promise) {
promise = asPromise(request);
}
if (result !== promis... | class Options {
private _unixOptions?: NativeRequestOptions;
private _internals: InternalsType;
private _merging: boolean;
private readonly _init: OptionsInit[];
constructor(input?: string | URL | OptionsInit, options?: OptionsInit, defaults?: Options) {
assert.any([is.string, is.urlInstance, is.object, is.unde... |
369 | (request: ClientRequest) => void | interface ClientRequest {
[reentry]?: boolean;
} |
370 | (progress: Progress) => void | type Progress = {
percent: number;
transferred: number;
total?: number;
}; |
371 | constructor(url: UrlType, options?: OptionsType, defaults?: DefaultsType) {
super({
// Don't destroy immediately, as the error may be emitted on unsuccessful retry
autoDestroy: false,
// It needs to be zero because we're just proxying the data to another stream
highWaterMark: 0,
});
this._downloadedS... | type DefaultsType = ConstructorParameters<typeof Options>[2]; |
372 | constructor(url: UrlType, options?: OptionsType, defaults?: DefaultsType) {
super({
// Don't destroy immediately, as the error may be emitted on unsuccessful retry
autoDestroy: false,
// It needs to be zero because we're just proxying the data to another stream
highWaterMark: 0,
});
this._downloadedS... | type UrlType = ConstructorParameters<typeof Options>[0]; |
373 | constructor(url: UrlType, options?: OptionsType, defaults?: DefaultsType) {
super({
// Don't destroy immediately, as the error may be emitted on unsuccessful retry
autoDestroy: false,
// It needs to be zero because we're just proxying the data to another stream
highWaterMark: 0,
});
this._downloadedS... | type OptionsType = ConstructorParameters<typeof Options>[1]; |
374 | _beforeError(error: Error): void {
if (this._stopReading) {
return;
}
const {response, options} = this;
const attemptCount = this.retryCount + (error.name === 'RetryError' ? 0 : 1);
this._stopReading = true;
if (!(error instanceof RequestError)) {
error = new RequestError(error.message, error, this... | type Error = NodeJS.ErrnoException; |
375 | _beforeError(error: Error): void {
if (this._stopReading) {
return;
}
const {response, options} = this;
const attemptCount = this.retryCount + (error.name === 'RetryError' ? 0 : 1);
this._stopReading = true;
if (!(error instanceof RequestError)) {
error = new RequestError(error.message, error, this... | type Error = NodeJS.ErrnoException; |
376 | (updatedOptions?: OptionsInit) => {
const request = new Request(options.url, updatedOptions, options);
request.retryCount = this.retryCount + 1;
process.nextTick(() => {
void request.flush();
});
return request;
} | type OptionsInit =
Except<Partial<InternalsType>, 'hooks' | 'retry'>
& {
hooks?: Partial<Hooks>;
retry?: Partial<RetryOptions>;
}; |
377 | (error: Error) => {
this._aborted = true;
// Force clean-up, because some packages don't do this.
// TODO: Fix decompress-response
response.destroy();
this._beforeError(new ReadError(error, this));
} | type Error = NodeJS.ErrnoException; |
378 | (error: Error) => {
this._aborted = true;
// Force clean-up, because some packages don't do this.
// TODO: Fix decompress-response
response.destroy();
this._beforeError(new ReadError(error, this));
} | type Error = NodeJS.ErrnoException; |
379 | private _onRequest(request: ClientRequest): void {
const {options} = this;
const {timeout, url} = options;
timer(request);
if (this.options.http2) {
// Unset stream timeout, as the `timeout` option was used only for connection timeout.
request.setTimeout(0);
}
this._cancelTimeouts = timedOut(reques... | interface ClientRequest {
[reentry]?: boolean;
} |
380 | (error: Error) => {
this._aborted = true;
// Force clean-up, because some packages (e.g. nock) don't do this.
request.destroy();
error = error instanceof TimedOutTimeoutError ? new TimeoutError(error, this.timings!, this) : new RequestError(error.message, error, this);
this._beforeError(error);
} | type Error = NodeJS.ErrnoException; |
381 | (error: Error) => {
this._aborted = true;
// Force clean-up, because some packages (e.g. nock) don't do this.
request.destroy();
error = error instanceof TimedOutTimeoutError ? new TimeoutError(error, this.timings!, this) : new RequestError(error.message, error, this);
this._beforeError(error);
} | type Error = NodeJS.ErrnoException; |
382 | private async _error(error: RequestError): Promise<void> {
try {
if (error instanceof HTTPError && !this.options.throwHttpErrors) {
// This branch can be reached only when using the Promise API
// Skip calling the hooks on purpose.
// See https://github.com/sindresorhus/got/issues/2103
} else {
... | class RequestError extends Error {
input?: string;
code: string;
override stack!: string;
declare readonly options: Options;
readonly response?: Response;
readonly request?: Request;
readonly timings?: Timings;
constructor(message: string, error: Partial<Error & {code?: string}>, self: Request | Options) {
... |
383 | (response: PlainResponse): boolean => {
const {statusCode} = response;
const limitStatusCode = response.request.options.followRedirect ? 299 : 399;
return (statusCode >= 200 && statusCode <= limitStatusCode) || statusCode === 304;
} | type PlainResponse = {
/**
The original request URL.
*/
requestUrl: URL;
/**
The redirect URLs.
*/
redirectUrls: URL[];
/**
- `options` - The Got options that were set on this request.
__Note__: This is not a [http.ClientRequest](https://nodejs.org/api/http.html#http_class_http_clientrequest).
*/
reques... |
384 | constructor(error: Error, response: Response) {
const {options} = response.request;
super(`${error.message} in "${options.url!.toString()}"`, error, response.request);
this.name = 'ParseError';
this.code = 'ERR_BODY_PARSE_FAILURE';
} | type Response<T = unknown> = {
/**
The result of the request.
*/
body: T;
/**
The raw result of the request.
*/
rawBody: Buffer;
} & PlainResponse; |
385 | constructor(error: Error, response: Response) {
const {options} = response.request;
super(`${error.message} in "${options.url!.toString()}"`, error, response.request);
this.name = 'ParseError';
this.code = 'ERR_BODY_PARSE_FAILURE';
} | type Error = NodeJS.ErrnoException; |
386 | constructor(error: Error, response: Response) {
const {options} = response.request;
super(`${error.message} in "${options.url!.toString()}"`, error, response.request);
this.name = 'ParseError';
this.code = 'ERR_BODY_PARSE_FAILURE';
} | type Error = NodeJS.ErrnoException; |
387 | (response: Response, responseType: ResponseType, parseJson: ParseJsonFunction, encoding?: BufferEncoding): unknown => {
const {rawBody} = response;
try {
if (responseType === 'text') {
return rawBody.toString(encoding);
}
if (responseType === 'json') {
return rawBody.length === 0 ? '' : parseJson(rawBod... | type Response<T = unknown> = {
/**
The result of the request.
*/
body: T;
/**
The raw result of the request.
*/
rawBody: Buffer;
} & PlainResponse; |
388 | (response: Response, responseType: ResponseType, parseJson: ParseJsonFunction, encoding?: BufferEncoding): unknown => {
const {rawBody} = response;
try {
if (responseType === 'text') {
return rawBody.toString(encoding);
}
if (responseType === 'json') {
return rawBody.length === 0 ? '' : parseJson(rawBod... | type ResponseType = 'json' | 'buffer' | 'text'; |
389 | (response: Response, responseType: ResponseType, parseJson: ParseJsonFunction, encoding?: BufferEncoding): unknown => {
const {rawBody} = response;
try {
if (responseType === 'text') {
return rawBody.toString(encoding);
}
if (responseType === 'json') {
return rawBody.length === 0 ? '' : parseJson(rawBod... | type ParseJsonFunction = (text: string) => unknown; |
390 | constructor(request: Request) {
super(`Redirected ${request.options.maxRedirects} times. Aborting.`, {}, request);
this.name = 'MaxRedirectsError';
this.code = 'ERR_TOO_MANY_REDIRECTS';
} | class Request extends Duplex implements RequestEvents<Request> {
// @ts-expect-error - Ignoring for now.
override ['constructor']: typeof Request;
_noPipe?: boolean;
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/9568
options: Options;
response?: PlainResponse;
requestUrl?: URL;
redirectUr... |
391 | constructor(response: PlainResponse) {
super(`Response code ${response.statusCode} (${response.statusMessage!})`, {}, response.request);
this.name = 'HTTPError';
this.code = 'ERR_NON_2XX_3XX_RESPONSE';
} | type PlainResponse = {
/**
The original request URL.
*/
requestUrl: URL;
/**
The redirect URLs.
*/
redirectUrls: URL[];
/**
- `options` - The Got options that were set on this request.
__Note__: This is not a [http.ClientRequest](https://nodejs.org/api/http.html#http_class_http_clientrequest).
*/
reques... |
392 | constructor(error: Error, request: Request) {
super(error.message, error, request);
this.name = 'CacheError';
this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_CACHE_ACCESS' : this.code;
} | type Error = NodeJS.ErrnoException; |
393 | constructor(error: Error, request: Request) {
super(error.message, error, request);
this.name = 'CacheError';
this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_CACHE_ACCESS' : this.code;
} | type Error = NodeJS.ErrnoException; |
394 | constructor(error: Error, request: Request) {
super(error.message, error, request);
this.name = 'CacheError';
this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_CACHE_ACCESS' : this.code;
} | class Request extends Duplex implements RequestEvents<Request> {
// @ts-expect-error - Ignoring for now.
override ['constructor']: typeof Request;
_noPipe?: boolean;
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/9568
options: Options;
response?: PlainResponse;
requestUrl?: URL;
redirectUr... |
395 | constructor(error: Error, request: Request) {
super(error.message, error, request);
this.name = 'UploadError';
this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_UPLOAD' : this.code;
} | type Error = NodeJS.ErrnoException; |
396 | constructor(error: Error, request: Request) {
super(error.message, error, request);
this.name = 'UploadError';
this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_UPLOAD' : this.code;
} | type Error = NodeJS.ErrnoException; |
397 | constructor(error: Error, request: Request) {
super(error.message, error, request);
this.name = 'UploadError';
this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_UPLOAD' : this.code;
} | class Request extends Duplex implements RequestEvents<Request> {
// @ts-expect-error - Ignoring for now.
override ['constructor']: typeof Request;
_noPipe?: boolean;
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/9568
options: Options;
response?: PlainResponse;
requestUrl?: URL;
redirectUr... |
398 | constructor(error: TimedOutTimeoutError, timings: Timings, request: Request) {
super(error.message, error, request);
this.name = 'TimeoutError';
this.event = error.event;
this.timings = timings;
} | class Request extends Duplex implements RequestEvents<Request> {
// @ts-expect-error - Ignoring for now.
override ['constructor']: typeof Request;
_noPipe?: boolean;
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/9568
options: Options;
response?: PlainResponse;
requestUrl?: URL;
redirectUr... |
399 | constructor(error: Error, request: Request) {
super(error.message, error, request);
this.name = 'ReadError';
this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_READING_RESPONSE_STREAM' : this.code;
} | type Error = NodeJS.ErrnoException; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.