Skip to content

Commit 3377eb9

Browse files
committed
typings: add types for internalBinding('util')
PR-URL: #38200 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
1 parent cb2bdc6 commit 3377eb9

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"exclude": ["src","tools","out"],
44
"files": [
55
"./typings/internalBinding/fs.d.ts",
6+
"./typings/internalBinding/util.d.ts",
67
"./typings/internalBinding.d.ts",
78
"./typings/primordials.d.ts"
89
],

typings/internalBinding/util.d.ts

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
declare namespace InternalUtilBinding {
2+
class WeakReference<T extends object> {
3+
constructor(value: T);
4+
get(): undefined | T;
5+
incRef(): void;
6+
decRef(): void;
7+
}
8+
}
9+
10+
declare function InternalBinding(binding: 'util'): {
11+
// PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES, defined in src/env.h
12+
alpn_buffer_private_symbol: 0;
13+
arrow_message_private_symbol: 1;
14+
contextify_context_private_symbol: 2;
15+
contextify_global_private_symbol: 3;
16+
decorated_private_symbol: 4;
17+
napi_type_tag: 5;
18+
napi_wrapper: 6;
19+
untransferable_object_private_symbol: 7;
20+
21+
kPending: 0;
22+
kFulfilled: 1;
23+
kRejected: 2;
24+
25+
getHiddenValue(object: object, index: number): any;
26+
setHiddenValue(object: object, index: number, value: any): boolean;
27+
getPromiseDetails(promise: any): undefined | [state: 0] | [state: 1 | 2, result: any];
28+
getProxyDetails(proxy: any, fullProxy?: boolean): undefined | any | [target: any, handler: any];
29+
previewEntries(object: object, slowPath?: boolean): undefined | any[] | [entries: any[], isKeyValue: boolean];
30+
getOwnNonIndexProperties(object: object, filter: number): Array<string | symbol>;
31+
getConstructorName(object: object): string;
32+
getExternalValue(value: any): bigint;
33+
sleep(msec: number): void;
34+
isConstructor(fn: Function): boolean;
35+
arrayBufferViewHasBuffer(view: ArrayBufferView): boolean;
36+
propertyFilter: {
37+
ALL_PROPERTIES: 0;
38+
ONLY_WRITABLE: 1;
39+
ONLY_ENUMERABLE: 2;
40+
ONLY_CONFIGURABLE: 4;
41+
SKIP_STRINGS: 8;
42+
SKIP_SYMBOLS: 16;
43+
};
44+
shouldAbortOnUncaughtToggle: [shouldAbort: 0 | 1];
45+
WeakReference: typeof InternalUtilBinding.WeakReference;
46+
guessHandleType(fd: number): 'TCP' | 'TTY' | 'UDP' | 'FILE' | 'PIPE' | 'UNKNOWN';
47+
};

0 commit comments

Comments
 (0)