Skip to content

typings: add types for "http_parser" and "options" bindings #38239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"exclude": ["src","tools","out"],
"files": [
"./typings/internalBinding/fs.d.ts",
"./typings/internalBinding/http_parser.d.ts",
"./typings/internalBinding/options.d.ts",
"./typings/internalBinding/serdes.d.ts",
"./typings/internalBinding/util.d.ts",
"./typings/internalBinding.d.ts",
Expand Down
42 changes: 42 additions & 0 deletions typings/internalBinding/http_parser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
declare namespace InternalHttpParserBinding {
class HTTPParser {
static REQUEST: 1;
static RESPONSE: 2;

static kOnMessageBegin: 0;
static kOnHeaders: 1;
static kOnHeadersComplete: 2;
static kOnBody: 3;
static kOnMessageComplete: 4;
static kOnExecute: 5;
static kOnTimeout: 6;

static kLenientNone: number;
static kLenientHeaders: number;
static kLenientChunkedLength: number;
static kLenientKeepAlive: number;
static kLenientAll: number;

close(): void;
free(): void;
execute(buffer: Buffer): Error | Buffer;
finish(): Error | Buffer;
initialize(
type: number,
resource: object,
maxHeaderSize?: number,
lenient?: number,
headersTimeout?: number,
): void;
pause(): void;
resume(): void;
consume(stream: object): void;
unconsume(): void;
getCurrentBuffer(): Buffer;
}
}

declare function InternalBinding(binding: 'http_parser'): {
methods: string[];
HTTPParser: typeof InternalHttpParserBinding.HTTPParser;
};
34 changes: 34 additions & 0 deletions typings/internalBinding/options.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
declare function InternalBinding(binding: 'options'): {
getOptions(): {
options: Map<
string,
{
helpText: string;
envVarSettings: 0 | 1;
} & (
| { type: 0 | 1; value: undefined }
| { type: 2; value: boolean }
| { type: 3 | 4; value: number }
| { type: 5; value: string }
| { type: 6; value: { host: string; port: number } }
| { type: 7; value: string[] }
)
>;
aliases: Map<string, string[]>;
};
envSettings: {
kAllowedInEnvironment: 0;
kDisallowedInEnvironment: 1;
};
shouldNotRegisterESMLoader: boolean;
types: {
kNoOp: 0;
kV8Option: 1;
kBoolean: 2;
kInteger: 3;
kUInteger: 4;
kString: 5;
kHostPort: 6;
kStringList: 7;
};
};