UNPKG

1.18 kBTypeScriptView Raw
1// Type definitions for agent-base 4.2
2// Project: https://github.com/TooTallNate/node-agent-base#readme
3// Definitions by: Christopher Quadflieg <https://github.com/Shinigami92>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/// <reference types="node" />
7import { EventEmitter } from 'events';
8
9declare namespace Agent {
10 type AgentCallback = (
11 req?: any,
12 opts?: {
13 secureEndpoint: boolean;
14 }
15 ) => void;
16
17 interface AgentOptions {
18 timeout?: number;
19 host?: string;
20 port?: number;
21 [key: string]: any;
22 }
23
24 interface Agent extends EventEmitter {
25 _promisifiedCallback: boolean;
26 timeout: number | null;
27 options?: AgentOptions;
28 callback: AgentCallback;
29 addRequest: (req?: any, opts?: any) => void;
30 freeSocket: (socket: any, opts: any) => void;
31 }
32}
33
34/**
35 * Base `http.Agent` implementation.
36 * No pooling/keep-alive is implemented by default.
37 */
38declare function Agent(opts?: Agent.AgentOptions): Agent.Agent;
39declare function Agent(
40 callback: Agent.AgentCallback,
41 opts?: Agent.AgentOptions
42): Agent.Agent;
43
44export = Agent;