Skip to content

Commit b87f1be

Browse files
committed
typings: add types for "http_parser" and "options" bindings
PR-URL: nodejs#38239 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniele Belardi <[email protected]>
1 parent 1c8b295 commit b87f1be

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"exclude": ["src","tools","out"],
44
"files": [
55
"./typings/internalBinding/fs.d.ts",
6+
"./typings/internalBinding/http_parser.d.ts",
7+
"./typings/internalBinding/options.d.ts",
68
"./typings/internalBinding/serdes.d.ts",
79
"./typings/internalBinding/util.d.ts",
810
"./typings/internalBinding.d.ts",
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
declare namespace InternalHttpParserBinding {
2+
class HTTPParser {
3+
static REQUEST: 1;
4+
static RESPONSE: 2;
5+
6+
static kOnMessageBegin: 0;
7+
static kOnHeaders: 1;
8+
static kOnHeadersComplete: 2;
9+
static kOnBody: 3;
10+
static kOnMessageComplete: 4;
11+
static kOnExecute: 5;
12+
static kOnTimeout: 6;
13+
14+
static kLenientNone: number;
15+
static kLenientHeaders: number;
16+
static kLenientChunkedLength: number;
17+
static kLenientKeepAlive: number;
18+
static kLenientAll: number;
19+
20+
close(): void;
21+
free(): void;
22+
execute(buffer: Buffer): Error | Buffer;
23+
finish(): Error | Buffer;
24+
initialize(
25+
type: number,
26+
resource: object,
27+
maxHeaderSize?: number,
28+
lenient?: number,
29+
headersTimeout?: number,
30+
): void;
31+
pause(): void;
32+
resume(): void;
33+
consume(stream: object): void;
34+
unconsume(): void;
35+
getCurrentBuffer(): Buffer;
36+
}
37+
}
38+
39+
declare function InternalBinding(binding: 'http_parser'): {
40+
methods: string[];
41+
HTTPParser: typeof InternalHttpParserBinding.HTTPParser;
42+
};

typings/internalBinding/options.d.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
declare function InternalBinding(binding: 'options'): {
2+
getOptions(): {
3+
options: Map<
4+
string,
5+
{
6+
helpText: string;
7+
envVarSettings: 0 | 1;
8+
} & (
9+
| { type: 0 | 1; value: undefined }
10+
| { type: 2; value: boolean }
11+
| { type: 3 | 4; value: number }
12+
| { type: 5; value: string }
13+
| { type: 6; value: { host: string; port: number } }
14+
| { type: 7; value: string[] }
15+
)
16+
>;
17+
aliases: Map<string, string[]>;
18+
};
19+
envSettings: {
20+
kAllowedInEnvironment: 0;
21+
kDisallowedInEnvironment: 1;
22+
};
23+
shouldNotRegisterESMLoader: boolean;
24+
types: {
25+
kNoOp: 0;
26+
kV8Option: 1;
27+
kBoolean: 2;
28+
kInteger: 3;
29+
kUInteger: 4;
30+
kString: 5;
31+
kHostPort: 6;
32+
kStringList: 7;
33+
};
34+
};

0 commit comments

Comments
 (0)