UNPKG

bot18

Version:

A high-frequency cryptocurrency trading bot by Zenbot creator @carlos8f

1,242 lines (1,140 loc) 365 kB
// Type definitions for Node.js 9.6.x // Project: http://nodejs.org/ // Definitions by: Microsoft TypeScript <http://typescriptlang.org> // DefinitelyTyped <https://github.com/DefinitelyTyped/DefinitelyTyped> // Parambir Singh <https://github.com/parambirs> // Christian Vaagland Tellnes <https://github.com/tellnes> // Wilco Bakker <https://github.com/WilcoBakker> // Nicolas Voigt <https://github.com/octo-sniffle> // Chigozirim C. <https://github.com/smac89> // Flarna <https://github.com/Flarna> // Mariusz Wiktorczyk <https://github.com/mwiktorczyk> // wwwy3y3 <https://github.com/wwwy3y3> // 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> // Klaus Meinhardt <https://github.com/ajafff> // Huw <https://github.com/hoo29> // Nicolas Even <https://github.com/n-e> // Bruno Scheufler <https://github.com/brunoscheufler> // Mohsen Azimi <https://github.com/mohsen1> // Hoàng Văn Khải <https://github.com/KSXGitHub> // Alexander T. <https://github.com/a-tarasyuk> // Lishude <https://github.com/islishude> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** inspector module types */ /// <reference path="./inspector.d.ts" /> // This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build interface Console { Console: NodeJS.ConsoleConstructor; /** * A simple assertion test that verifies whether `value` is truthy. * If it is not, an `AssertionError` is thrown. * If provided, the error `message` is formatted using `util.format()` and used as the error message. */ assert(value: any, message?: string, ...optionalParams: any[]): void; /** * When `stdout` is a TTY, calling `console.clear()` will attempt to clear the TTY. * When `stdout` is not a TTY, this method does nothing. */ clear(): void; /** * Maintains an internal counter specific to `label` and outputs to `stdout` the number of times `console.count()` has been called with the given `label`. */ count(label?: string): void; /** * Resets the internal counter specific to `label`. */ countReset(label?: string): void; /** * The `console.debug()` function is an alias for {@link console.log()}. */ debug(message?: any, ...optionalParams: any[]): void; /** * Uses {@link util.inspect()} on `obj` and prints the resulting string to `stdout`. * This function bypasses any custom `inspect()` function defined on `obj`. */ dir(obj: any, options?: NodeJS.InspectOptions): void; /** * This method calls {@link console.log()} passing it the arguments received. Please note that this method does not produce any XML formatting */ dirxml(...data: any[]): void; /** * Prints to `stderr` with newline. */ error(message?: any, ...optionalParams: any[]): void; /** * Increases indentation of subsequent lines by two spaces. * If one or more `label`s are provided, those are printed first without the additional indentation. */ group(...label: any[]): void; /** * The `console.groupCollapsed()` function is an alias for {@link console.group()}. */ groupCollapsed(): void; /** * Decreases indentation of subsequent lines by two spaces. */ groupEnd(): void; /** * The {@link console.info()} function is an alias for {@link console.log()}. */ info(message?: any, ...optionalParams: any[]): void; /** * Prints to `stdout` with newline. */ log(message?: any, ...optionalParams: any[]): void; /** * Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique `label`. */ time(label?: string): void; /** * Stops a timer that was previously started by calling {@link console.time()} and prints the result to `stdout`. */ timeEnd(label?: string): void; /** * Prints to `stderr` the string 'Trace :', followed by the {@link util.format()} formatted message and stack trace to the current position in the code. */ trace(message?: any, ...optionalParams: any[]): void; /** * The {@link console.warn()} function is an alias for {@link console.error()}. */ warn(message?: any, ...optionalParams: any[]): void; // --- Inspector mode only --- /** * This method does not display anything unless used in the inspector. * Starts a JavaScript CPU profile with an optional label. */ profile(label?: string): void; /** * This method does not display anything unless used in the inspector. * Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector. */ profileEnd(): void; /** * This method does not display anything unless used in the inspector. * Prints to `stdout` the array `array` formatted as a table. */ table(tabularData: any, properties?: string[]): void; /** * This method does not display anything unless used in the inspector. * Adds an event with the label `label` to the Timeline panel of the inspector. */ timeStamp(label?: string): void; } interface Error { stack?: string; } // Declare "static" methods in Error interface ErrorConstructor { /** Create .stack property on a target object */ captureStackTrace(targetObject: Object, constructorOpt?: Function): void; /** * Optional override for formatting stack traces * * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces */ prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any; stackTraceLimit: number; } // compat for TypeScript 1.8 // if you use with --target es3 or --target es5 and use below definitions, // use the lib.es6.d.ts that is bundled with TypeScript 1.8. interface MapConstructor { } interface WeakMapConstructor { } interface SetConstructor { } interface WeakSetConstructor { } // Forward-declare needed types from lib.es2015.d.ts (in case users are using `--lib es5`) interface Iterable<T> { } interface Iterator<T> { next(value?: any): IteratorResult<T>; } interface IteratorResult<T> { } interface SymbolConstructor { readonly iterator: symbol; } declare var Symbol: SymbolConstructor; // Node.js ESNEXT support interface String { /** Removes whitespace from the left end of a string. */ trimLeft(): string; /** Removes whitespace from the right end of a string. */ trimRight(): string; } /************************************************ * * * GLOBAL * * * ************************************************/ declare var process: NodeJS.Process; declare var global: NodeJS.Global; declare var console: Console; declare var __filename: string; declare var __dirname: string; declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; declare namespace setTimeout { export function __promisify__(ms: number): Promise<void>; export function __promisify__<T>(ms: number, value: T): Promise<T>; } declare function clearTimeout(timeoutId: NodeJS.Timer): void; declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; declare function clearInterval(intervalId: NodeJS.Timer): void; declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; declare namespace setImmediate { export function __promisify__(): Promise<void>; export function __promisify__<T>(value: T): Promise<T>; } declare function clearImmediate(immediateId: any): void; // TODO: change to `type NodeRequireFunction = (id: string) => any;` in next mayor version. interface NodeRequireFunction { /* tslint:disable-next-line:callable-types */ (id: string): any; } interface NodeRequire extends NodeRequireFunction { 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; '.node': (m: NodeModule, filename: string) => any; [ext: string]: (m: NodeModule, filename: string) => any; } declare var require: NodeRequire; interface NodeModule { exports: any; require: NodeRequireFunction; id: string; filename: string; loaded: boolean; parent: NodeModule | null; children: NodeModule[]; paths: string[]; } declare var module: NodeModule; // Same as module.exports declare var exports: any; declare var SlowBuffer: { new(str: string, encoding?: string): Buffer; new(size: number): Buffer; new(size: Uint8Array): Buffer; new(array: any[]): Buffer; prototype: Buffer; isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; concat(list: Buffer[], totalLength?: number): Buffer; }; // Buffer class type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex"; interface Buffer extends Uint8Array { write(string: string, offset?: number, length?: number, encoding?: string): number; toString(encoding?: string, start?: number, end?: number): string; toJSON(): { type: 'Buffer', data: any[] }; equals(otherBuffer: Uint8Array): boolean; compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; slice(start?: number, end?: number): Buffer; writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; readUInt8(offset: number, noAssert?: boolean): number; readUInt16LE(offset: number, noAssert?: boolean): number; readUInt16BE(offset: number, noAssert?: boolean): number; readUInt32LE(offset: number, noAssert?: boolean): number; readUInt32BE(offset: number, noAssert?: boolean): number; readInt8(offset: number, noAssert?: boolean): number; readInt16LE(offset: number, noAssert?: boolean): number; readInt16BE(offset: number, noAssert?: boolean): number; readInt32LE(offset: number, noAssert?: boolean): number; readInt32BE(offset: number, noAssert?: boolean): number; readFloatLE(offset: number, noAssert?: boolean): number; readFloatBE(offset: number, noAssert?: boolean): number; readDoubleLE(offset: number, noAssert?: boolean): number; readDoubleBE(offset: number, noAssert?: boolean): number; swap16(): Buffer; swap32(): Buffer; swap64(): Buffer; writeUInt8(value: number, offset: number, noAssert?: boolean): number; writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; writeInt8(value: number, offset: number, noAssert?: boolean): number; writeInt16LE(value: number, offset: number, noAssert?: boolean): number; writeInt16BE(value: number, offset: number, noAssert?: boolean): number; writeInt32LE(value: number, offset: number, noAssert?: boolean): number; writeInt32BE(value: number, offset: number, noAssert?: boolean): number; writeFloatLE(value: number, offset: number, noAssert?: boolean): number; writeFloatBE(value: number, offset: number, noAssert?: boolean): number; writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; fill(value: any, offset?: number, end?: number): this; indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: string): number; lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: string): number; entries(): IterableIterator<[number, number]>; includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; keys(): IterableIterator<number>; values(): IterableIterator<number>; } /** * Raw data is stored in instances of the Buffer class. * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' */ declare var Buffer: { /** * Allocates a new buffer containing the given {str}. * * @param str String to store in buffer. * @param encoding encoding to use, optional. Default is 'utf8' */ new(str: string, encoding?: string): Buffer; /** * Allocates a new buffer of {size} octets. * * @param size count of octets to allocate. */ new(size: number): Buffer; /** * Allocates a new buffer containing the given {array} of octets. * * @param array The octets to store. */ new(array: Uint8Array): Buffer; /** * Produces a Buffer backed by the same allocated memory as * the given {ArrayBuffer}. * * * @param arrayBuffer The ArrayBuffer with which to share memory. */ new(arrayBuffer: ArrayBuffer): Buffer; /** * Allocates a new buffer containing the given {array} of octets. * * @param array The octets to store. */ new(array: any[]): Buffer; /** * Copies the passed {buffer} data onto a new {Buffer} instance. * * @param buffer The buffer to copy. */ new(buffer: Buffer): Buffer; prototype: 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. * The optional {byteOffset} and {length} arguments specify a memory range * within the {arrayBuffer} that will be shared by the Buffer. * * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() */ from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; /** * Creates a new Buffer using the passed {data} * @param data data to create a new 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. * If not provided, {encoding} defaults to 'utf8'. */ from(str: string, encoding?: string): Buffer; /** * Returns true if {obj} is a Buffer * * @param obj object to test. */ isBuffer(obj: any): obj is Buffer; /** * Returns true if {encoding} is a valid encoding argument. * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' * * @param encoding string to test. */ isEncoding(encoding: string): boolean; /** * Gives the actual byte length of a string. encoding defaults to 'utf8'. * This is not the same as String.prototype.length since that returns the number of characters in a string. * * @param string string to test. (TypedArray is also allowed, but it is only available starting ES2017) * @param encoding encoding used to evaluate (defaults to 'utf8') */ byteLength(string: string | Buffer | DataView | ArrayBuffer, encoding?: string): number; /** * Returns a buffer which is the result of concatenating all the buffers in the list together. * * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. * If the list has exactly one item, then the first item of the list is returned. * If the list has more than one item, then a new Buffer is created. * * @param list An array of Buffer objects to concatenate * @param totalLength Total length of the buffers when concatenated. * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. */ concat(list: Uint8Array[], totalLength?: number): Buffer; /** * The same as buf1.compare(buf2). */ compare(buf1: Uint8Array, buf2: Uint8Array): number; /** * Allocates a new buffer of {size} octets. * * @param size count of octets to allocate. * @param fill if specified, buffer will be initialized by calling buf.fill(fill). * If parameter is omitted, buffer will be filled with zeros. * @param encoding encoding used for call to buf.fill while initalizing */ alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; /** * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents * of the newly created Buffer are unknown and may contain sensitive data. * * @param size count of octets to allocate */ allocUnsafe(size: number): Buffer; /** * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents * of the newly created Buffer are unknown and may contain sensitive data. * * @param size count of octets to allocate */ allocUnsafeSlow(size: number): Buffer; /** * This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified. */ poolSize: number; }; /************************************************ * * * GLOBAL INTERFACES * * * ************************************************/ declare namespace NodeJS { export interface InspectOptions { showHidden?: boolean; depth?: number | null; colors?: boolean; customInspect?: boolean; showProxy?: boolean; maxArrayLength?: number | null; breakLength?: number; } export interface ConsoleConstructor { prototype: Console; new(stdout: WritableStream, stderr?: WritableStream): Console; } export interface CallSite { /** * Value of "this" */ getThis(): any; /** * Type of "this" as a string. * This is the name of the function stored in the constructor field of * "this", if available. Otherwise the object's [[Class]] internal * property. */ getTypeName(): string | null; /** * Current function */ getFunction(): Function | undefined; /** * Name of the current function, typically its name property. * If a name property is not available an attempt will be made to try * to infer a name from the function's context. */ getFunctionName(): string | null; /** * Name of the property [of "this" or one of its prototypes] that holds * the current function */ getMethodName(): string | null; /** * Name of the script [if this function was defined in a script] */ getFileName(): string | null; /** * Current line number [if this function was defined in a script] */ getLineNumber(): number | null; /** * Current column number [if this function was defined in a script] */ getColumnNumber(): number | null; /** * A call site object representing the location where eval was called * [if this function was created using a call to eval] */ getEvalOrigin(): string | undefined; /** * Is this a toplevel invocation, that is, is "this" the global object? */ isToplevel(): boolean; /** * Does this call take place in code defined by a call to eval? */ isEval(): boolean; /** * Is this call in native V8 code? */ isNative(): boolean; /** * Is this a constructor call? */ isConstructor(): boolean; } export interface ErrnoException extends Error { errno?: number; code?: string; path?: string; syscall?: string; stack?: string; } export class EventEmitter { addListener(event: string | symbol, listener: (...args: any[]) => void): this; on(event: string | symbol, listener: (...args: any[]) => void): this; once(event: string | symbol, listener: (...args: any[]) => void): this; removeListener(event: string | symbol, listener: (...args: any[]) => void): this; removeAllListeners(event?: string | symbol): this; setMaxListeners(n: number): this; getMaxListeners(): number; listeners(event: string | symbol): Function[]; rawListeners(event: string | symbol): Function[]; emit(event: string | symbol, ...args: any[]): boolean; listenerCount(type: string | symbol): number; // Added in Node 6... prependListener(event: string | symbol, listener: (...args: any[]) => void): this; prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; eventNames(): Array<string | symbol>; } export interface ReadableStream extends EventEmitter { readable: boolean; read(size?: number): string | Buffer; setEncoding(encoding: string): this; pause(): this; resume(): this; isPaused(): boolean; pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T; unpipe<T extends WritableStream>(destination?: T): this; unshift(chunk: string): void; unshift(chunk: Buffer): void; wrap(oldStream: ReadableStream): this; } export interface WritableStream extends EventEmitter { writable: boolean; write(buffer: Buffer | string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(cb?: Function): void; end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } export interface ReadWriteStream extends ReadableStream, WritableStream { } export interface Events extends EventEmitter { } export interface Domain extends Events { run(fn: Function): void; add(emitter: Events): void; remove(emitter: Events): void; bind(cb: (err: Error, data: any) => any): any; intercept(cb: (data: any) => any): any; addListener(event: string, listener: (...args: any[]) => void): this; on(event: string, listener: (...args: any[]) => void): this; once(event: string, listener: (...args: any[]) => void): this; removeListener(event: string, listener: (...args: any[]) => void): this; removeAllListeners(event?: string): this; } export interface MemoryUsage { rss: number; heapTotal: number; heapUsed: number; external: number; } export interface CpuUsage { user: number; system: number; } export interface ProcessVersions { http_parser: string; node: string; v8: string; ares: string; uv: string; zlib: string; modules: string; openssl: string; } type Platform = 'aix' | 'android' | 'darwin' | 'freebsd' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin'; type Signals = "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" | "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" | "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" | "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO"; type BeforeExitListener = (code: number) => void; type DisconnectListener = () => void; type ExitListener = (code: number) => void; type RejectionHandledListener = (promise: Promise<any>) => void; type UncaughtExceptionListener = (error: Error) => void; type UnhandledRejectionListener = (reason: any, promise: Promise<any>) => void; type WarningListener = (warning: Error) => void; type MessageListener = (message: any, sendHandle: any) => void; type SignalsListener = (signal: Signals) => void; type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void; type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void; export interface Socket extends ReadWriteStream { isTTY?: true; } export interface ProcessEnv { [key: string]: string | undefined; } export interface WriteStream extends Socket { readonly writableHighWaterMark: number; readonly writableLength: number; columns?: number; rows?: number; _write(chunk: any, encoding: string, callback: Function): void; _destroy(err: Error, callback: Function): void; _final(callback: Function): void; setDefaultEncoding(encoding: string): this; cork(): void; uncork(): void; destroy(error?: Error): void; } export interface ReadStream extends Socket { readonly readableHighWaterMark: number; readonly readableLength: number; isRaw?: boolean; setRawMode?(mode: boolean): void; _read(size: number): void; _destroy(err: Error, callback: Function): void; push(chunk: any, encoding?: string): boolean; destroy(error?: Error): void; } export interface Process extends EventEmitter { stdout: WriteStream; stderr: WriteStream; stdin: ReadStream; openStdin(): Socket; argv: string[]; argv0: string; execArgv: string[]; execPath: string; 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; exitCode: number; getgid(): number; setgid(id: number | string): void; getuid(): number; setuid(id: number | string): void; geteuid(): number; seteuid(id: number | string): void; getegid(): number; setegid(id: number | string): void; getgroups(): number[]; setgroups(groups: Array<string | number>): void; setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void; hasUncaughtExceptionCaptureCallback(): boolean; version: string; versions: ProcessVersions; config: { target_defaults: { cflags: any[]; default_configuration: string; defines: string[]; include_dirs: string[]; libraries: string[]; }; variables: { clang: number; host_arch: string; node_install_npm: boolean; node_install_waf: boolean; node_prefix: string; node_shared_openssl: boolean; node_shared_v8: boolean; node_shared_zlib: boolean; node_use_dtrace: boolean; node_use_etw: boolean; node_use_openssl: boolean; target_arch: string; v8_no_strict_aliasing: number; v8_use_snapshot: boolean; visibility: string; }; }; kill(pid: number, signal?: string | number): void; pid: number; ppid: number; title: string; arch: string; platform: Platform; mainModule?: NodeModule; memoryUsage(): MemoryUsage; cpuUsage(previousValue?: CpuUsage): CpuUsage; nextTick(callback: Function, ...args: any[]): void; umask(mask?: number): number; uptime(): number; hrtime(time?: [number, number]): [number, number]; domain: Domain; // Worker send?(message: any, sendHandle?: any): void; disconnect(): void; connected: boolean; /** * EventEmitter * 1. beforeExit * 2. disconnect * 3. exit * 4. message * 5. rejectionHandled * 6. uncaughtException * 7. unhandledRejection * 8. warning * 9. message * 10. <All OS Signals> * 11. newListener/removeListener inherited from EventEmitter */ addListener(event: "beforeExit", listener: BeforeExitListener): this; addListener(event: "disconnect", listener: DisconnectListener): this; addListener(event: "exit", listener: ExitListener): this; addListener(event: "rejectionHandled", listener: RejectionHandledListener): this; addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; addListener(event: "warning", listener: WarningListener): this; addListener(event: "message", listener: MessageListener): this; addListener(event: Signals, listener: SignalsListener): this; addListener(event: "newListener", listener: NewListenerListener): this; addListener(event: "removeListener", listener: RemoveListenerListener): this; emit(event: "beforeExit", code: number): boolean; emit(event: "disconnect"): boolean; emit(event: "exit", code: number): boolean; emit(event: "rejectionHandled", promise: Promise<any>): boolean; emit(event: "uncaughtException", error: Error): boolean; emit(event: "unhandledRejection", reason: any, promise: Promise<any>): boolean; emit(event: "warning", warning: Error): boolean; emit(event: "message", message: any, sendHandle: any): this; emit(event: Signals): boolean; emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this; emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this; on(event: "beforeExit", listener: BeforeExitListener): this; on(event: "disconnect", listener: DisconnectListener): this; on(event: "exit", listener: ExitListener): this; on(event: "rejectionHandled", listener: RejectionHandledListener): this; on(event: "uncaughtException", listener: UncaughtExceptionListener): this; on(event: "unhandledRejection", listener: UnhandledRejectionListener): this; on(event: "warning", listener: WarningListener): this; on(event: "message", listener: MessageListener): this; on(event: Signals, listener: SignalsListener): this; on(event: "newListener", listener: NewListenerListener): this; on(event: "removeListener", listener: RemoveListenerListener): this; once(event: "beforeExit", listener: BeforeExitListener): this; once(event: "disconnect", listener: DisconnectListener): this; once(event: "exit", listener: ExitListener): this; once(event: "rejectionHandled", listener: RejectionHandledListener): this; once(event: "uncaughtException", listener: UncaughtExceptionListener): this; once(event: "unhandledRejection", listener: UnhandledRejectionListener): this; once(event: "warning", listener: WarningListener): this; once(event: "message", listener: MessageListener): this; once(event: Signals, listener: SignalsListener): this; once(event: "newListener", listener: NewListenerListener): this; once(event: "removeListener", listener: RemoveListenerListener): this; prependListener(event: "beforeExit", listener: BeforeExitListener): this; prependListener(event: "disconnect", listener: DisconnectListener): this; prependListener(event: "exit", listener: ExitListener): this; prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this; prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; prependListener(event: "warning", listener: WarningListener): this; prependListener(event: "message", listener: MessageListener): this; prependListener(event: Signals, listener: SignalsListener): this; prependListener(event: "newListener", listener: NewListenerListener): this; prependListener(event: "removeListener", listener: RemoveListenerListener): this; prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this; prependOnceListener(event: "disconnect", listener: DisconnectListener): this; prependOnceListener(event: "exit", listener: ExitListener): this; prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this; prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this; prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this; prependOnceListener(event: "warning", listener: WarningListener): this; prependOnceListener(event: "message", listener: MessageListener): this; prependOnceListener(event: Signals, listener: SignalsListener): this; prependOnceListener(event: "newListener", listener: NewListenerListener): this; prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this; listeners(event: "beforeExit"): BeforeExitListener[]; listeners(event: "disconnect"): DisconnectListener[]; listeners(event: "exit"): ExitListener[]; listeners(event: "rejectionHandled"): RejectionHandledListener[]; listeners(event: "uncaughtException"): UncaughtExceptionListener[]; listeners(event: "unhandledRejection"): UnhandledRejectionListener[]; listeners(event: "warning"): WarningListener[]; listeners(event: "message"): MessageListener[]; listeners(event: Signals): SignalsListener[]; listeners(event: "newListener"): NewListenerListener[]; listeners(event: "removeListener"): RemoveListenerListener[]; } export interface Global { Array: typeof Array; ArrayBuffer: typeof ArrayBuffer; Boolean: typeof Boolean; Buffer: typeof Buffer; DataView: typeof DataView; Date: typeof Date; Error: typeof Error; EvalError: typeof EvalError; Float32Array: typeof Float32Array; Float64Array: typeof Float64Array; Function: typeof Function; GLOBAL: Global; Infinity: typeof Infinity; Int16Array: typeof Int16Array; Int32Array: typeof Int32Array; Int8Array: typeof Int8Array; Intl: typeof Intl; JSON: typeof JSON; Map: MapConstructor; Math: typeof Math; NaN: typeof NaN; Number: typeof Number; Object: typeof Object; Promise: Function; RangeError: typeof RangeError; ReferenceError: typeof ReferenceError; RegExp: typeof RegExp; Set: SetConstructor; String: typeof String; Symbol: Function; SyntaxError: typeof SyntaxError; TypeError: typeof TypeError; URIError: typeof URIError; Uint16Array: typeof Uint16Array; Uint32Array: typeof Uint32Array; Uint8Array: typeof Uint8Array; Uint8ClampedArray: Function; WeakMap: WeakMapConstructor; WeakSet: WeakSetConstructor; clearImmediate: (immediateId: any) => void; clearInterval: (intervalId: NodeJS.Timer) => void; clearTimeout: (timeoutId: NodeJS.Timer) => void; console: typeof console; decodeURI: typeof decodeURI; decodeURIComponent: typeof decodeURIComponent; encodeURI: typeof encodeURI; encodeURIComponent: typeof encodeURIComponent; escape: (str: string) => string; eval: typeof eval; global: Global; isFinite: typeof isFinite; isNaN: typeof isNaN; parseFloat: typeof parseFloat; parseInt: typeof parseInt; process: Process; root: Global; setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; undefined: typeof undefined; unescape: (str: string) => string; gc: () => void; v8debug?: any; } export interface Timer { ref(): void; unref(): void; } class Module { static runMain(): void; static wrap(code: string): string; static builtinModules: string[]; static Module: typeof Module; exports: any; require: NodeRequireFunction; id: string; filename: string; loaded: boolean; parent: Module | null; children: Module[]; paths: string[]; constructor(id: string, parent?: Module); } } interface IterableIterator<T> { } /************************************************ * * * MODULES * * * ************************************************/ declare module "buffer" { export var INSPECT_MAX_BYTES: number; var BuffType: typeof Buffer; var SlowBuffType: typeof SlowBuffer; export { BuffType as Buffer, SlowBuffType as SlowBuffer }; } declare module "querystring" { export interface StringifyOptions { encodeURIComponent?: Function; } export interface ParseOptions { maxKeys?: number; decodeURIComponent?: Function; } 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; export function parse<T extends {}>(str: string, sep?: string, eq?: string, options?: ParseOptions): T; export function escape(str: string): string; export function unescape(str: string): string; } declare module "events" { class internal extends NodeJS.EventEmitter { } namespace internal { export class EventEmitter extends internal { static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated static defaultMaxListeners: number; addListener(event: string | symbol, listener: (...args: any[]) => void): this; on(event: string | symbol, listener: (...args: any[]) => void): this; once(event: string | symbol, listener: (...args: any[]) => void): this; prependListener(event: string | symbol, listener: (...args: any[]) => void): this; prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; removeListener(event: string | symbol, listener: (...args: any[]) => void): this; removeAllListeners(event?: string | symbol): this; setMaxListeners(n: number): this; getMaxListeners(): number; listeners(event: string | symbol): Function[]; rawListeners(event: string | symbol): Function[]; emit(event: string | symbol, ...args: any[]): boolean; eventNames(): Array<string | symbol>; listenerCount(type: string | symbol): number; } } export = internal; } declare module "http" { import * as events from "events"; import * as net from "net"; import * as stream from "stream"; import { URL } from "url"; // incoming headers will never contain number export interface IncomingHttpHeaders { 'accept'?: string; 'access-control-allow-origin'?: string; 'access-control-allow-credentials'?: string; 'access-control-expose-headers'?: string; 'access-control-max-age'?: string; 'access-control-allow-methods'?: string; 'access-control-allow-headers'?: string; 'accept-patch'?: string; 'accept-ranges'?: string; 'authorization'?: string; 'age'?: string; 'allow'?: string; 'alt-svc'?: string; 'cache-control'?: string; 'connection'?: string; 'content-disposition'?: string; 'content-encoding'?: string; 'content-language'?: string; 'content-length'?: string; 'content-location'?: string; 'content-range'?: string; 'content-type'?: string; 'date'?: string; 'expires'?: string; 'host'?: string; 'last-modified'?: string; 'location'?: string; 'pragma'?: string; 'proxy-authenticate'?: string; 'public-key-pins'?: string; 'retry-after'?: string; 'set-cookie'?: string[]; 'strict-transport-security'?: string; 'trailer'?: string; 'transfer-encoding'?: string; 'tk'?: string; 'upgrade'?: string; 'vary'?: string; 'via'?: string; 'warning'?: string; 'www-authenticate'?: string; [header: string]: string | string[] | undefined; } // outgoing headers allows numbers (as they are converted internally to strings) export interface OutgoingHttpHeaders { [header: string]: number | string | string[] | undefined; } export interface ClientRequestArgs { protocol?: string; host?: string; hostname?: string; family?: number; port?: number | string; defaultPort?: number | string; localAddress?: string; socketPath?: string; method?: string; path?: string; headers?: OutgoingHttpHeaders; auth?: string; agent?: Agent | boolean; _defaultAgent?: Agent; timeout?: number; // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278 createConnection?: (options: ClientRequestArgs, oncreate: (err: Error, socket: net.Socket) => void) => net.Socket; } export class Server extends net.Server { constructor(requestListener?: (req: IncomingMessage, res: ServerResponse) => void); setTimeout(msecs?: number, callback?: () => void): this; setTimeout(callback: () => void): this; maxHeadersCount: number; timeout: number; keepAliveTimeout: number; } /** * @deprecated Use IncomingMessage */ export class ServerRequest extends IncomingMessage { connection: net.Socket; } // https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js export class OutgoingMessage extends stream.Writable { upgrading: boolean; chunkedEncoding: boolean; shouldKeepAlive: boolean; useChunkedEncodingByDefault: boolean; sendDate: boolean; finished: boolean; headersSent: boolean; connection: net.Socket; constructor(); setTimeout(msecs: number, callback?: () => void): this; destroy(error: Error): void; setHeader(name: string, value: number | string | string[]): void; getHeader(name: string): number | string | string[] | undefined; getHeaders(): OutgoingHttpHeaders; getHeaderNames(): string[]; hasHeader(name: string): boolean; removeHeader(name: string): void; addTrailers(headers: OutgoingHttpHeaders | Array<[string, string]>): void; flushHeaders(): void; } // https://github.com/nodejs/node/blob/master/lib/_http_server.js#L108-L256 export class ServerResponse extends OutgoingMessage { statusCode: number; statusMessage: string; constructor(req: IncomingMessage); assignSocket(socket: net.Socket): void; detachSocket(socket: net.Socket): void; // https://github.com/nodejs/node/blob/master/test/parallel/test-http-write-callbacks.js#L53 // no args in writeContinue callback writeContinue(callback?: () => void): void; writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void; writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void; } // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L77 export class ClientRequest extends OutgoingMessage { connection: net.Socket; socket: net.Socket; aborted: number; constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void); abort(): void; onSocket(socket: net.Socket): void; setTimeout(timeout: number, callback?: () => void): this; setNoDelay(noDelay?: boolean): void; setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; } export class IncomingMessage extends stream.Readable { constructor(socket: net.Socket); httpVersion: string; httpVersionMajor: number; httpVersionMinor: number; connection: net.Socket; headers: IncomingHttpHeaders; rawHeaders: string[]; trailers: { [key: string]: string | undefined }; rawTrailers: string[]; setTimeout(msecs: number, callback: () => void): this; /** * Only valid for request obtained from http.Server. */ method?: string; /** * Only valid for request obtained from http.Server. */ url?: string; /** * Only valid for response obtained from http.ClientRequest. */ statusCode?: number; /** * Only valid for response obtained from http.ClientRequest. */ statusMessage?: string; socket: net.Socket; destroy(error?: Error): void; } /** * @deprecated Use IncomingMessage */ export class ClientResponse extends IncomingMessage { } export interface AgentOptions { /** * Keep sockets around in a pool to be used by other requests in the future. Default = false */ keepAlive?: boolean; /** * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. * Only relevant if keepAlive is set to true. */ keepAliveMsecs?: number; /** * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity */ maxSockets?: number; /** * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. */ maxFreeSockets?: number; } export class Agent { maxSockets: number; sockets: any; requests: any; constructor(opts?: AgentOptions); /** * Destroy any sockets that are currently in use by the agent. * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, * sockets may hang open for quite a long time before the server terminates them. */ des