提交 a05419de 编写于 作者: B Benjamin Pasero

update d.ts (node.js, electron) to latest

上级 eda31573
// Type definitions for Electron 2.0.0-beta.2
// Type definitions for Electron 2.0.5
// Project: http://electron.atom.io/
// Definitions by: The Electron Team <https://github.com/electron/electron>
// Definitions: https://github.com/electron/electron-typescript-definitions
......@@ -204,7 +204,9 @@ declare namespace Electron {
* event.preventDefault() will prevent the default behaviour, which is terminating
* the application. Note: If application quit was initiated by
* autoUpdater.quitAndInstall() then before-quit is emitted after emitting close
* event on all windows and closing them.
* event on all windows and closing them. Note: On Windows, this event will not be
* emitted if the app is closed due to a shutdown/restart of the system or a user
* logout.
*/
on(event: 'before-quit', listener: (event: Event) => void): this;
once(event: 'before-quit', listener: (event: Event) => void): this;
......@@ -446,7 +448,9 @@ declare namespace Electron {
removeListener(event: 'open-url', listener: (event: Event,
url: string) => void): this;
/**
* Emitted when the application is quitting.
* Emitted when the application is quitting. Note: On Windows, this event will not
* be emitted if the app is closed due to a shutdown/restart of the system or a
* user logout.
*/
on(event: 'quit', listener: (event: Event,
exitCode: number) => void): this;
......@@ -587,7 +591,9 @@ declare namespace Electron {
* Emitted when all windows have been closed and the application will quit. Calling
* event.preventDefault() will prevent the default behaviour, which is terminating
* the application. See the description of the window-all-closed event for the
* differences between the will-quit and window-all-closed events.
* differences between the will-quit and window-all-closed events. Note: On
* Windows, this event will not be emitted if the app is closed due to a
* shutdown/restart of the system or a user logout.
*/
on(event: 'will-quit', listener: (event: Event) => void): this;
once(event: 'will-quit', listener: (event: Event) => void): this;
......@@ -659,9 +665,10 @@ declare namespace Electron {
getGPUFeatureStatus(): GPUFeatureStatus;
getJumpListSettings(): JumpListSettings;
/**
* Note: When distributing your packaged app, you have to also ship the locales
* folder. Note: On Windows you have to call it after the ready events gets
* emitted.
* To set the locale, you'll want to use a command line switch at app startup,
* which may be found here. Note: When distributing your packaged app, you have to
* also ship the locales folder. Note: On Windows you have to call it after the
* ready events gets emitted.
*/
getLocale(): string;
/**
......@@ -975,6 +982,13 @@ declare namespace Electron {
static fromId(id: number): BrowserView;
static fromWebContents(webContents: WebContents): BrowserView | null;
static getAllViews(): BrowserView[];
/**
* Force closing the view, the unload and beforeunload events won't be emitted for
* the web page. After you're done with a view, call this function in order to free
* memory and other resources as soon as possible.
*/
destroy(): void;
isDestroyed(): boolean;
setAutoResize(options: AutoResizeOptions): void;
setBackgroundColor(color: string): void;
/**
......@@ -6757,7 +6771,8 @@ declare namespace Electron {
/**
* Add a type of vibrancy effect to the window, only on macOS. Can be
* appearance-based, light, dark, titlebar, selection, menu, popover, sidebar,
* medium-light or ultra-dark.
* medium-light or ultra-dark. Please note that using frame: false in combination
* with a vibrancy value requires that you use a non-default titleBarStyle as well.
*/
vibrancy?: ('appearance-based' | 'light' | 'dark' | 'titlebar' | 'selection' | 'menu' | 'popover' | 'sidebar' | 'medium-light' | 'ultra-dark');
/**
......@@ -7967,9 +7982,9 @@ declare namespace Electron {
interface ProgressBarOptions {
/**
* Mode for the progress bar. Can be none, normal, indeterminate, error, or paused.
* Mode for the progress bar. Can be none, normal, indeterminate, error or paused.
*/
mode: ('none' | 'normal' | 'indeterminate' | 'error');
mode: ('none' | 'normal' | 'indeterminate' | 'error' | 'paused');
}
interface Provider {
......@@ -8177,11 +8192,26 @@ declare namespace Electron {
}
interface SizeOptions {
/**
* true to make the webview container automatically resize within the bounds
* specified by the attributes normal, min and max.
*/
enableAutoSize?: boolean;
/**
* Normal size of the page. This can be used in combination with the attribute to
* manually resize the webview guest contents.
*/
normal?: Normal;
normal?: Size;
/**
* Minimum size of the page. This can be used in combination with the attribute to
* manually resize the webview guest contents.
*/
min?: Size;
/**
* Maximium size of the page. This can be used in combination with the attribute to
* manually resize the webview guest contents.
*/
max?: Size;
}
interface SourcesOptions {
......@@ -8522,11 +8552,6 @@ declare namespace Electron {
canRotate: boolean;
}
interface Normal {
width: number;
height: number;
}
interface Options {
}
......
......@@ -13,11 +13,15 @@
// Deividas Bakanas <https://github.com/DeividasBakanas>
// Kelvin Jin <https://github.com/kjin>
// Alvis HT Tang <https://github.com/alvis>
// Oliver Joseph Ash <https://github.com/OliverJAsh>
// Sebastian Silbermann <https://github.com/eps1lon>
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
// Alberto Schiabel <https://github.com/jkomyno>
// Huw <https://github.com/hoo29>
// Nicolas Even <https://github.com/n-e>
// Bruno Scheufler <https://github.com/brunoscheufler>
// Hoàng Văn Khải <https://github.com/KSXGitHub>
// Lishude <https://github.com/islishude>
// Andrew Makarov <https://github.com/r3nya>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
......@@ -31,6 +35,7 @@ interface Console {
Console: NodeJS.ConsoleConstructor;
assert(value: any, message?: string, ...optionalParams: any[]): void;
dir(obj: any, options?: NodeJS.InspectOptions): void;
debug(message?: any, ...optionalParams: any[]): void;
error(message?: any, ...optionalParams: any[]): void;
info(message?: any, ...optionalParams: any[]): void;
log(message?: any, ...optionalParams: any[]): void;
......@@ -124,12 +129,17 @@ interface NodeRequireFunction {
// ### BEGIN VSCODE MODIFICATION ###
// interface NodeRequire extends NodeRequireFunction {
// resolve(id: string): string;
// resolve: RequireResolve;
// cache: any;
// extensions: NodeExtensions;
// main: NodeModule | undefined;
// }
// interface RequireResolve {
// (id: string, options?: { paths?: string[]; }): string;
// paths(request: string): string[] | null;
// }
// interface NodeExtensions {
// '.js': (m: NodeModule, filename: string) => any;
// '.json': (m: NodeModule, filename: string) => any;
......@@ -216,10 +226,6 @@ declare var Buffer: {
*/
new(buffer: Buffer): Buffer;
prototype: Buffer;
/**
* Allocates a new Buffer using an {array} of octets.
*/
from(array: any[]): Buffer;
/**
* When passed a reference to the .buffer property of a TypedArray instance,
* the newly created Buffer will share the same allocated memory as the TypedArray.
......@@ -230,9 +236,10 @@ declare var Buffer: {
*/
from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
/**
* Copies the passed {buffer} data onto a new Buffer instance.
* Creates a new Buffer using the passed {data}
* @param data data to create a new Buffer
*/
from(buffer: Buffer): Buffer;
from(data: any[] | string | Buffer | ArrayBuffer /*| TypedArray*/): Buffer;
/**
* Creates a new Buffer containing the given JavaScript string {str}.
* If provided, the {encoding} parameter identifies the character encoding.
......@@ -472,6 +479,7 @@ declare namespace NodeJS {
rss: number;
heapTotal: number;
heapUsed: number;
external: number;
}
export interface CpuUsage {
......@@ -527,6 +535,7 @@ declare namespace NodeJS {
}
export interface WriteStream extends Socket {
readonly writableHighWaterMark: number;
columns?: number;
rows?: number;
_write(chunk: any, encoding: string, callback: Function): void;
......@@ -538,6 +547,7 @@ declare namespace NodeJS {
destroy(error?: Error): void;
}
export interface ReadStream extends Socket {
readonly readableHighWaterMark: number;
isRaw?: boolean;
setRawMode?(mode: boolean): void;
_read(size: number): void;
......@@ -558,6 +568,7 @@ declare namespace NodeJS {
abort(): void;
chdir(directory: string): void;
cwd(): string;
debugPort: number;
emitWarning(warning: string | Error, name?: string, ctor?: Function): void;
env: ProcessEnv;
exit(code?: number): never;
......@@ -792,6 +803,7 @@ declare namespace NodeJS {
class Module {
static runMain(): void;
static wrap(code: string): string;
static builtinModules: string[];
static Module: typeof Module;
......@@ -891,7 +903,7 @@ declare module "querystring" {
decodeURIComponent?: Function;
}
interface ParsedUrlQuery { [key: string]: string | string[]; }
interface ParsedUrlQuery { [key: string]: string | string[] | undefined; }
export function stringify<T>(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string;
export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery;
......@@ -944,6 +956,7 @@ declare module "http" {
'access-control-allow-headers'?: string;
'accept-patch'?: string;
'accept-ranges'?: string;
'authorization'?: string;
'age'?: string;
'allow'?: string;
'alt-svc'?: string;
......@@ -1133,6 +1146,7 @@ declare module "http" {
}
export class Agent {
maxFreeSockets: number;
maxSockets: number;
sockets: any;
requests: any;
......@@ -1468,27 +1482,28 @@ declare module "zlib" {
export function createInflateRaw(options?: ZlibOptions): InflateRaw;
export function createUnzip(options?: ZlibOptions): Unzip;
export function deflate(buf: Buffer | string, callback: (error: Error | null, result: Buffer) => void): void;
export function deflate(buf: Buffer | string, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function deflateSync(buf: Buffer | string, options?: ZlibOptions): Buffer;
export function deflateRaw(buf: Buffer | string, callback: (error: Error | null, result: Buffer) => void): void;
export function deflateRaw(buf: Buffer | string, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): Buffer;
export function gzip(buf: Buffer | string, callback: (error: Error | null, result: Buffer) => void): void;
export function gzip(buf: Buffer | string, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function gzipSync(buf: Buffer | string, options?: ZlibOptions): Buffer;
export function gunzip(buf: Buffer | string, callback: (error: Error | null, result: Buffer) => void): void;
export function gunzip(buf: Buffer | string, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function gunzipSync(buf: Buffer | string, options?: ZlibOptions): Buffer;
export function inflate(buf: Buffer | string, callback: (error: Error | null, result: Buffer) => void): void;
export function inflate(buf: Buffer | string, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function inflateSync(buf: Buffer | string, options?: ZlibOptions): Buffer;
export function inflateRaw(buf: Buffer | string, callback: (error: Error | null, result: Buffer) => void): void;
export function inflateRaw(buf: Buffer | string, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function inflateRawSync(buf: Buffer | string, options?: ZlibOptions): Buffer;
export function unzip(buf: Buffer | string, callback: (error: Error | null, result: Buffer) => void): void;
export function unzip(buf: Buffer | string, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function unzipSync(buf: Buffer | string, options?: ZlibOptions): Buffer;
type InputType = string | Buffer | DataView /* | TypedArray */;
export function deflate(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
export function deflate(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function deflateSync(buf: InputType, options?: ZlibOptions): Buffer;
export function deflateRaw(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
export function deflateRaw(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function deflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
export function gzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
export function gzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function gzipSync(buf: InputType, options?: ZlibOptions): Buffer;
export function gunzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
export function gunzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer;
export function inflate(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
export function inflate(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function inflateSync(buf: InputType, options?: ZlibOptions): Buffer;
export function inflateRaw(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
export function inflateRaw(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function inflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
export function unzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
export function unzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
export function unzipSync(buf: InputType, options?: ZlibOptions): Buffer;
export namespace constants {
// Allowed flush values.
......@@ -1759,6 +1774,7 @@ declare module "https" {
export class Agent extends http.Agent {
constructor(options?: AgentOptions);
options: AgentOptions;
}
export class Server extends tls.Server {
......@@ -1952,6 +1968,9 @@ declare module "readline" {
completer?: Completer | AsyncCompleter;
terminal?: boolean;
historySize?: number;
prompt?: string;
crlfDelay?: number;
removeHistoryDuplicates?: boolean;
}
export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): ReadLine;
......@@ -1990,10 +2009,10 @@ declare module "vm" {
}
export function createContext(sandbox?: Context): Context;
export function isContext(sandbox: Context): boolean;
export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any;
export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions | string): any;
export function runInDebugContext(code: string): any;
export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any;
export function runInThisContext(code: string, options?: RunningScriptOptions): any;
export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions | string): any;
export function runInThisContext(code: string, options?: RunningScriptOptions | string): any;
}
declare module "child_process" {
......@@ -2082,9 +2101,10 @@ declare module "child_process" {
gid?: number;
shell?: boolean | string;
windowsVerbatimArguments?: boolean;
windowsHide?: boolean;
}
export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
export function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions): ChildProcess;
export interface ExecOptions {
cwd?: string;
......@@ -2095,6 +2115,7 @@ declare module "child_process" {
killSignal?: string;
uid?: number;
gid?: number;
windowsHide?: boolean;
}
export interface ExecOptionsWithStringEncoding extends ExecOptions {
......@@ -2141,6 +2162,7 @@ declare module "child_process" {
killSignal?: string;
uid?: number;
gid?: number;
windowsHide?: boolean;
windowsVerbatimArguments?: boolean;
}
export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
......@@ -2224,6 +2246,7 @@ declare module "child_process" {
maxBuffer?: number;
encoding?: string;
shell?: boolean | string;
windowsHide?: boolean;
windowsVerbatimArguments?: boolean;
}
export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
......@@ -2261,6 +2284,7 @@ declare module "child_process" {
killSignal?: string;
maxBuffer?: number;
encoding?: string;
windowsHide?: boolean;
}
export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
encoding: BufferEncoding;
......@@ -2284,6 +2308,7 @@ declare module "child_process" {
killSignal?: string;
maxBuffer?: number;
encoding?: string;
windowsHide?: boolean;
}
export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
encoding: BufferEncoding;
......@@ -2345,6 +2370,9 @@ declare module "url" {
export function format(urlObject: UrlObject | string): string;
export function resolve(from: string, to: string): string;
export function domainToASCII(domain: string): string;
export function domainToUnicode(domain: string): string;
export interface URLFormatOptions {
auth?: boolean;
fragment?: boolean;
......@@ -2425,6 +2453,12 @@ declare module "dns" {
export function __promisify__(hostname: string, options?: LookupOptions | number): Promise<{ address: string | LookupAddress[], family?: number }>;
}
export function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException, hostname: string, service: string) => void): void;
export namespace lookupService {
export function __promisify__(address: string, port: number): Promise<{ hostname: string, service: string }>;
}
export interface ResolveOptions {
ttl: boolean;
}
......@@ -2835,8 +2869,8 @@ declare module "dgram" {
export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
export class Socket extends events.EventEmitter {
send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error | null, bytes: number) => void): void;
send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error | null, bytes: number) => void): void;
send(msg: Buffer | string | Uint8Array | any[], port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
send(msg: Buffer | string | Uint8Array, offset: number, length: number, port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
bind(port?: number, address?: string, callback?: () => void): void;
bind(port?: number, callback?: () => void): void;
bind(callback?: () => void): void;
......@@ -3352,7 +3386,7 @@ declare module "fs" {
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function symlink(target: PathLike, path: PathLike, type: string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
/**
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
......@@ -3371,6 +3405,8 @@ declare module "fs" {
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
export type Type = "dir" | "file" | "junction";
}
/**
......@@ -3380,7 +3416,7 @@ declare module "fs" {
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function symlinkSync(target: PathLike, path: PathLike, type?: string | null): void;
export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
/**
* Asynchronous readlink(2) - read value of a symbolic link.
......@@ -4653,11 +4689,11 @@ declare module "path" {
/**
* The platform-specific file separator. '\\' or '/'.
*/
export var sep: string;
export var sep: '\\' | '/';
/**
* The platform-specific file delimiter. ';' or ':'.
*/
export var delimiter: string;
export var delimiter: ';' | ':';
/**
* Returns an object from a path string - the opposite of format().
*
......@@ -4875,6 +4911,14 @@ declare module "tls" {
getPeerCertificate(detailed: true): DetailedPeerCertificate;
getPeerCertificate(detailed?: false): PeerCertificate;
getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate;
/**
* Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
* The value `'unknown'` will be returned for connected sockets that have not completed the handshaking process.
* The value `null` will be returned for server sockets or disconnected client sockets.
* See https://www.openssl.org/docs/man1.0.2/ssl/SSL_get_version.html for more information.
* @returns negotiated SSL/TLS protocol version of the current connection
*/
getProtocol(): string | null;
/**
* Could be used to speed up handshake establishment when reconnecting to the server.
* @returns ASN.1 encoded TLS session or undefined if none was negotiated.
......@@ -5139,9 +5183,9 @@ declare module "crypto" {
update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string;
final(): Buffer;
final(output_encoding: string): string;
setAutoPadding(auto_padding?: boolean): void;
setAutoPadding(auto_padding?: boolean): this;
getAuthTag(): Buffer;
setAAD(buffer: Buffer): void;
setAAD(buffer: Buffer): this;
}
export function createDecipher(algorithm: string, password: any): Decipher;
export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher;
......@@ -5152,9 +5196,9 @@ declare module "crypto" {
update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string;
final(): Buffer;
final(output_encoding: string): string;
setAutoPadding(auto_padding?: boolean): void;
setAuthTag(tag: Buffer): void;
setAAD(buffer: Buffer): void;
setAutoPadding(auto_padding?: boolean): this;
setAuthTag(tag: Buffer): this;
setAAD(buffer: Buffer): this;
}
export function createSign(algorithm: string): Signer;
export interface Signer extends NodeJS.WritableStream {
......@@ -5267,6 +5311,7 @@ declare module "stream" {
export class Readable extends Stream implements NodeJS.ReadableStream {
readable: boolean;
readonly readableHighWaterMark: number;
constructor(opts?: ReadableOptions);
_read(size: number): void;
read(size?: number): any;
......@@ -5344,14 +5389,15 @@ declare module "stream" {
highWaterMark?: number;
decodeStrings?: boolean;
objectMode?: boolean;
write?: (chunk: string | Buffer, encoding: string, callback: Function) => any;
writev?: (chunks: Array<{ chunk: string | Buffer, encoding: string }>, callback: Function) => any;
write?: (chunk: any, encoding: string, callback: Function) => any;
writev?: (chunks: Array<{ chunk: any, encoding: string }>, callback: Function) => any;
destroy?: (error?: Error) => any;
final?: (callback: (error?: Error) => void) => void;
}
export class Writable extends Stream implements NodeJS.WritableStream {
writable: boolean;
readonly writableHighWaterMark: number;
constructor(opts?: WritableOptions);
_write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (err?: Error) => void): void;
......@@ -5443,6 +5489,7 @@ declare module "stream" {
// Note: Duplex extends both Readable and Writable.
export class Duplex extends Readable implements Writable {
writable: boolean;
readonly writableHighWaterMark: number;
constructor(opts?: DuplexOptions);
_write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
_writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (err?: Error) => void): void;
......@@ -5534,22 +5581,54 @@ declare module "util" {
export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
export function promisify<TResult>(fn: (callback: (err: Error, result: TResult) => void) => void): () => Promise<TResult>;
export function promisify(fn: (callback: (err: Error) => void) => void): () => Promise<void>;
export function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: Error, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
export function promisify<T1>(fn: (arg1: T1, callback: (err: Error) => void) => void): (arg1: T1) => Promise<void>;
export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
export function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
export function promisify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
export function promisify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
export function promisify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
export function promisify<TResult>(fn: (callback: (err: Error | null, result: TResult) => void) => void): () => Promise<TResult>;
export function promisify(fn: (callback: (err: Error | null) => void) => void): () => Promise<void>;
export function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
export function promisify<T1>(fn: (arg1: T1, callback: (err: Error | null) => void) => void): (arg1: T1) => Promise<void>;
export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
export function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
export function promisify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
export function promisify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
export function promisify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
export function promisify(fn: Function): Function;
export namespace promisify {
const custom: symbol;
}
export class TextDecoder {
readonly encoding: string;
readonly fatal: boolean;
readonly ignoreBOM: boolean;
constructor(
encoding?: string,
options?: { fatal?: boolean; ignoreBOM?: boolean }
);
decode(
input?:
Int8Array
| Int16Array
| Int32Array
| Uint8Array
| Uint16Array
| Uint32Array
| Uint8ClampedArray
| Float32Array
| Float64Array
| DataView
| ArrayBuffer
| null,
options?: { stream?: boolean }
): string;
}
export class TextEncoder {
readonly encoding: string;
constructor();
encode(input?: string): Uint8Array;
}
}
declare module "assert" {
......@@ -5569,8 +5648,8 @@ declare module "assert" {
});
}
export function fail(message: string): void;
export function fail(actual: any, expected: any, message?: string, operator?: string): void;
export function fail(message: string): never;
export function fail(actual: any, expected: any, message?: string, operator?: string): never;
export function ok(value: any, message?: string): void;
export function equal(actual: any, expected: any, message?: string): void;
export function notEqual(actual: any, expected: any, message?: string): void;
......@@ -6041,6 +6120,23 @@ declare module "async_hooks" {
*/
export function createHook(options: HookCallbacks): AsyncHook;
export interface AsyncResourceOptions {
/**
* The ID of the execution context that created this async event.
* Default: `executionAsyncId()`
*/
triggerAsyncId?: number;
/**
* Disables automatic `emitDestroy` when the object is garbage collected.
* This usually does not need to be set (even if `emitDestroy` is called
* manually), unless the resource's `asyncId` is retrieved and the
* sensitive API's `emitDestroy` is called with it.
* Default: `false`
*/
requireManualDestroy?: boolean;
}
/**
* The class AsyncResource was designed to be extended by the embedder's async resources.
* Using this users can easily trigger the lifetime events of their own resources.
......@@ -6050,10 +6146,12 @@ declare module "async_hooks" {
* AsyncResource() is meant to be extended. Instantiating a
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
* async_hook.executionAsyncId() is used.
* @param type the name of this async resource type
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
* @param type The type of async event.
* @param triggerAsyncId The ID of the execution context that created
* this async event (default: `executionAsyncId()`), or an
* AsyncResourceOptions object (since 8.10)
*/
constructor(type: string, triggerAsyncId?: number)
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
/**
* Call AsyncHooks before callbacks.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册