From 34d650220abba2ef1c2011cc9c508d2e2a7f28fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 11 Apr 2021 15:57:33 +0200 Subject: [PATCH] typings: add types for internalBinding('util') PR-URL: https://github.com/nodejs/node/pull/38200 Reviewed-By: James M Snell Reviewed-By: Bradley Farias --- tsconfig.json | 1 + typings/internalBinding/util.d.ts | 47 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 typings/internalBinding/util.d.ts diff --git a/tsconfig.json b/tsconfig.json index 93abd26727e44c..80189489b6c02f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "exclude": ["src","tools","out"], "files": [ "./typings/internalBinding/fs.d.ts", + "./typings/internalBinding/util.d.ts", "./typings/internalBinding.d.ts", "./typings/primordials.d.ts" ], diff --git a/typings/internalBinding/util.d.ts b/typings/internalBinding/util.d.ts new file mode 100644 index 00000000000000..2158c7ed688bcd --- /dev/null +++ b/typings/internalBinding/util.d.ts @@ -0,0 +1,47 @@ +declare namespace InternalUtilBinding { + class WeakReference { + constructor(value: T); + get(): undefined | T; + incRef(): void; + decRef(): void; + } +} + +declare function InternalBinding(binding: 'util'): { + // PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES, defined in src/env.h + alpn_buffer_private_symbol: 0; + arrow_message_private_symbol: 1; + contextify_context_private_symbol: 2; + contextify_global_private_symbol: 3; + decorated_private_symbol: 4; + napi_type_tag: 5; + napi_wrapper: 6; + untransferable_object_private_symbol: 7; + + kPending: 0; + kFulfilled: 1; + kRejected: 2; + + getHiddenValue(object: object, index: number): any; + setHiddenValue(object: object, index: number, value: any): boolean; + getPromiseDetails(promise: any): undefined | [state: 0] | [state: 1 | 2, result: any]; + getProxyDetails(proxy: any, fullProxy?: boolean): undefined | any | [target: any, handler: any]; + previewEntries(object: object, slowPath?: boolean): undefined | any[] | [entries: any[], isKeyValue: boolean]; + getOwnNonIndexProperties(object: object, filter: number): Array; + getConstructorName(object: object): string; + getExternalValue(value: any): bigint; + sleep(msec: number): void; + isConstructor(fn: Function): boolean; + arrayBufferViewHasBuffer(view: ArrayBufferView): boolean; + propertyFilter: { + ALL_PROPERTIES: 0; + ONLY_WRITABLE: 1; + ONLY_ENUMERABLE: 2; + ONLY_CONFIGURABLE: 4; + SKIP_STRINGS: 8; + SKIP_SYMBOLS: 16; + }; + shouldAbortOnUncaughtToggle: [shouldAbort: 0 | 1]; + WeakReference: typeof InternalUtilBinding.WeakReference; + guessHandleType(fd: number): 'TCP' | 'TTY' | 'UDP' | 'FILE' | 'PIPE' | 'UNKNOWN'; +};