Projekt

Obecné

Profil

Stáhnout (44.2 KB) Statistiky
| Větev: | Revize:
1
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
2
interface Console {
3
    Console: NodeJS.ConsoleConstructor;
4
    /**
5
     * A simple assertion test that verifies whether `value` is truthy.
6
     * If it is not, an `AssertionError` is thrown.
7
     * If provided, the error `message` is formatted using `util.format()` and used as the error message.
8
     */
9
    assert(value: any, message?: string, ...optionalParams: any[]): void;
10
    /**
11
     * When `stdout` is a TTY, calling `console.clear()` will attempt to clear the TTY.
12
     * When `stdout` is not a TTY, this method does nothing.
13
     */
14
    clear(): void;
15
    /**
16
     * Maintains an internal counter specific to `label` and outputs to `stdout` the number of times `console.count()` has been called with the given `label`.
17
     */
18
    count(label?: string): void;
19
    /**
20
     * Resets the internal counter specific to `label`.
21
     */
22
    countReset(label?: string): void;
23
    /**
24
     * The `console.debug()` function is an alias for {@link console.log()}.
25
     */
26
    debug(message?: any, ...optionalParams: any[]): void;
27
    /**
28
     * Uses {@link util.inspect()} on `obj` and prints the resulting string to `stdout`.
29
     * This function bypasses any custom `inspect()` function defined on `obj`.
30
     */
31
    dir(obj: any, options?: NodeJS.InspectOptions): void;
32
    /**
33
     * This method calls {@link console.log()} passing it the arguments received. Please note that this method does not produce any XML formatting
34
     */
35
    dirxml(...data: any[]): void;
36
    /**
37
     * Prints to `stderr` with newline.
38
     */
39
    error(message?: any, ...optionalParams: any[]): void;
40
    /**
41
     * Increases indentation of subsequent lines by two spaces.
42
     * If one or more `label`s are provided, those are printed first without the additional indentation.
43
     */
44
    group(...label: any[]): void;
45
    /**
46
     * The `console.groupCollapsed()` function is an alias for {@link console.group()}.
47
     */
48
    groupCollapsed(...label: any[]): void;
49
    /**
50
     * Decreases indentation of subsequent lines by two spaces.
51
     */
52
    groupEnd(): void;
53
    /**
54
     * The {@link console.info()} function is an alias for {@link console.log()}.
55
     */
56
    info(message?: any, ...optionalParams: any[]): void;
57
    /**
58
     * Prints to `stdout` with newline.
59
     */
60
    log(message?: any, ...optionalParams: any[]): void;
61
    /**
62
     * This method does not display anything unless used in the inspector.
63
     *  Prints to `stdout` the array `array` formatted as a table.
64
     */
65
    table(tabularData: any, properties?: string[]): void;
66
    /**
67
     * Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique `label`.
68
     */
69
    time(label?: string): void;
70
    /**
71
     * Stops a timer that was previously started by calling {@link console.time()} and prints the result to `stdout`.
72
     */
73
    timeEnd(label?: string): void;
74
    /**
75
     * For a timer that was previously started by calling {@link console.time()}, prints the elapsed time and other `data` arguments to `stdout`.
76
     */
77
    timeLog(label?: string, ...data: any[]): void;
78
    /**
79
     * Prints to `stderr` the string 'Trace :', followed by the {@link util.format()} formatted message and stack trace to the current position in the code.
80
     */
81
    trace(message?: any, ...optionalParams: any[]): void;
82
    /**
83
     * The {@link console.warn()} function is an alias for {@link console.error()}.
84
     */
85
    warn(message?: any, ...optionalParams: any[]): void;
86

    
87
    // --- Inspector mode only ---
88
    /**
89
     * This method does not display anything unless used in the inspector.
90
     *  Starts a JavaScript CPU profile with an optional label.
91
     */
92
    profile(label?: string): void;
93
    /**
94
     * This method does not display anything unless used in the inspector.
95
     *  Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
96
     */
97
    profileEnd(label?: string): void;
98
    /**
99
     * This method does not display anything unless used in the inspector.
100
     *  Adds an event with the label `label` to the Timeline panel of the inspector.
101
     */
102
    timeStamp(label?: string): void;
103
}
104

    
105
// Declare "static" methods in Error
106
interface ErrorConstructor {
107
    /** Create .stack property on a target object */
108
    captureStackTrace(targetObject: object, constructorOpt?: Function): void;
109

    
110
    /**
111
     * Optional override for formatting stack traces
112
     *
113
     * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces
114
     */
115
    prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any;
116

    
117
    stackTraceLimit: number;
118
}
119

    
120
// Node.js ESNEXT support
121
interface String {
122
    /** Removes whitespace from the left end of a string. */
123
    trimLeft(): string;
124
    /** Removes whitespace from the right end of a string. */
125
    trimRight(): string;
126
}
127

    
128
interface ImportMeta {
129
    url: string;
130
}
131

    
132
/*-----------------------------------------------*
133
 *                                               *
134
 *                   GLOBAL                      *
135
 *                                               *
136
 ------------------------------------------------*/
137

    
138
// For backwards compability
139
interface NodeRequire extends NodeJS.Require {}
140
interface RequireResolve extends NodeJS.RequireResolve {}
141
interface NodeModule extends NodeJS.Module {}
142

    
143
declare var process: NodeJS.Process;
144
declare var global: NodeJS.Global;
145
declare var console: Console;
146

    
147
declare var __filename: string;
148
declare var __dirname: string;
149

    
150
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
151
declare namespace setTimeout {
152
    function __promisify__(ms: number): Promise<void>;
153
    function __promisify__<T>(ms: number, value: T): Promise<T>;
154
}
155
declare function clearTimeout(timeoutId: NodeJS.Timeout): void;
156
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
157
declare function clearInterval(intervalId: NodeJS.Timeout): void;
158
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate;
159
declare namespace setImmediate {
160
    function __promisify__(): Promise<void>;
161
    function __promisify__<T>(value: T): Promise<T>;
162
}
163
declare function clearImmediate(immediateId: NodeJS.Immediate): void;
164

    
165
declare function queueMicrotask(callback: () => void): void;
166

    
167
declare var require: NodeRequire;
168
declare var module: NodeModule;
169

    
170
// Same as module.exports
171
declare var exports: any;
172

    
173
// Buffer class
174
type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
175

    
176
/**
177
 * Raw data is stored in instances of the Buffer class.
178
 * 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.
179
 * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
180
 */
181
declare class Buffer extends Uint8Array {
182
    /**
183
     * Allocates a new buffer containing the given {str}.
184
     *
185
     * @param str String to store in buffer.
186
     * @param encoding encoding to use, optional.  Default is 'utf8'
187
     * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
188
     */
189
    constructor(str: string, encoding?: BufferEncoding);
190
    /**
191
     * Allocates a new buffer of {size} octets.
192
     *
193
     * @param size count of octets to allocate.
194
     * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
195
     */
196
    constructor(size: number);
197
    /**
198
     * Allocates a new buffer containing the given {array} of octets.
199
     *
200
     * @param array The octets to store.
201
     * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
202
     */
203
    constructor(array: Uint8Array);
204
    /**
205
     * Produces a Buffer backed by the same allocated memory as
206
     * the given {ArrayBuffer}/{SharedArrayBuffer}.
207
     *
208
     *
209
     * @param arrayBuffer The ArrayBuffer with which to share memory.
210
     * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
211
     */
212
    constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
213
    /**
214
     * Allocates a new buffer containing the given {array} of octets.
215
     *
216
     * @param array The octets to store.
217
     * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
218
     */
219
    constructor(array: any[]);
220
    /**
221
     * Copies the passed {buffer} data onto a new {Buffer} instance.
222
     *
223
     * @param buffer The buffer to copy.
224
     * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
225
     */
226
    constructor(buffer: Buffer);
227
    /**
228
     * When passed a reference to the .buffer property of a TypedArray instance,
229
     * the newly created Buffer will share the same allocated memory as the TypedArray.
230
     * The optional {byteOffset} and {length} arguments specify a memory range
231
     * within the {arrayBuffer} that will be shared by the Buffer.
232
     *
233
     * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
234
     */
235
    static from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
236
    /**
237
     * Creates a new Buffer using the passed {data}
238
     * @param data data to create a new Buffer
239
     */
240
    static from(data: number[]): Buffer;
241
    static from(data: Uint8Array): Buffer;
242
    /**
243
     * Creates a new buffer containing the coerced value of an object
244
     * A `TypeError` will be thrown if {obj} has not mentioned methods or is not of other type appropriate for `Buffer.from()` variants.
245
     * @param obj An object supporting `Symbol.toPrimitive` or `valueOf()`.
246
     */
247
    static from(obj: { valueOf(): string | object } | { [Symbol.toPrimitive](hint: 'string'): string }, byteOffset?: number, length?: number): Buffer;
248
    /**
249
     * Creates a new Buffer containing the given JavaScript string {str}.
250
     * If provided, the {encoding} parameter identifies the character encoding.
251
     * If not provided, {encoding} defaults to 'utf8'.
252
     */
253
    static from(str: string, encoding?: BufferEncoding): Buffer;
254
    /**
255
     * Creates a new Buffer using the passed {data}
256
     * @param values to create a new Buffer
257
     */
258
    static of(...items: number[]): Buffer;
259
    /**
260
     * Returns true if {obj} is a Buffer
261
     *
262
     * @param obj object to test.
263
     */
264
    static isBuffer(obj: any): obj is Buffer;
265
    /**
266
     * Returns true if {encoding} is a valid encoding argument.
267
     * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
268
     *
269
     * @param encoding string to test.
270
     */
271
    static isEncoding(encoding: string): encoding is BufferEncoding;
272
    /**
273
     * Gives the actual byte length of a string. encoding defaults to 'utf8'.
274
     * This is not the same as String.prototype.length since that returns the number of characters in a string.
275
     *
276
     * @param string string to test.
277
     * @param encoding encoding used to evaluate (defaults to 'utf8')
278
     */
279
    static byteLength(
280
        string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
281
        encoding?: BufferEncoding
282
    ): number;
283
    /**
284
     * Returns a buffer which is the result of concatenating all the buffers in the list together.
285
     *
286
     * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
287
     * If the list has exactly one item, then the first item of the list is returned.
288
     * If the list has more than one item, then a new Buffer is created.
289
     *
290
     * @param list An array of Buffer objects to concatenate
291
     * @param totalLength Total length of the buffers when concatenated.
292
     *   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.
293
     */
294
    static concat(list: Uint8Array[], totalLength?: number): Buffer;
295
    /**
296
     * The same as buf1.compare(buf2).
297
     */
298
    static compare(buf1: Uint8Array, buf2: Uint8Array): number;
299
    /**
300
     * Allocates a new buffer of {size} octets.
301
     *
302
     * @param size count of octets to allocate.
303
     * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
304
     *    If parameter is omitted, buffer will be filled with zeros.
305
     * @param encoding encoding used for call to buf.fill while initalizing
306
     */
307
    static alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
308
    /**
309
     * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
310
     * of the newly created Buffer are unknown and may contain sensitive data.
311
     *
312
     * @param size count of octets to allocate
313
     */
314
    static allocUnsafe(size: number): Buffer;
315
    /**
316
     * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
317
     * of the newly created Buffer are unknown and may contain sensitive data.
318
     *
319
     * @param size count of octets to allocate
320
     */
321
    static allocUnsafeSlow(size: number): Buffer;
322
    /**
323
     * 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.
324
     */
325
    static poolSize: number;
326

    
327
    write(string: string, encoding?: BufferEncoding): number;
328
    write(string: string, offset: number, encoding?: BufferEncoding): number;
329
    write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
330
    toString(encoding?: string, start?: number, end?: number): string;
331
    toJSON(): { type: 'Buffer'; data: number[] };
332
    equals(otherBuffer: Uint8Array): boolean;
333
    compare(
334
        otherBuffer: Uint8Array,
335
        targetStart?: number,
336
        targetEnd?: number,
337
        sourceStart?: number,
338
        sourceEnd?: number
339
    ): number;
340
    copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
341
    /**
342
     * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
343
     *
344
     * This method is incompatible with `Uint8Array#slice()`, which returns a copy of the original memory.
345
     *
346
     * @param begin Where the new `Buffer` will start. Default: `0`.
347
     * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
348
     */
349
    slice(begin?: number, end?: number): Buffer;
350
    /**
351
     * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
352
     *
353
     * This method is compatible with `Uint8Array#subarray()`.
354
     *
355
     * @param begin Where the new `Buffer` will start. Default: `0`.
356
     * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
357
     */
358
    subarray(begin?: number, end?: number): Buffer;
359
    writeUIntLE(value: number, offset: number, byteLength: number): number;
360
    writeUIntBE(value: number, offset: number, byteLength: number): number;
361
    writeIntLE(value: number, offset: number, byteLength: number): number;
362
    writeIntBE(value: number, offset: number, byteLength: number): number;
363
    readUIntLE(offset: number, byteLength: number): number;
364
    readUIntBE(offset: number, byteLength: number): number;
365
    readIntLE(offset: number, byteLength: number): number;
366
    readIntBE(offset: number, byteLength: number): number;
367
    readUInt8(offset?: number): number;
368
    readUInt16LE(offset?: number): number;
369
    readUInt16BE(offset?: number): number;
370
    readUInt32LE(offset?: number): number;
371
    readUInt32BE(offset?: number): number;
372
    readInt8(offset?: number): number;
373
    readInt16LE(offset?: number): number;
374
    readInt16BE(offset?: number): number;
375
    readInt32LE(offset?: number): number;
376
    readInt32BE(offset?: number): number;
377
    readFloatLE(offset?: number): number;
378
    readFloatBE(offset?: number): number;
379
    readDoubleLE(offset?: number): number;
380
    readDoubleBE(offset?: number): number;
381
    reverse(): this;
382
    swap16(): Buffer;
383
    swap32(): Buffer;
384
    swap64(): Buffer;
385
    writeUInt8(value: number, offset?: number): number;
386
    writeUInt16LE(value: number, offset?: number): number;
387
    writeUInt16BE(value: number, offset?: number): number;
388
    writeUInt32LE(value: number, offset?: number): number;
389
    writeUInt32BE(value: number, offset?: number): number;
390
    writeInt8(value: number, offset?: number): number;
391
    writeInt16LE(value: number, offset?: number): number;
392
    writeInt16BE(value: number, offset?: number): number;
393
    writeInt32LE(value: number, offset?: number): number;
394
    writeInt32BE(value: number, offset?: number): number;
395
    writeFloatLE(value: number, offset?: number): number;
396
    writeFloatBE(value: number, offset?: number): number;
397
    writeDoubleLE(value: number, offset?: number): number;
398
    writeDoubleBE(value: number, offset?: number): number;
399

    
400
    fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
401

    
402
    indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
403
    lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
404
    entries(): IterableIterator<[number, number]>;
405
    includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
406
    keys(): IterableIterator<number>;
407
    values(): IterableIterator<number>;
408
}
409

    
410
/*----------------------------------------------*
411
*                                               *
412
*               GLOBAL INTERFACES               *
413
*                                               *
414
*-----------------------------------------------*/
415
declare namespace NodeJS {
416
    interface InspectOptions {
417
        /**
418
         * If set to `true`, getters are going to be
419
         * inspected as well. If set to `'get'` only getters without setter are going
420
         * to be inspected. If set to `'set'` only getters having a corresponding
421
         * setter are going to be inspected. This might cause side effects depending on
422
         * the getter function.
423
         * @default `false`
424
         */
425
        getters?: 'get' | 'set' | boolean;
426
        showHidden?: boolean;
427
        /**
428
         * @default 2
429
         */
430
        depth?: number | null;
431
        colors?: boolean;
432
        customInspect?: boolean;
433
        showProxy?: boolean;
434
        maxArrayLength?: number | null;
435
        breakLength?: number;
436
        /**
437
         * Setting this to `false` causes each object key
438
         * to be displayed on a new line. It will also add new lines to text that is
439
         * longer than `breakLength`. If set to a number, the most `n` inner elements
440
         * are united on a single line as long as all properties fit into
441
         * `breakLength`. Short array elements are also grouped together. Note that no
442
         * text will be reduced below 16 characters, no matter the `breakLength` size.
443
         * For more information, see the example below.
444
         * @default `true`
445
         */
446
        compact?: boolean | number;
447
        sorted?: boolean | ((a: string, b: string) => number);
448
    }
449

    
450
    interface ConsoleConstructorOptions {
451
        stdout: WritableStream;
452
        stderr?: WritableStream;
453
        ignoreErrors?: boolean;
454
        colorMode?: boolean | 'auto';
455
        inspectOptions?: InspectOptions;
456
    }
457

    
458
    interface ConsoleConstructor {
459
        prototype: Console;
460
        new(stdout: WritableStream, stderr?: WritableStream, ignoreErrors?: boolean): Console;
461
        new(options: ConsoleConstructorOptions): Console;
462
    }
463

    
464
    interface CallSite {
465
        /**
466
         * Value of "this"
467
         */
468
        getThis(): any;
469

    
470
        /**
471
         * Type of "this" as a string.
472
         * This is the name of the function stored in the constructor field of
473
         * "this", if available.  Otherwise the object's [[Class]] internal
474
         * property.
475
         */
476
        getTypeName(): string | null;
477

    
478
        /**
479
         * Current function
480
         */
481
        getFunction(): Function | undefined;
482

    
483
        /**
484
         * Name of the current function, typically its name property.
485
         * If a name property is not available an attempt will be made to try
486
         * to infer a name from the function's context.
487
         */
488
        getFunctionName(): string | null;
489

    
490
        /**
491
         * Name of the property [of "this" or one of its prototypes] that holds
492
         * the current function
493
         */
494
        getMethodName(): string | null;
495

    
496
        /**
497
         * Name of the script [if this function was defined in a script]
498
         */
499
        getFileName(): string | null;
500

    
501
        /**
502
         * Current line number [if this function was defined in a script]
503
         */
504
        getLineNumber(): number | null;
505

    
506
        /**
507
         * Current column number [if this function was defined in a script]
508
         */
509
        getColumnNumber(): number | null;
510

    
511
        /**
512
         * A call site object representing the location where eval was called
513
         * [if this function was created using a call to eval]
514
         */
515
        getEvalOrigin(): string | undefined;
516

    
517
        /**
518
         * Is this a toplevel invocation, that is, is "this" the global object?
519
         */
520
        isToplevel(): boolean;
521

    
522
        /**
523
         * Does this call take place in code defined by a call to eval?
524
         */
525
        isEval(): boolean;
526

    
527
        /**
528
         * Is this call in native V8 code?
529
         */
530
        isNative(): boolean;
531

    
532
        /**
533
         * Is this a constructor call?
534
         */
535
        isConstructor(): boolean;
536
    }
537

    
538
    interface ErrnoException extends Error {
539
        errno?: number;
540
        code?: string;
541
        path?: string;
542
        syscall?: string;
543
        stack?: string;
544
    }
545

    
546
    interface EventEmitter {
547
        addListener(event: string | symbol, listener: (...args: any[]) => void): this;
548
        on(event: string | symbol, listener: (...args: any[]) => void): this;
549
        once(event: string | symbol, listener: (...args: any[]) => void): this;
550
        removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
551
        off(event: string | symbol, listener: (...args: any[]) => void): this;
552
        removeAllListeners(event?: string | symbol): this;
553
        setMaxListeners(n: number): this;
554
        getMaxListeners(): number;
555
        listeners(event: string | symbol): Function[];
556
        rawListeners(event: string | symbol): Function[];
557
        emit(event: string | symbol, ...args: any[]): boolean;
558
        listenerCount(type: string | symbol): number;
559
        // Added in Node 6...
560
        prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
561
        prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
562
        eventNames(): Array<string | symbol>;
563
    }
564

    
565
    interface ReadableStream extends EventEmitter {
566
        readable: boolean;
567
        read(size?: number): string | Buffer;
568
        setEncoding(encoding: string): this;
569
        pause(): this;
570
        resume(): this;
571
        isPaused(): boolean;
572
        pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
573
        unpipe(destination?: WritableStream): this;
574
        unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
575
        wrap(oldStream: ReadableStream): this;
576
        [Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
577
    }
578

    
579
    interface WritableStream extends EventEmitter {
580
        writable: boolean;
581
        write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
582
        write(str: string, encoding?: string, cb?: (err?: Error | null) => void): boolean;
583
        end(cb?: () => void): void;
584
        end(data: string | Uint8Array, cb?: () => void): void;
585
        end(str: string, encoding?: string, cb?: () => void): void;
586
    }
587

    
588
    interface ReadWriteStream extends ReadableStream, WritableStream { }
589

    
590
    interface Domain extends EventEmitter {
591
        run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
592
        add(emitter: EventEmitter | Timer): void;
593
        remove(emitter: EventEmitter | Timer): void;
594
        bind<T extends Function>(cb: T): T;
595
        intercept<T extends Function>(cb: T): T;
596

    
597
        addListener(event: string, listener: (...args: any[]) => void): this;
598
        on(event: string, listener: (...args: any[]) => void): this;
599
        once(event: string, listener: (...args: any[]) => void): this;
600
        removeListener(event: string, listener: (...args: any[]) => void): this;
601
        removeAllListeners(event?: string): this;
602
    }
603

    
604
    interface MemoryUsage {
605
        rss: number;
606
        heapTotal: number;
607
        heapUsed: number;
608
        external: number;
609
        arrayBuffers: number;
610
    }
611

    
612
    interface CpuUsage {
613
        user: number;
614
        system: number;
615
    }
616

    
617
    interface ProcessRelease {
618
        name: string;
619
        sourceUrl?: string;
620
        headersUrl?: string;
621
        libUrl?: string;
622
        lts?: string;
623
    }
624

    
625
    interface ProcessVersions {
626
        http_parser: string;
627
        node: string;
628
        v8: string;
629
        ares: string;
630
        uv: string;
631
        zlib: string;
632
        modules: string;
633
        openssl: string;
634
    }
635

    
636
    type Platform = 'aix'
637
        | 'android'
638
        | 'darwin'
639
        | 'freebsd'
640
        | 'linux'
641
        | 'openbsd'
642
        | 'sunos'
643
        | 'win32'
644
        | 'cygwin'
645
        | 'netbsd';
646

    
647
    type Signals =
648
        "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" |
649
        "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" |
650
        "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" |
651
        "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO";
652

    
653
    type MultipleResolveType = 'resolve' | 'reject';
654

    
655
    type BeforeExitListener = (code: number) => void;
656
    type DisconnectListener = () => void;
657
    type ExitListener = (code: number) => void;
658
    type RejectionHandledListener = (promise: Promise<any>) => void;
659
    type UncaughtExceptionListener = (error: Error) => void;
660
    type UnhandledRejectionListener = (reason: {} | null | undefined, promise: Promise<any>) => void;
661
    type WarningListener = (warning: Error) => void;
662
    type MessageListener = (message: any, sendHandle: any) => void;
663
    type SignalsListener = (signal: Signals) => void;
664
    type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
665
    type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
666
    type MultipleResolveListener = (type: MultipleResolveType, promise: Promise<any>, value: any) => void;
667

    
668
    interface Socket extends ReadWriteStream {
669
        isTTY?: true;
670
    }
671

    
672
    interface ProcessEnv {
673
        [key: string]: string | undefined;
674
    }
675

    
676
    interface HRTime {
677
        (time?: [number, number]): [number, number];
678
    }
679

    
680
    interface ProcessReport {
681
        /**
682
         * Directory where the report is written.
683
         * working directory of the Node.js process.
684
         * @default '' indicating that reports are written to the current
685
         */
686
        directory: string;
687

    
688
        /**
689
         * Filename where the report is written.
690
         * The default value is the empty string.
691
         * @default '' the output filename will be comprised of a timestamp,
692
         * PID, and sequence number.
693
         */
694
        filename: string;
695

    
696
        /**
697
         * Returns a JSON-formatted diagnostic report for the running process.
698
         * The report's JavaScript stack trace is taken from err, if present.
699
         */
700
        getReport(err?: Error): string;
701

    
702
        /**
703
         * If true, a diagnostic report is generated on fatal errors,
704
         * such as out of memory errors or failed C++ assertions.
705
         * @default false
706
         */
707
        reportOnFatalError: boolean;
708

    
709
        /**
710
         * If true, a diagnostic report is generated when the process
711
         * receives the signal specified by process.report.signal.
712
         * @defaul false
713
         */
714
        reportOnSignal: boolean;
715

    
716
        /**
717
         * If true, a diagnostic report is generated on uncaught exception.
718
         * @default false
719
         */
720
        reportOnUncaughtException: boolean;
721

    
722
        /**
723
         * The signal used to trigger the creation of a diagnostic report.
724
         * @default 'SIGUSR2'
725
         */
726
        signal: Signals;
727

    
728
        /**
729
         * Writes a diagnostic report to a file. If filename is not provided, the default filename
730
         * includes the date, time, PID, and a sequence number.
731
         * The report's JavaScript stack trace is taken from err, if present.
732
         *
733
         * @param fileName Name of the file where the report is written.
734
         * This should be a relative path, that will be appended to the directory specified in
735
         * `process.report.directory`, or the current working directory of the Node.js process,
736
         * if unspecified.
737
         * @param error A custom error used for reporting the JavaScript stack.
738
         * @return Filename of the generated report.
739
         */
740
        writeReport(fileName?: string): string;
741
        writeReport(error?: Error): string;
742
        writeReport(fileName?: string, err?: Error): string;
743
    }
744

    
745
    interface ResourceUsage {
746
        fsRead: number;
747
        fsWrite: number;
748
        involuntaryContextSwitches: number;
749
        ipcReceived: number;
750
        ipcSent: number;
751
        majorPageFault: number;
752
        maxRSS: number;
753
        minorPageFault: number;
754
        sharedMemorySize: number;
755
        signalsCount: number;
756
        swappedOut: number;
757
        systemCPUTime: number;
758
        unsharedDataSize: number;
759
        unsharedStackSize: number;
760
        userCPUTime: number;
761
        voluntaryContextSwitches: number;
762
    }
763

    
764
    interface Process extends EventEmitter {
765
        /**
766
         * Can also be a tty.WriteStream, not typed due to limitation.s
767
         */
768
        stdout: WriteStream;
769
        /**
770
         * Can also be a tty.WriteStream, not typed due to limitation.s
771
         */
772
        stderr: WriteStream;
773
        stdin: ReadStream;
774
        openStdin(): Socket;
775
        argv: string[];
776
        argv0: string;
777
        execArgv: string[];
778
        execPath: string;
779
        abort(): void;
780
        chdir(directory: string): void;
781
        cwd(): string;
782
        debugPort: number;
783
        emitWarning(warning: string | Error, name?: string, ctor?: Function): void;
784
        env: ProcessEnv;
785
        exit(code?: number): never;
786
        exitCode?: number;
787
        getgid(): number;
788
        setgid(id: number | string): void;
789
        getuid(): number;
790
        setuid(id: number | string): void;
791
        geteuid(): number;
792
        seteuid(id: number | string): void;
793
        getegid(): number;
794
        setegid(id: number | string): void;
795
        getgroups(): number[];
796
        setgroups(groups: Array<string | number>): void;
797
        setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
798
        hasUncaughtExceptionCaptureCallback(): boolean;
799
        version: string;
800
        versions: ProcessVersions;
801
        config: {
802
            target_defaults: {
803
                cflags: any[];
804
                default_configuration: string;
805
                defines: string[];
806
                include_dirs: string[];
807
                libraries: string[];
808
            };
809
            variables: {
810
                clang: number;
811
                host_arch: string;
812
                node_install_npm: boolean;
813
                node_install_waf: boolean;
814
                node_prefix: string;
815
                node_shared_openssl: boolean;
816
                node_shared_v8: boolean;
817
                node_shared_zlib: boolean;
818
                node_use_dtrace: boolean;
819
                node_use_etw: boolean;
820
                node_use_openssl: boolean;
821
                target_arch: string;
822
                v8_no_strict_aliasing: number;
823
                v8_use_snapshot: boolean;
824
                visibility: string;
825
            };
826
        };
827
        kill(pid: number, signal?: string | number): void;
828
        pid: number;
829
        ppid: number;
830
        title: string;
831
        arch: string;
832
        platform: Platform;
833
        mainModule?: Module;
834
        memoryUsage(): MemoryUsage;
835
        cpuUsage(previousValue?: CpuUsage): CpuUsage;
836
        nextTick(callback: Function, ...args: any[]): void;
837
        release: ProcessRelease;
838
        features: {
839
            inspector: boolean;
840
            debug: boolean;
841
            uv: boolean;
842
            ipv6: boolean;
843
            tls_alpn: boolean;
844
            tls_sni: boolean;
845
            tls_ocsp: boolean;
846
            tls: boolean;
847
        };
848
        /**
849
         * Can only be set if not in worker thread.
850
         */
851
        umask(mask?: number): number;
852
        uptime(): number;
853
        hrtime: HRTime;
854
        domain: Domain;
855

    
856
        // Worker
857
        send?(message: any, sendHandle?: any, options?: { swallowErrors?: boolean}, callback?: (error: Error | null) => void): boolean;
858
        disconnect(): void;
859
        connected: boolean;
860

    
861
        /**
862
         * The `process.allowedNodeEnvironmentFlags` property is a special,
863
         * read-only `Set` of flags allowable within the [`NODE_OPTIONS`][]
864
         * environment variable.
865
         */
866
        allowedNodeEnvironmentFlags: ReadonlySet<string>;
867

    
868
        /**
869
         * Only available with `--experimental-report`
870
         */
871
        report?: ProcessReport;
872

    
873
        resourceUsage(): ResourceUsage;
874

    
875
        /* EventEmitter */
876
        addListener(event: "beforeExit", listener: BeforeExitListener): this;
877
        addListener(event: "disconnect", listener: DisconnectListener): this;
878
        addListener(event: "exit", listener: ExitListener): this;
879
        addListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
880
        addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
881
        addListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
882
        addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
883
        addListener(event: "warning", listener: WarningListener): this;
884
        addListener(event: "message", listener: MessageListener): this;
885
        addListener(event: Signals, listener: SignalsListener): this;
886
        addListener(event: "newListener", listener: NewListenerListener): this;
887
        addListener(event: "removeListener", listener: RemoveListenerListener): this;
888
        addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
889

    
890
        emit(event: "beforeExit", code: number): boolean;
891
        emit(event: "disconnect"): boolean;
892
        emit(event: "exit", code: number): boolean;
893
        emit(event: "rejectionHandled", promise: Promise<any>): boolean;
894
        emit(event: "uncaughtException", error: Error): boolean;
895
        emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
896
        emit(event: "unhandledRejection", reason: any, promise: Promise<any>): boolean;
897
        emit(event: "warning", warning: Error): boolean;
898
        emit(event: "message", message: any, sendHandle: any): this;
899
        emit(event: Signals, signal: Signals): boolean;
900
        emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this;
901
        emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this;
902
        emit(event: "multipleResolves", listener: MultipleResolveListener): this;
903

    
904
        on(event: "beforeExit", listener: BeforeExitListener): this;
905
        on(event: "disconnect", listener: DisconnectListener): this;
906
        on(event: "exit", listener: ExitListener): this;
907
        on(event: "rejectionHandled", listener: RejectionHandledListener): this;
908
        on(event: "uncaughtException", listener: UncaughtExceptionListener): this;
909
        on(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
910
        on(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
911
        on(event: "warning", listener: WarningListener): this;
912
        on(event: "message", listener: MessageListener): this;
913
        on(event: Signals, listener: SignalsListener): this;
914
        on(event: "newListener", listener: NewListenerListener): this;
915
        on(event: "removeListener", listener: RemoveListenerListener): this;
916
        on(event: "multipleResolves", listener: MultipleResolveListener): this;
917

    
918
        once(event: "beforeExit", listener: BeforeExitListener): this;
919
        once(event: "disconnect", listener: DisconnectListener): this;
920
        once(event: "exit", listener: ExitListener): this;
921
        once(event: "rejectionHandled", listener: RejectionHandledListener): this;
922
        once(event: "uncaughtException", listener: UncaughtExceptionListener): this;
923
        once(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
924
        once(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
925
        once(event: "warning", listener: WarningListener): this;
926
        once(event: "message", listener: MessageListener): this;
927
        once(event: Signals, listener: SignalsListener): this;
928
        once(event: "newListener", listener: NewListenerListener): this;
929
        once(event: "removeListener", listener: RemoveListenerListener): this;
930
        once(event: "multipleResolves", listener: MultipleResolveListener): this;
931

    
932
        prependListener(event: "beforeExit", listener: BeforeExitListener): this;
933
        prependListener(event: "disconnect", listener: DisconnectListener): this;
934
        prependListener(event: "exit", listener: ExitListener): this;
935
        prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
936
        prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
937
        prependListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
938
        prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
939
        prependListener(event: "warning", listener: WarningListener): this;
940
        prependListener(event: "message", listener: MessageListener): this;
941
        prependListener(event: Signals, listener: SignalsListener): this;
942
        prependListener(event: "newListener", listener: NewListenerListener): this;
943
        prependListener(event: "removeListener", listener: RemoveListenerListener): this;
944
        prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
945

    
946
        prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
947
        prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
948
        prependOnceListener(event: "exit", listener: ExitListener): this;
949
        prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
950
        prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
951
        prependOnceListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
952
        prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
953
        prependOnceListener(event: "warning", listener: WarningListener): this;
954
        prependOnceListener(event: "message", listener: MessageListener): this;
955
        prependOnceListener(event: Signals, listener: SignalsListener): this;
956
        prependOnceListener(event: "newListener", listener: NewListenerListener): this;
957
        prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this;
958
        prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
959

    
960
        listeners(event: "beforeExit"): BeforeExitListener[];
961
        listeners(event: "disconnect"): DisconnectListener[];
962
        listeners(event: "exit"): ExitListener[];
963
        listeners(event: "rejectionHandled"): RejectionHandledListener[];
964
        listeners(event: "uncaughtException"): UncaughtExceptionListener[];
965
        listeners(event: "uncaughtExceptionMonitor"): UncaughtExceptionListener[];
966
        listeners(event: "unhandledRejection"): UnhandledRejectionListener[];
967
        listeners(event: "warning"): WarningListener[];
968
        listeners(event: "message"): MessageListener[];
969
        listeners(event: Signals): SignalsListener[];
970
        listeners(event: "newListener"): NewListenerListener[];
971
        listeners(event: "removeListener"): RemoveListenerListener[];
972
        listeners(event: "multipleResolves"): MultipleResolveListener[];
973
    }
974

    
975
    interface Global {
976
        Array: typeof Array;
977
        ArrayBuffer: typeof ArrayBuffer;
978
        Boolean: typeof Boolean;
979
        Buffer: typeof Buffer;
980
        DataView: typeof DataView;
981
        Date: typeof Date;
982
        Error: typeof Error;
983
        EvalError: typeof EvalError;
984
        Float32Array: typeof Float32Array;
985
        Float64Array: typeof Float64Array;
986
        Function: typeof Function;
987
        GLOBAL: Global;
988
        Infinity: typeof Infinity;
989
        Int16Array: typeof Int16Array;
990
        Int32Array: typeof Int32Array;
991
        Int8Array: typeof Int8Array;
992
        Intl: typeof Intl;
993
        JSON: typeof JSON;
994
        Map: MapConstructor;
995
        Math: typeof Math;
996
        NaN: typeof NaN;
997
        Number: typeof Number;
998
        Object: typeof Object;
999
        Promise: typeof Promise;
1000
        RangeError: typeof RangeError;
1001
        ReferenceError: typeof ReferenceError;
1002
        RegExp: typeof RegExp;
1003
        Set: SetConstructor;
1004
        String: typeof String;
1005
        Symbol: Function;
1006
        SyntaxError: typeof SyntaxError;
1007
        TypeError: typeof TypeError;
1008
        URIError: typeof URIError;
1009
        Uint16Array: typeof Uint16Array;
1010
        Uint32Array: typeof Uint32Array;
1011
        Uint8Array: typeof Uint8Array;
1012
        Uint8ClampedArray: typeof Uint8ClampedArray;
1013
        WeakMap: WeakMapConstructor;
1014
        WeakSet: WeakSetConstructor;
1015
        clearImmediate: (immediateId: Immediate) => void;
1016
        clearInterval: (intervalId: Timeout) => void;
1017
        clearTimeout: (timeoutId: Timeout) => void;
1018
        console: typeof console;
1019
        decodeURI: typeof decodeURI;
1020
        decodeURIComponent: typeof decodeURIComponent;
1021
        encodeURI: typeof encodeURI;
1022
        encodeURIComponent: typeof encodeURIComponent;
1023
        escape: (str: string) => string;
1024
        eval: typeof eval;
1025
        global: Global;
1026
        isFinite: typeof isFinite;
1027
        isNaN: typeof isNaN;
1028
        parseFloat: typeof parseFloat;
1029
        parseInt: typeof parseInt;
1030
        process: Process;
1031
        /**
1032
         * @deprecated Use `global`.
1033
         */
1034
        root: Global;
1035
        setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => Immediate;
1036
        setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
1037
        setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
1038
        queueMicrotask: typeof queueMicrotask;
1039
        undefined: typeof undefined;
1040
        unescape: (str: string) => string;
1041
        gc: () => void;
1042
        v8debug?: any;
1043
    }
1044

    
1045
    interface RefCounted {
1046
        ref(): this;
1047
        unref(): this;
1048
    }
1049

    
1050
    // compatibility with older typings
1051
    interface Timer extends RefCounted {
1052
        hasRef(): boolean;
1053
        refresh(): this;
1054
    }
1055

    
1056
    interface Immediate extends RefCounted {
1057
        hasRef(): boolean;
1058
        _onImmediate: Function; // to distinguish it from the Timeout class
1059
    }
1060

    
1061
    interface Timeout extends Timer {
1062
        hasRef(): boolean;
1063
        refresh(): this;
1064
    }
1065

    
1066
    type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
1067
    type ArrayBufferView = TypedArray | DataView;
1068

    
1069
    interface NodeRequireCache {
1070
        [path: string]: NodeModule;
1071
    }
1072

    
1073
    interface Require {
1074
        /* tslint:disable-next-line:callable-types */
1075
        (id: string): any;
1076
        resolve: RequireResolve;
1077
        cache: NodeRequireCache;
1078
        /**
1079
         * @deprecated
1080
         */
1081
        extensions: RequireExtensions;
1082
        main: Module | undefined;
1083
    }
1084

    
1085
    interface RequireResolve {
1086
        (id: string, options?: { paths?: string[]; }): string;
1087
        paths(request: string): string[] | null;
1088
    }
1089

    
1090
    interface RequireExtensions {
1091
        '.js': (m: Module, filename: string) => any;
1092
        '.json': (m: Module, filename: string) => any;
1093
        '.node': (m: Module, filename: string) => any;
1094
        [ext: string]: (m: Module, filename: string) => any;
1095
    }
1096
    interface Module {
1097
        exports: any;
1098
        require: Require;
1099
        id: string;
1100
        filename: string;
1101
        loaded: boolean;
1102
        parent: Module | null;
1103
        children: Module[];
1104
        paths: string[];
1105
    }
1106
}
(17-17/45)