main
js 4,289 lines 121 KB
Raw
1 // flow-typed signature: 44d8f5b0b708cdf7288ec50b7c08e1bf
2 // flow-typed version: 832153ff79/node/flow_>=v0.261.x
3
4 interface ErrnoError extends Error {
5 address?: string;
6 code?: string;
7 dest?: string;
8 errno?: string | number;
9 info?: Object;
10 path?: string;
11 port?: number;
12 syscall?: string;
13 }
14
15 type Node$Conditional<T: boolean, IfTrue, IfFalse> = T extends true
16 ? IfTrue
17 : T extends false
18 ? IfFalse
19 : IfTrue | IfFalse;
20
21 type buffer$NonBufferEncoding =
22 | 'hex'
23 | 'HEX'
24 | 'utf8'
25 | 'UTF8'
26 | 'utf-8'
27 | 'UTF-8'
28 | 'ascii'
29 | 'ASCII'
30 | 'binary'
31 | 'BINARY'
32 | 'base64'
33 | 'BASE64'
34 | 'ucs2'
35 | 'UCS2'
36 | 'ucs-2'
37 | 'UCS-2'
38 | 'utf16le'
39 | 'UTF16LE'
40 | 'utf-16le'
41 | 'UTF-16LE'
42 | 'latin1';
43 type buffer$Encoding = buffer$NonBufferEncoding | 'buffer';
44 type buffer$ToJSONRet = {
45 type: string,
46 data: Array<number>,
47 ...
48 };
49
50 declare class Buffer extends Uint8Array {
51 constructor(
52 value: Array<number> | number | string | Buffer | ArrayBuffer,
53 encoding?: buffer$Encoding
54 ): void;
55 [i: number]: number;
56 length: number;
57
58 compare(otherBuffer: Buffer): number;
59 copy(
60 targetBuffer: Buffer,
61 targetStart?: number,
62 sourceStart?: number,
63 sourceEnd?: number
64 ): number;
65 entries(): Iterator<[number, number]>;
66 equals(otherBuffer: Buffer): boolean;
67 fill(
68 value: string | Buffer | number,
69 offset?: number,
70 end?: number,
71 encoding?: string
72 ): this;
73 fill(value: string, encoding?: string): this;
74 includes(
75 value: string | Buffer | number,
76 offsetOrEncoding?: number | buffer$Encoding,
77 encoding?: buffer$Encoding
78 ): boolean;
79 indexOf(
80 value: string | Buffer | number,
81 offsetOrEncoding?: number | buffer$Encoding,
82 encoding?: buffer$Encoding
83 ): number;
84 inspect(): string;
85 keys(): Iterator<number>;
86 lastIndexOf(
87 value: string | Buffer | number,
88 offsetOrEncoding?: number | buffer$Encoding,
89 encoding?: buffer$Encoding
90 ): number;
91 readDoubleBE(offset?: number, noAssert?: boolean): number;
92 readDoubleLE(offset?: number, noAssert?: boolean): number;
93 readFloatBE(offset?: number, noAssert?: boolean): number;
94 readFloatLE(offset?: number, noAssert?: boolean): number;
95 readInt16BE(offset?: number, noAssert?: boolean): number;
96 readInt16LE(offset?: number, noAssert?: boolean): number;
97 readInt32BE(offset?: number, noAssert?: boolean): number;
98 readInt32LE(offset?: number, noAssert?: boolean): number;
99 readInt8(offset?: number, noAssert?: boolean): number;
100 readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
101 readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
102 readUInt16BE(offset?: number, noAssert?: boolean): number;
103 readUInt16LE(offset?: number, noAssert?: boolean): number;
104 readUInt32BE(offset?: number, noAssert?: boolean): number;
105 readUInt32LE(offset?: number, noAssert?: boolean): number;
106 readUInt8(offset?: number, noAssert?: boolean): number;
107 readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
108 readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
109 slice(start?: number, end?: number): this;
110 swap16(): Buffer;
111 swap32(): Buffer;
112 swap64(): Buffer;
113 toJSON(): buffer$ToJSONRet;
114 toString(encoding?: buffer$Encoding, start?: number, end?: number): string;
115 values(): Iterator<number>;
116 write(
117 string: string,
118 offset?: number,
119 length?: number,
120 encoding?: buffer$Encoding
121 ): number;
122 writeDoubleBE(value: number, offset?: number, noAssert?: boolean): number;
123 writeDoubleLE(value: number, offset?: number, noAssert?: boolean): number;
124 writeFloatBE(value: number, offset?: number, noAssert?: boolean): number;
125 writeFloatLE(value: number, offset?: number, noAssert?: boolean): number;
126 writeInt16BE(value: number, offset?: number, noAssert?: boolean): number;
127 writeInt16LE(value: number, offset?: number, noAssert?: boolean): number;
128 writeInt32BE(value: number, offset?: number, noAssert?: boolean): number;
129 writeInt32LE(value: number, offset?: number, noAssert?: boolean): number;
130 writeInt8(value: number, offset?: number, noAssert?: boolean): number;
131 writeIntBE(
132 value: number,
133 offset: number,
134 byteLength: number,
135 noAssert?: boolean
136 ): number;
137 writeIntLE(
138 value: number,
139 offset: number,
140 byteLength: number,
141 noAssert?: boolean
142 ): number;
143 writeUInt16BE(value: number, offset?: number, noAssert?: boolean): number;
144 writeUInt16LE(value: number, offset?: number, noAssert?: boolean): number;
145 writeUInt32BE(value: number, offset?: number, noAssert?: boolean): number;
146 writeUInt32LE(value: number, offset?: number, noAssert?: boolean): number;
147 writeUInt8(value: number, offset?: number, noAssert?: boolean): number;
148 writeUIntBE(
149 value: number,
150 offset: number,
151 byteLength: number,
152 noAssert?: boolean
153 ): number;
154 writeUIntLE(
155 value: number,
156 offset: number,
157 byteLength: number,
158 noAssert?: boolean
159 ): number;
160
161 static alloc(
162 size: number,
163 fill?: string | number,
164 encoding?: buffer$Encoding
165 ): Buffer;
166 static allocUnsafe(size: number): Buffer;
167 static allocUnsafeSlow(size: number): Buffer;
168 static byteLength(
169 string: string | Buffer | $TypedArray | DataView | ArrayBuffer,
170 encoding?: buffer$Encoding
171 ): number;
172 static compare(buf1: Buffer, buf2: Buffer): number;
173 static concat(list: Array<Buffer>, totalLength?: number): Buffer;
174
175 static from(value: Buffer): Buffer;
176 static from(value: string, encoding?: buffer$Encoding): Buffer;
177 static from(
178 value: ArrayBuffer | SharedArrayBuffer,
179 byteOffset?: number,
180 length?: number
181 ): Buffer;
182 static from(value: Iterable<number>): this;
183 static isBuffer(obj: any): boolean;
184 static isEncoding(encoding: string): boolean;
185 }
186
187 declare type Node$Buffer = typeof Buffer;
188
189 declare module 'buffer' {
190 declare var kMaxLength: number;
191 declare var INSPECT_MAX_BYTES: number;
192 declare function transcode(
193 source: Node$Buffer,
194 fromEnc: buffer$Encoding,
195 toEnc: buffer$Encoding
196 ): Node$Buffer;
197 declare var Buffer: Node$Buffer;
198 }
199
200 type child_process$execOpts = {
201 cwd?: string,
202 env?: Object,
203 encoding?: string,
204 shell?: string,
205 timeout?: number,
206 maxBuffer?: number,
207 killSignal?: string | number,
208 uid?: number,
209 gid?: number,
210 windowsHide?: boolean,
211 ...
212 };
213
214 declare class child_process$Error extends Error {
215 code: number | string | null;
216 errno?: string;
217 syscall?: string;
218 path?: string;
219 spawnargs?: Array<string>;
220 killed?: boolean;
221 signal?: string | null;
222 cmd: string;
223 }
224
225 type child_process$execCallback = (
226 error: ?child_process$Error,
227 stdout: string | Buffer,
228 stderr: string | Buffer
229 ) => void;
230
231 type child_process$execSyncOpts = {
232 cwd?: string,
233 input?: string | Buffer | $TypedArray | DataView,
234 stdio?: string | Array<any>,
235 env?: Object,
236 shell?: string,
237 uid?: number,
238 gid?: number,
239 timeout?: number,
240 killSignal?: string | number,
241 maxBuffer?: number,
242 encoding?: string,
243 windowsHide?: boolean,
244 ...
245 };
246
247 type child_process$execFileOpts = {
248 cwd?: string,
249 env?: Object,
250 encoding?: string,
251 timeout?: number,
252 maxBuffer?: number,
253 killSignal?: string | number,
254 uid?: number,
255 gid?: number,
256 windowsHide?: boolean,
257 windowsVerbatimArguments?: boolean,
258 shell?: boolean | string,
259 ...
260 };
261
262 type child_process$execFileCallback = (
263 error: ?child_process$Error,
264 stdout: string | Buffer,
265 stderr: string | Buffer
266 ) => void;
267
268 type child_process$execFileSyncOpts = {
269 cwd?: string,
270 input?: string | Buffer | $TypedArray | DataView,
271 stdio?: string | Array<any>,
272 env?: Object,
273 uid?: number,
274 gid?: number,
275 timeout?: number,
276 killSignal?: string | number,
277 maxBuffer?: number,
278 encoding?: string,
279 windowsHide?: boolean,
280 shell?: boolean | string,
281 ...
282 };
283
284 type child_process$forkOpts = {
285 cwd?: string,
286 env?: Object,
287 execPath?: string,
288 execArgv?: Array<string>,
289 silent?: boolean,
290 stdio?: Array<any> | string,
291 windowsVerbatimArguments?: boolean,
292 uid?: number,
293 gid?: number,
294 ...
295 };
296
297 type child_process$Handle = any; // TODO
298
299 type child_process$spawnOpts = {
300 cwd?: string,
301 env?: Object,
302 argv0?: string,
303 stdio?: string | Array<any>,
304 detached?: boolean,
305 uid?: number,
306 gid?: number,
307 shell?: boolean | string,
308 windowsVerbatimArguments?: boolean,
309 windowsHide?: boolean,
310 ...
311 };
312
313 type child_process$spawnRet = {
314 pid: number,
315 output: Array<any>,
316 stdout: Buffer | string,
317 stderr: Buffer | string,
318 status: number,
319 signal: string,
320 error: Error,
321 ...
322 };
323
324 type child_process$spawnSyncOpts = {
325 cwd?: string,
326 input?: string | Buffer,
327 stdio?: string | Array<any>,
328 env?: Object,
329 uid?: number,
330 gid?: number,
331 timeout?: number,
332 killSignal?: string,
333 maxBuffer?: number,
334 encoding?: string,
335 shell?: boolean | string,
336 ...
337 };
338
339 type child_process$spawnSyncRet = child_process$spawnRet;
340
341 declare class child_process$ChildProcess extends events$EventEmitter {
342 channel: Object;
343 connected: boolean;
344 killed: boolean;
345 pid: number;
346 exitCode: number | null;
347 stderr: stream$Readable;
348 stdin: stream$Writable;
349 stdio: Array<any>;
350 stdout: stream$Readable;
351
352 disconnect(): void;
353 kill(signal?: string): void;
354 send(
355 message: Object,
356 sendHandleOrCallback?: child_process$Handle,
357 optionsOrCallback?: Object | Function,
358 callback?: Function
359 ): boolean;
360 unref(): void;
361 ref(): void;
362 }
363
364 declare module 'child_process' {
365 declare var ChildProcess: typeof child_process$ChildProcess;
366
367 declare function exec(
368 command: string,
369 optionsOrCallback?: child_process$execOpts | child_process$execCallback,
370 callback?: child_process$execCallback
371 ): child_process$ChildProcess;
372
373 declare function execSync(
374 command: string,
375 options: {
376 encoding: buffer$NonBufferEncoding,
377 ...
378 } & child_process$execSyncOpts
379 ): string;
380
381 declare function execSync(
382 command: string,
383 options?: child_process$execSyncOpts
384 ): Buffer;
385
386 declare function execFile(
387 file: string,
388 argsOrOptionsOrCallback?:
389 | Array<string>
390 | child_process$execFileOpts
391 | child_process$execFileCallback,
392 optionsOrCallback?:
393 | child_process$execFileOpts
394 | child_process$execFileCallback,
395 callback?: child_process$execFileCallback
396 ): child_process$ChildProcess;
397
398 declare function execFileSync(
399 command: string,
400 argsOrOptions?: Array<string> | child_process$execFileSyncOpts,
401 options?: child_process$execFileSyncOpts
402 ): Buffer | string;
403
404 declare function fork(
405 modulePath: string,
406 argsOrOptions?: Array<string> | child_process$forkOpts,
407 options?: child_process$forkOpts
408 ): child_process$ChildProcess;
409
410 declare function spawn(
411 command: string,
412 argsOrOptions?: Array<string> | child_process$spawnOpts,
413 options?: child_process$spawnOpts
414 ): child_process$ChildProcess;
415
416 declare function spawnSync(
417 command: string,
418 argsOrOptions?: Array<string> | child_process$spawnSyncOpts,
419 options?: child_process$spawnSyncOpts
420 ): child_process$spawnSyncRet;
421 }
422
423 declare module 'cluster' {
424 declare type ClusterSettings = {
425 execArgv: Array<string>,
426 exec: string,
427 args: Array<string>,
428 cwd: string,
429 serialization: 'json' | 'advanced',
430 silent: boolean,
431 stdio: Array<any>,
432 uid: number,
433 gid: number,
434 inspectPort: number | (() => number),
435 windowsHide: boolean,
436 ...
437 };
438
439 declare type ClusterSettingsOpt = {
440 execArgv?: Array<string>,
441 exec?: string,
442 args?: Array<string>,
443 cwd?: string,
444 serialization?: 'json' | 'advanced',
445 silent?: boolean,
446 stdio?: Array<any>,
447 uid?: number,
448 gid?: number,
449 inspectPort?: number | (() => number),
450 windowsHide?: boolean,
451 ...
452 };
453
454 declare class Worker extends events$EventEmitter {
455 id: number;
456 process: child_process$ChildProcess;
457 suicide: boolean;
458
459 disconnect(): void;
460 isConnected(): boolean;
461 isDead(): boolean;
462 kill(signal?: string): void;
463 send(
464 message: Object,
465 sendHandleOrCallback?: child_process$Handle | Function,
466 callback?: Function
467 ): boolean;
468 }
469
470 declare class Cluster extends events$EventEmitter {
471 isMaster: boolean;
472 isWorker: boolean;
473 settings: ClusterSettings;
474 worker: Worker;
475 workers: {[id: number]: Worker};
476
477 disconnect(callback?: () => void): void;
478 fork(env?: Object): Worker;
479 setupMaster(settings?: ClusterSettingsOpt): void;
480 }
481
482 declare module.exports: Cluster;
483 }
484
485 type crypto$createCredentialsDetails = any; // TODO
486
487 declare class crypto$Cipher extends stream$Duplex {
488 final(output_encoding: 'latin1' | 'binary' | 'base64' | 'hex'): string;
489 final(output_encoding: void): Buffer;
490 getAuthTag(): Buffer;
491 setAAD(buffer: Buffer): crypto$Cipher;
492 setAuthTag(buffer: Buffer): void;
493 setAutoPadding(auto_padding?: boolean): crypto$Cipher;
494 update(
495 data: string,
496 input_encoding: 'utf8' | 'ascii' | 'latin1' | 'binary',
497 output_encoding: 'latin1' | 'binary' | 'base64' | 'hex'
498 ): string;
499 update(
500 data: string,
501 input_encoding: 'utf8' | 'ascii' | 'latin1' | 'binary',
502 output_encoding: void
503 ): Buffer;
504 update(
505 data: Buffer,
506 input_encoding: void | 'utf8' | 'ascii' | 'latin1' | 'binary',
507 output_encoding: 'latin1' | 'binary' | 'base64' | 'hex'
508 ): string;
509 update(data: Buffer, input_encoding: void, output_encoding: void): Buffer;
510 }
511
512 type crypto$Credentials = {...};
513
514 type crypto$DiffieHellman = {
515 computeSecret(
516 other_public_key: string,
517 input_encoding?: string,
518 output_encoding?: string
519 ): any,
520 generateKeys(encoding?: string): any,
521 getGenerator(encoding?: string): any,
522 getPrime(encoding?: string): any,
523 getPrivateKey(encoding?: string): any,
524 getPublicKey(encoding?: string): any,
525 setPrivateKey(private_key: any, encoding?: string): void,
526 setPublicKey(public_key: any, encoding?: string): void,
527 ...
528 };
529
530 type crypto$ECDH$Encoding = 'latin1' | 'hex' | 'base64';
531 type crypto$ECDH$Format = 'compressed' | 'uncompressed';
532
533 declare class crypto$ECDH {
534 computeSecret(other_public_key: Buffer | $TypedArray | DataView): Buffer;
535 computeSecret(
536 other_public_key: string,
537 input_encoding: crypto$ECDH$Encoding
538 ): Buffer;
539 computeSecret(
540 other_public_key: Buffer | $TypedArray | DataView,
541 output_encoding: crypto$ECDH$Encoding
542 ): string;
543 computeSecret(
544 other_public_key: string,
545 input_encoding: crypto$ECDH$Encoding,
546 output_encoding: crypto$ECDH$Encoding
547 ): string;
548 generateKeys(format?: crypto$ECDH$Format): Buffer;
549 generateKeys(
550 encoding: crypto$ECDH$Encoding,
551 format?: crypto$ECDH$Format
552 ): string;
553 getPrivateKey(): Buffer;
554 getPrivateKey(encoding: crypto$ECDH$Encoding): string;
555 getPublicKey(format?: crypto$ECDH$Format): Buffer;
556 getPublicKey(
557 encoding: crypto$ECDH$Encoding,
558 format?: crypto$ECDH$Format
559 ): string;
560 setPrivateKey(private_key: Buffer | $TypedArray | DataView): void;
561 setPrivateKey(private_key: string, encoding: crypto$ECDH$Encoding): void;
562 }
563
564 declare class crypto$Decipher extends stream$Duplex {
565 final(output_encoding: 'latin1' | 'binary' | 'ascii' | 'utf8'): string;
566 final(output_encoding: void): Buffer;
567 getAuthTag(): Buffer;
568 setAAD(buffer: Buffer): void;
569 setAuthTag(buffer: Buffer): void;
570 setAutoPadding(auto_padding?: boolean): crypto$Cipher;
571 update(
572 data: string,
573 input_encoding: 'latin1' | 'binary' | 'base64' | 'hex',
574 output_encoding: 'latin1' | 'binary' | 'ascii' | 'utf8'
575 ): string;
576 update(
577 data: string,
578 input_encoding: 'latin1' | 'binary' | 'base64' | 'hex',
579 output_encoding: void
580 ): Buffer;
581 update(
582 data: Buffer,
583 input_encoding: void,
584 output_encoding: 'latin1' | 'binary' | 'ascii' | 'utf8'
585 ): string;
586 update(data: Buffer, input_encoding: void, output_encoding: void): Buffer;
587 }
588
589 declare class crypto$Hash extends stream$Duplex {
590 digest(encoding: 'hex' | 'latin1' | 'binary' | 'base64'): string;
591 digest(encoding: 'buffer'): Buffer;
592 digest(encoding: void): Buffer;
593 update(
594 data: string | Buffer,
595 input_encoding?: 'utf8' | 'ascii' | 'latin1' | 'binary'
596 ): crypto$Hash;
597 }
598
599 declare class crypto$Hmac extends stream$Duplex {
600 digest(encoding: 'hex' | 'latin1' | 'binary' | 'base64'): string;
601 digest(encoding: 'buffer'): Buffer;
602 digest(encoding: void): Buffer;
603 update(
604 data: string | Buffer,
605 input_encoding?: 'utf8' | 'ascii' | 'latin1' | 'binary'
606 ): crypto$Hmac;
607 }
608
609 type crypto$Sign$private_key =
610 | string
611 | {
612 key: string,
613 passphrase: string,
614 ...
615 };
616 declare class crypto$Sign extends stream$Writable {
617 static (algorithm: string, options?: writableStreamOptions): crypto$Sign;
618 constructor(algorithm: string, options?: writableStreamOptions): void;
619 sign(
620 private_key: crypto$Sign$private_key,
621 output_format: 'latin1' | 'binary' | 'hex' | 'base64'
622 ): string;
623 sign(private_key: crypto$Sign$private_key, output_format: void): Buffer;
624 update(
625 data: string | Buffer,
626 input_encoding?: 'utf8' | 'ascii' | 'latin1' | 'binary'
627 ): crypto$Sign;
628 }
629
630 declare class crypto$Verify extends stream$Writable {
631 static (algorithm: string, options?: writableStreamOptions): crypto$Verify;
632 constructor(algorithm: string, options?: writableStreamOptions): void;
633 update(
634 data: string | Buffer,
635 input_encoding?: 'utf8' | 'ascii' | 'latin1' | 'binary'
636 ): crypto$Verify;
637 verify(
638 object: string,
639 signature: string | Buffer | $TypedArray | DataView,
640 signature_format: 'latin1' | 'binary' | 'hex' | 'base64'
641 ): boolean;
642 verify(object: string, signature: Buffer, signature_format: void): boolean;
643 }
644
645 type crypto$key =
646 | string
647 | {
648 key: string,
649 passphrase?: string,
650 // TODO: enum type in crypto.constants
651 padding?: string,
652 ...
653 };
654
655 declare module 'crypto' {
656 declare var DEFAULT_ENCODING: string;
657
658 declare class Sign extends crypto$Sign {}
659 declare class Verify extends crypto$Verify {}
660
661 declare function createCipher(
662 algorithm: string,
663 password: string | Buffer
664 ): crypto$Cipher;
665 declare function createCipheriv(
666 algorithm: string,
667 key: string | Buffer,
668 iv: string | Buffer
669 ): crypto$Cipher;
670 declare function createCredentials(
671 details?: crypto$createCredentialsDetails
672 ): crypto$Credentials;
673 declare function createDecipher(
674 algorithm: string,
675 password: string | Buffer
676 ): crypto$Decipher;
677 declare function createDecipheriv(
678 algorithm: string,
679 key: string | Buffer,
680 iv: string | Buffer
681 ): crypto$Decipher;
682 declare function createDiffieHellman(
683 prime_length: number
684 ): crypto$DiffieHellman;
685 declare function createDiffieHellman(
686 prime: number,
687 encoding?: string
688 ): crypto$DiffieHellman;
689 declare function createECDH(curveName: string): crypto$ECDH;
690 declare function createHash(algorithm: string): crypto$Hash;
691 declare function createHmac(
692 algorithm: string,
693 key: string | Buffer
694 ): crypto$Hmac;
695 declare function createSign(algorithm: string): crypto$Sign;
696 declare function createVerify(algorithm: string): crypto$Verify;
697 declare function getCiphers(): Array<string>;
698 declare function getCurves(): Array<string>;
699 declare function getDiffieHellman(group_name: string): crypto$DiffieHellman;
700 declare function getHashes(): Array<string>;
701 declare function pbkdf2(
702 password: string | Buffer,
703 salt: string | Buffer,
704 iterations: number,
705 keylen: number,
706 digest: string,
707 callback: (err: ?Error, derivedKey: Buffer) => void
708 ): void;
709 declare function pbkdf2(
710 password: string | Buffer,
711 salt: string | Buffer,
712 iterations: number,
713 keylen: number,
714 callback: (err: ?Error, derivedKey: Buffer) => void
715 ): void;
716 declare function pbkdf2Sync(
717 password: string | Buffer,
718 salt: string | Buffer,
719 iterations: number,
720 keylen: number,
721 digest?: string
722 ): Buffer;
723 declare function scrypt(
724 password: string | Buffer,
725 salt: string | Buffer,
726 keylen: number,
727 options:
728 | {|N?: number, r?: number, p?: number, maxmem?: number|}
729 | {|
730 cost?: number,
731 blockSize?: number,
732 parallelization?: number,
733 maxmem?: number,
734 |},
735 callback: (err: ?Error, derivedKey: Buffer) => void
736 ): void;
737 declare function scrypt(
738 password: string | Buffer,
739 salt: string | Buffer,
740 keylen: number,
741 callback: (err: ?Error, derivedKey: Buffer) => void
742 ): void;
743 declare function scryptSync(
744 password: string | Buffer,
745 salt: string | Buffer,
746 keylen: number,
747 options?:
748 | {|N?: number, r?: number, p?: number, maxmem?: number|}
749 | {|
750 cost?: number,
751 blockSize?: number,
752 parallelization?: number,
753 maxmem?: number,
754 |}
755 ): Buffer;
756 declare function privateDecrypt(
757 private_key: crypto$key,
758 buffer: Buffer
759 ): Buffer;
760 declare function privateEncrypt(
761 private_key: crypto$key,
762 buffer: Buffer
763 ): Buffer;
764 declare function publicDecrypt(key: crypto$key, buffer: Buffer): Buffer;
765 declare function publicEncrypt(key: crypto$key, buffer: Buffer): Buffer;
766 // `UNUSED` argument strictly enforces arity to enable overloading this
767 // function with 1-arg and 2-arg variants.
768 declare function pseudoRandomBytes(size: number, UNUSED: void): Buffer;
769 declare function pseudoRandomBytes(
770 size: number,
771 callback: (err: ?Error, buffer: Buffer) => void
772 ): void;
773 // `UNUSED` argument strictly enforces arity to enable overloading this
774 // function with 1-arg and 2-arg variants.
775 declare function randomBytes(size: number, UNUSED: void): Buffer;
776 declare function randomBytes(
777 size: number,
778 callback: (err: ?Error, buffer: Buffer) => void
779 ): void;
780 declare function randomFillSync(
781 buffer: Buffer | $TypedArray | DataView
782 ): void;
783 declare function randomFillSync(
784 buffer: Buffer | $TypedArray | DataView,
785 offset: number
786 ): void;
787 declare function randomFillSync(
788 buffer: Buffer | $TypedArray | DataView,
789 offset: number,
790 size: number
791 ): void;
792 declare function randomFill(
793 buffer: Buffer | $TypedArray | DataView,
794 callback: (err: ?Error, buffer: Buffer) => void
795 ): void;
796 declare function randomFill(
797 buffer: Buffer | $TypedArray | DataView,
798 offset: number,
799 callback: (err: ?Error, buffer: Buffer) => void
800 ): void;
801 declare function randomFill(
802 buffer: Buffer | $TypedArray | DataView,
803 offset: number,
804 size: number,
805 callback: (err: ?Error, buffer: Buffer) => void
806 ): void;
807 declare function randomUUID(
808 options?: $ReadOnly<{|disableEntropyCache?: boolean|}>
809 ): string;
810 declare function timingSafeEqual(
811 a: Buffer | $TypedArray | DataView,
812 b: Buffer | $TypedArray | DataView
813 ): boolean;
814 }
815
816 type net$Socket$address = {
817 address: string,
818 family: string,
819 port: number,
820 ...
821 };
822 type dgram$Socket$rinfo = {
823 address: string,
824 family: 'IPv4' | 'IPv6',
825 port: number,
826 size: number,
827 ...
828 };
829
830 declare class dgram$Socket extends events$EventEmitter {
831 addMembership(multicastAddress: string, multicastInterface?: string): void;
832 address(): net$Socket$address;
833 bind(port?: number, address?: string, callback?: () => void): void;
834 close(callback?: () => void): void;
835 dropMembership(multicastAddress: string, multicastInterface?: string): void;
836 ref(): void;
837 send(
838 msg: Buffer,
839 port: number,
840 address: string,
841 callback?: (err: ?Error, bytes: any) => mixed
842 ): void;
843 send(
844 msg: Buffer,
845 offset: number,
846 length: number,
847 port: number,
848 address: string,
849 callback?: (err: ?Error, bytes: any) => mixed
850 ): void;
851 setBroadcast(flag: boolean): void;
852 setMulticastLoopback(flag: boolean): void;
853 setMulticastTTL(ttl: number): void;
854 setTTL(ttl: number): void;
855 unref(): void;
856 }
857
858 declare module 'dgram' {
859 declare function createSocket(
860 options: string | {type: string, ...},
861 callback?: () => void
862 ): dgram$Socket;
863 }
864
865 declare module 'dns' {
866 declare var ADDRGETNETWORKPARAMS: string;
867 declare var BADFAMILY: string;
868 declare var BADFLAGS: string;
869 declare var BADHINTS: string;
870 declare var BADQUERY: string;
871 declare var BADNAME: string;
872 declare var BADRESP: string;
873 declare var BADSTR: string;
874 declare var CANCELLED: string;
875 declare var CONNREFUSED: string;
876 declare var DESTRUCTION: string;
877 declare var EOF: string;
878 declare var FILE: string;
879 declare var FORMER: string;
880 declare var LOADIPHLPAPI: string;
881 declare var NODATA: string;
882 declare var NOMEM: string;
883 declare var NONAME: string;
884 declare var NOTFOUND: string;
885 declare var NOTIMP: string;
886 declare var NOTINITIALIZED: string;
887 declare var REFUSED: string;
888 declare var SERVFAIL: string;
889 declare var TIMEOUT: string;
890 declare var ADDRCONFIG: number;
891 declare var V4MAPPED: number;
892
893 declare type LookupOptions = {
894 family?: number,
895 hints?: number,
896 verbatim?: boolean,
897 all?: boolean,
898 ...
899 };
900
901 declare function lookup(
902 domain: string,
903 options: number | LookupOptions,
904 callback: (err: ?Error, address: string, family: number) => void
905 ): void;
906 declare function lookup(
907 domain: string,
908 callback: (err: ?Error, address: string, family: number) => void
909 ): void;
910
911 declare function resolve(
912 domain: string,
913 rrtype?: string,
914 callback?: (err: ?Error, addresses: Array<any>) => void
915 ): void;
916
917 declare function resolve4(
918 domain: string,
919 callback: (err: ?Error, addresses: Array<any>) => void
920 ): void;
921
922 declare function resolve6(
923 domain: string,
924 callback: (err: ?Error, addresses: Array<any>) => void
925 ): void;
926
927 declare function resolveCname(
928 domain: string,
929 callback: (err: ?Error, addresses: Array<any>) => void
930 ): void;
931
932 declare function resolveMx(
933 domain: string,
934 callback: (err: ?Error, addresses: Array<any>) => void
935 ): void;
936
937 declare function resolveNs(
938 domain: string,
939 callback: (err: ?Error, addresses: Array<any>) => void
940 ): void;
941
942 declare function resolveSrv(
943 domain: string,
944 callback: (err: ?Error, addresses: Array<any>) => void
945 ): void;
946
947 declare function resolveTxt(
948 domain: string,
949 callback: (err: ?Error, addresses: Array<any>) => void
950 ): void;
951
952 declare function reverse(
953 ip: string,
954 callback: (err: ?Error, domains: Array<any>) => void
955 ): void;
956 declare function timingSafeEqual(
957 a: Buffer | $TypedArray | DataView,
958 b: Buffer | $TypedArray | DataView
959 ): boolean;
960 }
961
962 declare class events$EventEmitter {
963 // deprecated
964 static listenerCount(emitter: events$EventEmitter, event: string): number;
965 static defaultMaxListeners: number;
966
967 addListener(event: string, listener: Function): this;
968 emit(event: string, ...args: Array<any>): boolean;
969 eventNames(): Array<string>;
970 listeners(event: string): Array<Function>;
971 listenerCount(event: string): number;
972 on(event: string, listener: Function): this;
973 once(event: string, listener: Function): this;
974 prependListener(event: string, listener: Function): this;
975 prependOnceListener(event: string, listener: Function): this;
976 removeAllListeners(event?: string): this;
977 removeListener(event: string, listener: Function): this;
978 off(event: string, listener: Function): this;
979 setMaxListeners(n: number): this;
980 getMaxListeners(): number;
981 rawListeners(event: string): Array<Function>;
982 }
983
984 declare module 'events' {
985 // TODO: See the comment above the events$EventEmitter declaration
986 declare class EventEmitter extends events$EventEmitter {
987 static EventEmitter: typeof EventEmitter;
988 }
989
990 declare module.exports: typeof EventEmitter;
991 }
992
993 declare class domain$Domain extends events$EventEmitter {
994 members: Array<any>;
995
996 add(emitter: events$EventEmitter): void;
997 bind(callback: Function): Function;
998 dispose(): void;
999 enter(): void;
1000 exit(): void;
1001 intercept(callback: Function): Function;
1002 remove(emitter: events$EventEmitter): void;
1003 run(fn: Function): void;
1004 }
1005
1006 declare module 'domain' {
1007 declare function create(): domain$Domain;
1008 }
1009
1010 declare module 'fs' {
1011 declare class Stats {
1012 dev: number;
1013 ino: number;
1014 mode: number;
1015 nlink: number;
1016 uid: number;
1017 gid: number;
1018 rdev: number;
1019 size: number;
1020 blksize: number;
1021 blocks: number;
1022 atimeMs: number;
1023 mtimeMs: number;
1024 ctimeMs: number;
1025 birthtimeMs: number;
1026 atime: Date;
1027 mtime: Date;
1028 ctime: Date;
1029 birthtime: Date;
1030
1031 isFile(): boolean;
1032 isDirectory(): boolean;
1033 isBlockDevice(): boolean;
1034 isCharacterDevice(): boolean;
1035 isSymbolicLink(): boolean;
1036 isFIFO(): boolean;
1037 isSocket(): boolean;
1038 }
1039
1040 declare type PathLike = string | Buffer | URL;
1041
1042 declare class FSWatcher extends events$EventEmitter {
1043 close(): void;
1044 }
1045
1046 declare class ReadStream extends stream$Readable {
1047 close(): void;
1048 }
1049
1050 declare class WriteStream extends stream$Writable {
1051 close(): void;
1052 bytesWritten: number;
1053 }
1054
1055 declare class Dirent {
1056 name: string | Buffer;
1057
1058 isBlockDevice(): boolean;
1059 isCharacterDevice(): boolean;
1060 isDirectory(): boolean;
1061 isFIFO(): boolean;
1062 isFile(): boolean;
1063 isSocket(): boolean;
1064 isSymbolicLink(): boolean;
1065 }
1066
1067 declare function rename(
1068 oldPath: string,
1069 newPath: string,
1070 callback?: (err: ?ErrnoError) => void
1071 ): void;
1072 declare function renameSync(oldPath: string, newPath: string): void;
1073 declare function ftruncate(
1074 fd: number,
1075 len: number,
1076 callback?: (err: ?ErrnoError) => void
1077 ): void;
1078 declare function ftruncateSync(fd: number, len: number): void;
1079 declare function truncate(
1080 path: string,
1081 len: number,
1082 callback?: (err: ?ErrnoError) => void
1083 ): void;
1084 declare function truncateSync(path: string, len: number): void;
1085 declare function chown(
1086 path: string,
1087 uid: number,
1088 gid: number,
1089 callback?: (err: ?ErrnoError) => void
1090 ): void;
1091 declare function chownSync(path: string, uid: number, gid: number): void;
1092 declare function fchown(
1093 fd: number,
1094 uid: number,
1095 gid: number,
1096 callback?: (err: ?ErrnoError) => void
1097 ): void;
1098 declare function fchownSync(fd: number, uid: number, gid: number): void;
1099 declare function lchown(
1100 path: string,
1101 uid: number,
1102 gid: number,
1103 callback?: (err: ?ErrnoError) => void
1104 ): void;
1105 declare function lchownSync(path: string, uid: number, gid: number): void;
1106 declare function chmod(
1107 path: string,
1108 mode: number | string,
1109 callback?: (err: ?ErrnoError) => void
1110 ): void;
1111 declare function chmodSync(path: string, mode: number | string): void;
1112 declare function fchmod(
1113 fd: number,
1114 mode: number | string,
1115 callback?: (err: ?ErrnoError) => void
1116 ): void;
1117 declare function fchmodSync(fd: number, mode: number | string): void;
1118 declare function lchmod(
1119 path: string,
1120 mode: number | string,
1121 callback?: (err: ?ErrnoError) => void
1122 ): void;
1123 declare function lchmodSync(path: string, mode: number | string): void;
1124 declare function stat(
1125 path: string,
1126 callback?: (err: ?ErrnoError, stats: Stats) => any
1127 ): void;
1128 declare function statSync(path: string): Stats;
1129 declare function fstat(
1130 fd: number,
1131 callback?: (err: ?ErrnoError, stats: Stats) => any
1132 ): void;
1133 declare function fstatSync(fd: number): Stats;
1134 declare function lstat(
1135 path: string,
1136 callback?: (err: ?ErrnoError, stats: Stats) => any
1137 ): void;
1138 declare function lstatSync(path: string): Stats;
1139 declare function link(
1140 srcpath: string,
1141 dstpath: string,
1142 callback?: (err: ?ErrnoError) => void
1143 ): void;
1144 declare function linkSync(srcpath: string, dstpath: string): void;
1145 declare function symlink(
1146 srcpath: string,
1147 dtspath: string,
1148 type?: string,
1149 callback?: (err: ?ErrnoError) => void
1150 ): void;
1151 declare function symlinkSync(
1152 srcpath: string,
1153 dstpath: string,
1154 type?: string
1155 ): void;
1156 declare function readlink(
1157 path: string,
1158 callback: (err: ?ErrnoError, linkString: string) => void
1159 ): void;
1160 declare function readlinkSync(path: string): string;
1161 declare function realpath(
1162 path: string,
1163 cache?: Object,
1164 callback?: (err: ?ErrnoError, resolvedPath: string) => void
1165 ): void;
1166 declare function realpathSync(path: string, cache?: Object): string;
1167 declare function unlink(
1168 path: string,
1169 callback?: (err: ?ErrnoError) => void
1170 ): void;
1171 declare function unlinkSync(path: string): void;
1172
1173 declare type RmDirOptions = {|
1174 /**
1175 * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
1176 * `EPERM` error is encountered, Node.js will retry the operation with a linear
1177 * backoff wait of `retryDelay` ms longer on each try. This option represents the
1178 * number of retries. This option is ignored if the `recursive` option is not
1179 * `true`.
1180 * @default 0
1181 */
1182 maxRetries?: number | void,
1183 /**
1184 * @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning
1185 * `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file.
1186 * Use `fs.rm(path, { recursive: true, force: true })` instead.
1187 *
1188 * If `true`, perform a recursive directory removal. In
1189 * recursive mode soperations are retried on failure.
1190 * @default false
1191 */
1192 recursive?: boolean | void,
1193 /**
1194 * The amount of time in milliseconds to wait between retries.
1195 * This option is ignored if the `recursive` option is not `true`.
1196 * @default 100
1197 */
1198 retryDelay?: number | void,
1199 |};
1200
1201 declare function rmdir(
1202 path: PathLike,
1203 callback?: (err: ?ErrnoError) => void
1204 ): void;
1205 declare function rmdir(
1206 path: PathLike,
1207 options: RmDirOptions,
1208 callback?: (err: ?ErrnoError) => void
1209 ): void;
1210 declare function rmdirSync(path: PathLike, options?: RmDirOptions): void;
1211
1212 declare type RmOptions = {|
1213 /**
1214 * When `true`, exceptions will be ignored if `path` does not exist.
1215 * @default false
1216 */
1217 force?: boolean | void,
1218 /**
1219 * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
1220 * `EPERM` error is encountered, Node.js will retry the operation with a linear
1221 * backoff wait of `retryDelay` ms longer on each try. This option represents the
1222 * number of retries. This option is ignored if the `recursive` option is not
1223 * `true`.
1224 * @default 0
1225 */
1226 maxRetries?: number | void,
1227 /**
1228 * If `true`, perform a recursive directory removal. In
1229 * recursive mode, operations are retried on failure.
1230 * @default false
1231 */
1232 recursive?: boolean | void,
1233 /**
1234 * The amount of time in milliseconds to wait between retries.
1235 * This option is ignored if the `recursive` option is not `true`.
1236 * @default 100
1237 */
1238 retryDelay?: number | void,
1239 |};
1240
1241 /**
1242 * Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the
1243 * completion callback.
1244 * @since v14.14.0
1245 */
1246 declare function rm(
1247 path: PathLike,
1248 callback?: (err: ?ErrnoError) => void
1249 ): void;
1250 declare function rm(
1251 path: PathLike,
1252 options: RmOptions,
1253 callback?: (err: ?ErrnoError) => void
1254 ): void;
1255
1256 /**
1257 * Synchronously removes files and directories (modeled on the standard POSIX `rm`utility). Returns `undefined`.
1258 * @since v14.14.0
1259 */
1260 declare function rmSync(path: PathLike, options?: RmOptions): void;
1261
1262 declare function mkdir(
1263 path: string,
1264 mode?:
1265 | number
1266 | {
1267 recursive?: boolean,
1268 mode?: number,
1269 ...
1270 },
1271 callback?: (err: ?ErrnoError) => void
1272 ): void;
1273 declare function mkdirSync(
1274 path: string,
1275 mode?:
1276 | number
1277 | {
1278 recursive?: boolean,
1279 mode?: number,
1280 ...
1281 }
1282 ): void;
1283 declare function mkdtemp(
1284 prefix: string,
1285 callback: (err: ?ErrnoError, folderPath: string) => void
1286 ): void;
1287 declare function mkdtempSync(prefix: string): string;
1288 declare function readdir(
1289 path: string,
1290 options: string | {encoding?: string, withFileTypes?: false, ...},
1291 callback: (err: ?ErrnoError, files: Array<string>) => void
1292 ): void;
1293 declare function readdir(
1294 path: string,
1295 options: {encoding?: string, withFileTypes: true, ...},
1296 callback: (err: ?ErrnoError, files: Array<Dirent>) => void
1297 ): void;
1298 declare function readdir(
1299 path: string,
1300 callback: (err: ?ErrnoError, files: Array<string>) => void
1301 ): void;
1302 declare function readdirSync(
1303 path: string,
1304 options?: string | {encoding?: string, withFileTypes?: false, ...}
1305 ): Array<string>;
1306 declare function readdirSync(
1307 path: string,
1308 options?: string | {encoding?: string, withFileTypes: true, ...}
1309 ): Array<Dirent>;
1310 declare function close(
1311 fd: number,
1312 callback: (err: ?ErrnoError) => void
1313 ): void;
1314 declare function closeSync(fd: number): void;
1315 declare function open(
1316 path: string | Buffer | URL,
1317 flags: string | number,
1318 mode: number,
1319 callback: (err: ?ErrnoError, fd: number) => void
1320 ): void;
1321 declare function open(
1322 path: string | Buffer | URL,
1323 flags: string | number,
1324 callback: (err: ?ErrnoError, fd: number) => void
1325 ): void;
1326 declare function openSync(
1327 path: string | Buffer,
1328 flags: string | number,
1329 mode?: number
1330 ): number;
1331 declare function utimes(
1332 path: string,
1333 atime: number,
1334 mtime: number,
1335 callback?: (err: ?ErrnoError) => void
1336 ): void;
1337 declare function utimesSync(path: string, atime: number, mtime: number): void;
1338 declare function futimes(
1339 fd: number,
1340 atime: number,
1341 mtime: number,
1342 callback?: (err: ?ErrnoError) => void
1343 ): void;
1344 declare function futimesSync(fd: number, atime: number, mtime: number): void;
1345 declare function fsync(
1346 fd: number,
1347 callback?: (err: ?ErrnoError) => void
1348 ): void;
1349 declare function fsyncSync(fd: number): void;
1350 declare function write(
1351 fd: number,
1352 buffer: Buffer,
1353 offset: number,
1354 length: number,
1355 position: number,
1356 callback: (err: ?ErrnoError, write: number, buf: Buffer) => void
1357 ): void;
1358 declare function write(
1359 fd: number,
1360 buffer: Buffer,
1361 offset: number,
1362 length: number,
1363 callback: (err: ?ErrnoError, write: number, buf: Buffer) => void
1364 ): void;
1365 declare function write(
1366 fd: number,
1367 buffer: Buffer,
1368 offset: number,
1369 callback: (err: ?ErrnoError, write: number, buf: Buffer) => void
1370 ): void;
1371 declare function write(
1372 fd: number,
1373 buffer: Buffer,
1374 callback: (err: ?ErrnoError, write: number, buf: Buffer) => void
1375 ): void;
1376 declare function write(
1377 fd: number,
1378 data: string,
1379 position: number,
1380 encoding: string,
1381 callback: (err: ?ErrnoError, write: number, str: string) => void
1382 ): void;
1383 declare function write(
1384 fd: number,
1385 data: string,
1386 position: number,
1387 callback: (err: ?ErrnoError, write: number, str: string) => void
1388 ): void;
1389 declare function write(
1390 fd: number,
1391 data: string,
1392 callback: (err: ?ErrnoError, write: number, str: string) => void
1393 ): void;
1394 declare function writeSync(
1395 fd: number,
1396 buffer: Buffer,
1397 offset: number,
1398 length: number,
1399 position: number
1400 ): number;
1401 declare function writeSync(
1402 fd: number,
1403 buffer: Buffer,
1404 offset: number,
1405 length: number
1406 ): number;
1407 declare function writeSync(
1408 fd: number,
1409 buffer: Buffer,
1410 offset?: number
1411 ): number;
1412 declare function writeSync(
1413 fd: number,
1414 str: string,
1415 position: number,
1416 encoding: string
1417 ): number;
1418 declare function writeSync(
1419 fd: number,
1420 str: string,
1421 position?: number
1422 ): number;
1423 declare function read(
1424 fd: number,
1425 buffer: Buffer,
1426 offset: number,
1427 length: number,
1428 position: ?number,
1429 callback: (err: ?ErrnoError, bytesRead: number, buffer: Buffer) => void
1430 ): void;
1431 declare function readSync(
1432 fd: number,
1433 buffer: Buffer,
1434 offset: number,
1435 length: number,
1436 position: number
1437 ): number;
1438 declare function readFile(
1439 path: string | Buffer | URL | number,
1440 callback: (err: ?ErrnoError, data: Buffer) => void
1441 ): void;
1442 declare function readFile(
1443 path: string | Buffer | URL | number,
1444 encoding: string,
1445 callback: (err: ?ErrnoError, data: string) => void
1446 ): void;
1447 declare function readFile(
1448 path: string | Buffer | URL | number,
1449 options: {
1450 encoding: string,
1451 flag?: string,
1452 ...
1453 },
1454 callback: (err: ?ErrnoError, data: string) => void
1455 ): void;
1456 declare function readFile(
1457 path: string | Buffer | URL | number,
1458 options: {encoding?: null | void, flag?: string, ...},
1459 callback: (err: ?ErrnoError, data: Buffer) => void
1460 ): void;
1461 declare function readFileSync(path: string | Buffer | URL | number): Buffer;
1462 declare function readFileSync(
1463 path: string | Buffer | URL | number,
1464 encoding: string
1465 ): string;
1466 declare function readFileSync(
1467 path: string | Buffer | URL | number,
1468 options: {
1469 encoding: string,
1470 flag?: string,
1471 ...
1472 }
1473 ): string;
1474 declare function readFileSync(
1475 path: string | Buffer | URL | number,
1476 options: {
1477 encoding?: void,
1478 flag?: string,
1479 ...
1480 }
1481 ): Buffer;
1482 declare function writeFile(
1483 filename: string | Buffer | number,
1484 data: Buffer | string,
1485 options:
1486 | string
1487 | {
1488 encoding?: ?string,
1489 mode?: number,
1490 flag?: string,
1491 ...
1492 },
1493 callback: (err: ?ErrnoError) => void
1494 ): void;
1495 declare function writeFile(
1496 filename: string | Buffer | number,
1497 data: Buffer | string,
1498 callback?: (err: ?ErrnoError) => void
1499 ): void;
1500 declare function writeFileSync(
1501 filename: string,
1502 data: Buffer | string,
1503 options?:
1504 | string
1505 | {
1506 encoding?: ?string,
1507 mode?: number,
1508 flag?: string,
1509 ...
1510 }
1511 ): void;
1512 declare function appendFile(
1513 filename: string | Buffer | number,
1514 data: string | Buffer,
1515 options:
1516 | string
1517 | {
1518 encoding?: ?string,
1519 mode?: number,
1520 flag?: string,
1521 ...
1522 },
1523 callback: (err: ?ErrnoError) => void
1524 ): void;
1525 declare function appendFile(
1526 filename: string | Buffer | number,
1527 data: string | Buffer,
1528 callback: (err: ?ErrnoError) => void
1529 ): void;
1530 declare function appendFileSync(
1531 filename: string | Buffer | number,
1532 data: string | Buffer,
1533 options?:
1534 | string
1535 | {
1536 encoding?: ?string,
1537 mode?: number,
1538 flag?: string,
1539 ...
1540 }
1541 ): void;
1542 declare function watchFile(
1543 filename: string,
1544 options?: Object,
1545 listener?: (curr: Stats, prev: Stats) => void
1546 ): void;
1547 declare function unwatchFile(
1548 filename: string,
1549 listener?: (curr: Stats, prev: Stats) => void
1550 ): void;
1551 declare function watch(
1552 filename: string,
1553 options?: Object,
1554 listener?: (event: string, filename: string) => void
1555 ): FSWatcher;
1556 declare function exists(
1557 path: string,
1558 callback?: (exists: boolean) => void
1559 ): void;
1560 declare function existsSync(path: string): boolean;
1561 declare function access(
1562 path: string,
1563 mode?: number,
1564 callback?: (err: ?ErrnoError) => void
1565 ): void;
1566 declare function accessSync(path: string, mode?: number): void;
1567 declare function createReadStream(path: string, options?: Object): ReadStream;
1568 declare function createWriteStream(
1569 path: string,
1570 options?: Object
1571 ): WriteStream;
1572 declare function fdatasync(
1573 fd: number,
1574 callback: (err: ?ErrnoError) => void
1575 ): void;
1576 declare function fdatasyncSync(fd: number): void;
1577 declare function copyFile(
1578 src: string,
1579 dest: string,
1580 callback: (err: ErrnoError) => void
1581 ): void;
1582 declare function copyFile(
1583 src: string,
1584 dest: string,
1585 flags?: number,
1586 callback: (err: ErrnoError) => void
1587 ): void;
1588 declare function copyFileSync(
1589 src: string,
1590 dest: string,
1591 flags?: number
1592 ): void;
1593
1594 declare type GlobOptions<WithFileTypes: boolean> = $ReadOnly<{
1595 /**
1596 * Current working directory.
1597 * @default process.cwd()
1598 */
1599 cwd?: string | void,
1600 /**
1601 * `true` if the glob should return paths as `Dirent`s, `false` otherwise.
1602 * @default false
1603 * @since v22.2.0
1604 */
1605 withFileTypes?: WithFileTypes,
1606 /**
1607 * Function to filter out files/directories or a
1608 * list of glob patterns to be excluded. If a function is provided, return
1609 * `true` to exclude the item, `false` to include it.
1610 * @default undefined
1611 */
1612 exclude?:
1613 | ((fileName: Node$Conditional<WithFileTypes, Dirent, string>) => boolean)
1614 | $ReadOnlyArray<string>,
1615 ...
1616 }>;
1617
1618 /**
1619 * Retrieves the files matching the specified pattern.
1620 *
1621 * ```js
1622 * import { glob } from 'node:fs';
1623 *
1624 * glob('*.js', (err, matches) => {
1625 * if (err) throw err;
1626 * console.log(matches);
1627 * });
1628 * ```
1629 * @since v22.0.0
1630 */
1631 declare function glob(
1632 pattern: string | $ReadOnlyArray<string>,
1633 callback: (err: ?ErrnoError, matches: Array<string>) => void
1634 ): void;
1635
1636 declare function glob<WithFileTypes: boolean = false>(
1637 pattern: string | $ReadOnlyArray<string>,
1638 options: GlobOptions<WithFileTypes>,
1639 callback: (
1640 err: ?ErrnoError,
1641 matches: Node$Conditional<WithFileTypes, Array<Dirent>, Array<string>>
1642 ) => void
1643 ): void;
1644
1645 /**
1646 * ```js
1647 * import { globSync } from 'node:fs';
1648 *
1649 * console.log(globSync('*.js'));
1650 * ```
1651 * @since v22.0.0
1652 * @returns paths of files that match the pattern.
1653 */
1654 declare function globSync<WithFileTypes: boolean = false>(
1655 pattern: string | $ReadOnlyArray<string>,
1656 options?: GlobOptions<WithFileTypes>
1657 ): Node$Conditional<WithFileTypes, Array<Dirent>, Array<string>>;
1658
1659 declare var F_OK: number;
1660 declare var R_OK: number;
1661 declare var W_OK: number;
1662 declare var X_OK: number;
1663 // new var from node 6.x
1664 // https://nodejs.org/dist/latest-v6.x/docs/api/fs.html#fs_fs_constants_1
1665 declare var constants: {
1666 F_OK: number, // 0
1667 R_OK: number, // 4
1668 W_OK: number, // 2
1669 X_OK: number, // 1
1670 COPYFILE_EXCL: number, // 1
1671 COPYFILE_FICLONE: number, // 2
1672 COPYFILE_FICLONE_FORCE: number, // 4
1673 O_RDONLY: number, // 0
1674 O_WRONLY: number, // 1
1675 O_RDWR: number, // 2
1676 S_IFMT: number, // 61440
1677 S_IFREG: number, // 32768
1678 S_IFDIR: number, // 16384
1679 S_IFCHR: number, // 8192
1680 S_IFBLK: number, // 24576
1681 S_IFIFO: number, // 4096
1682 S_IFLNK: number, // 40960
1683 S_IFSOCK: number, // 49152
1684 O_CREAT: number, // 64
1685 O_EXCL: number, // 128
1686 O_NOCTTY: number, // 256
1687 O_TRUNC: number, // 512
1688 O_APPEND: number, // 1024
1689 O_DIRECTORY: number, // 65536
1690 O_NOATIME: number, // 262144
1691 O_NOFOLLOW: number, // 131072
1692 O_SYNC: number, // 1052672
1693 O_DSYNC: number, // 4096
1694 O_SYMLINK: number, // 2097152
1695 O_DIRECT: number, // 16384
1696 O_NONBLOCK: number, // 2048
1697 S_IRWXU: number, // 448
1698 S_IRUSR: number, // 256
1699 S_IWUSR: number, // 128
1700 S_IXUSR: number, // 64
1701 S_IRWXG: number, // 56
1702 S_IRGRP: number, // 32
1703 S_IWGRP: number, // 16
1704 S_IXGRP: number, // 8
1705 S_IRWXO: number, // 7
1706 S_IROTH: number, // 4
1707 S_IWOTH: number, // 2
1708 S_IXOTH: number, // 1
1709 ...
1710 };
1711
1712 declare type BufferEncoding = 'buffer' | {encoding: 'buffer', ...};
1713 declare type EncodingOptions = {encoding?: string, ...};
1714 declare type EncodingFlag = EncodingOptions & {flag?: string, ...};
1715 declare type WriteOptions = EncodingFlag & {mode?: number, ...};
1716 declare type RemoveOptions = {
1717 force?: boolean,
1718 maxRetries?: number,
1719 recursive?: boolean,
1720 retryDelay?: number,
1721 ...
1722 };
1723 declare class FileHandle {
1724 appendFile(
1725 data: string | Buffer,
1726 options: WriteOptions | string
1727 ): Promise<void>;
1728 chmod(mode: number): Promise<void>;
1729 chown(uid: number, guid: number): Promise<void>;
1730 close(): Promise<void>;
1731 datasync(): Promise<void>;
1732 fd: number;
1733 read<T: Buffer | Uint8Array>(
1734 buffer: T,
1735 offset: number,
1736 length: number,
1737 position: number
1738 ): Promise<{
1739 bytesRead: number,
1740 buffer: T,
1741 ...
1742 }>;
1743 readFile(options: EncodingFlag): Promise<Buffer>;
1744 readFile(options: string): Promise<string>;
1745 stat(): Promise<Stats>;
1746 sync(): Promise<void>;
1747 truncate(len?: number): Promise<void>;
1748 utimes(
1749 atime: number | string | Date,
1750 mtime: number | string | Date
1751 ): Promise<void>;
1752 write(
1753 buffer: Buffer | Uint8Array,
1754 offset: number,
1755 length: number,
1756 position: number
1757 ): Promise<void>;
1758 writeFile(
1759 data: string | Buffer | Uint8Array,
1760 options: WriteOptions | string
1761 ): Promise<void>;
1762 }
1763
1764 declare type FSPromisePath = string | Buffer | URL;
1765 declare type FSPromise = {
1766 access(path: FSPromisePath, mode?: number): Promise<void>,
1767 appendFile(
1768 path: FSPromisePath | FileHandle,
1769 data: string | Buffer,
1770 options?: WriteOptions | string
1771 ): Promise<void>,
1772 chmod(path: FSPromisePath, mode: number): Promise<void>,
1773 chown(path: FSPromisePath, uid: number, gid: number): Promise<void>,
1774 copyFile(
1775 src: FSPromisePath,
1776 dest: FSPromisePath,
1777 flags?: number
1778 ): Promise<void>,
1779 fchmod(filehandle: FileHandle, mode: number): Promise<void>,
1780 fchown(filehandle: FileHandle, uid: number, guid: number): Promise<void>,
1781 fdatasync(filehandle: FileHandle): Promise<void>,
1782 fstat(filehandle: FileHandle): Promise<Stats>,
1783 fsync(filehandle: FileHandle): Promise<void>,
1784 ftruncate(filehandle: FileHandle, len?: number): Promise<void>,
1785 futimes(
1786 filehandle: FileHandle,
1787 atime: number | string | Date,
1788 mtime: number | string | Date
1789 ): Promise<void>,
1790 lchmod(path: FSPromisePath, mode: number): Promise<void>,
1791 glob<WithFileTypes: boolean = false>(
1792 pattern: string | $ReadOnlyArray<string>,
1793 options?: GlobOptions<WithFileTypes>
1794 ): Node$Conditional<
1795 WithFileTypes,
1796 AsyncIterator<Dirent>,
1797 AsyncIterator<string>,
1798 >,
1799 lchown(path: FSPromisePath, uid: number, guid: number): Promise<void>,
1800 link(existingPath: FSPromisePath, newPath: FSPromisePath): Promise<void>,
1801 lstat(path: FSPromisePath): Promise<Stats>,
1802 mkdir(
1803 path: FSPromisePath,
1804 mode?:
1805 | number
1806 | {
1807 recursive?: boolean,
1808 mode?: number,
1809 ...
1810 }
1811 ): Promise<void>,
1812 mkdtemp(prefix: string, options?: EncodingOptions): Promise<string>,
1813 open(
1814 path: FSPromisePath,
1815 flags?: string | number,
1816 mode?: number
1817 ): Promise<FileHandle>,
1818 read<T: Buffer | Uint8Array>(
1819 filehandle: FileHandle,
1820 buffer: T,
1821 offset: number,
1822 length: number,
1823 position?: number
1824 ): Promise<{
1825 bytesRead: number,
1826 buffer: T,
1827 ...
1828 }>,
1829 readdir: ((
1830 path: FSPromisePath,
1831 options: string | {encoding?: string, withFileTypes?: false, ...}
1832 ) => Promise<Array<string>>) &
1833 ((
1834 path: FSPromisePath,
1835 options: {encoding?: string, withFileTypes: true, ...}
1836 ) => Promise<Array<Dirent>>) &
1837 ((path: FSPromisePath) => Promise<Array<string>>),
1838 readFile: ((
1839 path: FSPromisePath | FileHandle,
1840 options: string
1841 ) => Promise<string>) &
1842 ((
1843 path: FSPromisePath | FileHandle,
1844 options?: EncodingFlag
1845 ) => Promise<Buffer>),
1846 readlink: ((
1847 path: FSPromisePath,
1848 options: BufferEncoding
1849 ) => Promise<Buffer>) &
1850 ((
1851 path: FSPromisePath,
1852 options?: string | EncodingOptions
1853 ) => Promise<string>),
1854 realpath: ((
1855 path: FSPromisePath,
1856 options: BufferEncoding
1857 ) => Promise<Buffer>) &
1858 ((
1859 path: FSPromisePath,
1860 options?: string | EncodingOptions
1861 ) => Promise<string>),
1862 rename(oldPath: FSPromisePath, newPath: FSPromisePath): Promise<void>,
1863 rm(path: FSPromisePath, options?: RemoveOptions): Promise<void>,
1864 rmdir(path: FSPromisePath): Promise<void>,
1865 stat(path: FSPromisePath): Promise<Stats>,
1866 symlink(
1867 target: FSPromisePath,
1868 path: FSPromisePath,
1869 type?: 'dir' | 'file' | 'junction'
1870 ): Promise<void>,
1871 truncate(path: FSPromisePath, len?: number): Promise<void>,
1872 unlink(path: FSPromisePath): Promise<void>,
1873 utimes(
1874 path: FSPromisePath,
1875 atime: number | string | Date,
1876 mtime: number | string | Date
1877 ): Promise<void>,
1878 write<T: Buffer | Uint8Array>(
1879 filehandle: FileHandle,
1880 buffer: T,
1881 offset: number,
1882 length: number,
1883 position?: number
1884 ): Promise<{
1885 bytesRead: number,
1886 buffer: T,
1887 ...
1888 }>,
1889 writeFile(
1890 FSPromisePath | FileHandle,
1891 data: string | Buffer | Uint8Array,
1892 options?: string | WriteOptions
1893 ): Promise<void>,
1894 ...
1895 };
1896
1897 declare var promises: FSPromise;
1898 }
1899
1900 type http$agentOptions = {
1901 keepAlive?: boolean,
1902 keepAliveMsecs?: number,
1903 maxSockets?: number,
1904 maxFreeSockets?: number,
1905 ...
1906 };
1907
1908 declare class http$Agent<+SocketT = net$Socket> {
1909 constructor(options: http$agentOptions): void;
1910 destroy(): void;
1911 // $FlowFixMe[incompatible-variance]
1912 freeSockets: {[name: string]: $ReadOnlyArray<SocketT>, ...};
1913 getName(options: {
1914 host: string,
1915 port: number,
1916 localAddress: string,
1917 ...
1918 }): string;
1919 maxFreeSockets: number;
1920 maxSockets: number;
1921 // $FlowFixMe[incompatible-variance]
1922 requests: {[name: string]: $ReadOnlyArray<http$ClientRequest<SocketT>>, ...};
1923 // $FlowFixMe[incompatible-variance]
1924 sockets: {[name: string]: $ReadOnlyArray<SocketT>, ...};
1925 }
1926
1927 declare class http$IncomingMessage<SocketT = net$Socket>
1928 extends stream$Readable
1929 {
1930 headers: Object;
1931 rawHeaders: Array<string>;
1932 httpVersion: string;
1933 method: string;
1934 trailers: Object;
1935 setTimeout(msecs: number, callback: Function): void;
1936 socket: SocketT;
1937 statusCode: number;
1938 statusMessage: string;
1939 url: string;
1940 aborted: boolean;
1941 complete: boolean;
1942 rawTrailers: Array<string>;
1943 }
1944
1945 declare class http$ClientRequest<+SocketT = net$Socket>
1946 extends stream$Writable
1947 {
1948 abort(): void;
1949 aborted: boolean;
1950 +connection: SocketT | null;
1951 flushHeaders(): void;
1952 getHeader(name: string): string;
1953 removeHeader(name: string): void;
1954 setHeader(name: string, value: string | Array<string>): void;
1955 setNoDelay(noDelay?: boolean): void;
1956 setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
1957 setTimeout(msecs: number, callback?: Function): void;
1958 +socket: SocketT | null;
1959 }
1960
1961 declare class http$ServerResponse extends stream$Writable {
1962 addTrailers(headers: {[key: string]: string, ...}): void;
1963 connection: net$Socket;
1964 finished: boolean;
1965 flushHeaders(): void;
1966 getHeader(name: string): string;
1967 getHeaderNames(): Array<string>;
1968 getHeaders(): {[key: string]: string | Array<string>, ...};
1969 hasHeader(name: string): boolean;
1970 headersSent: boolean;
1971 removeHeader(name: string): void;
1972 sendDate: boolean;
1973 setHeader(name: string, value: string | Array<string>): void;
1974 setTimeout(msecs: number, callback?: Function): http$ServerResponse;
1975 socket: net$Socket;
1976 statusCode: number;
1977 statusMessage: string;
1978 writeContinue(): void;
1979 writeHead(
1980 status: number,
1981 statusMessage?: string,
1982 headers?: {[key: string]: string, ...}
1983 ): void;
1984 writeHead(status: number, headers?: {[key: string]: string, ...}): void;
1985 writeProcessing(): void;
1986 }
1987
1988 declare class http$Server extends net$Server {
1989 listen(
1990 port?: number,
1991 hostname?: string,
1992 backlog?: number,
1993 callback?: Function
1994 ): this;
1995 // The following signatures are added to allow omitting intermediate arguments
1996 listen(port?: number, backlog?: number, callback?: Function): this;
1997 listen(port?: number, hostname?: string, callback?: Function): this;
1998 listen(port?: number, callback?: Function): this;
1999 listen(path: string, callback?: Function): this;
2000 listen(
2001 handle: {
2002 port?: number,
2003 host?: string,
2004 path?: string,
2005 backlog?: number,
2006 exclusive?: boolean,
2007 readableAll?: boolean,
2008 writableAll?: boolean,
2009 ipv6Only?: boolean,
2010 ...
2011 },
2012 callback?: Function
2013 ): this;
2014 listening: boolean;
2015 close(callback?: (error: ?Error) => mixed): this;
2016 closeAllConnections(): void;
2017 closeIdleConnections(): void;
2018 maxHeadersCount: number;
2019 keepAliveTimeout: number;
2020 headersTimeout: number;
2021 setTimeout(msecs: number, callback: Function): this;
2022 timeout: number;
2023 }
2024
2025 declare class https$Server extends tls$Server {
2026 listen(
2027 port?: number,
2028 hostname?: string,
2029 backlog?: number,
2030 callback?: Function
2031 ): this;
2032 // The following signatures are added to allow omitting intermediate arguments
2033 listen(port?: number, backlog?: number, callback?: Function): this;
2034 listen(port?: number, hostname?: string, callback?: Function): this;
2035 listen(port?: number, callback?: Function): this;
2036 listen(path: string, callback?: Function): this;
2037 listen(
2038 handle: {
2039 port?: number,
2040 host?: string,
2041 path?: string,
2042 backlog?: number,
2043 exclusive?: boolean,
2044 readableAll?: boolean,
2045 writableAll?: boolean,
2046 ipv6Only?: boolean,
2047 ...
2048 },
2049 callback?: Function
2050 ): this;
2051 close(callback?: (error: ?Error) => mixed): this;
2052 closeAllConnections(): void;
2053 closeIdleConnections(): void;
2054 keepAliveTimeout: number;
2055 headersTimeout: number;
2056 setTimeout(msecs: number, callback: Function): this;
2057 timeout: number;
2058 }
2059
2060 type requestOptions = {|
2061 auth?: string,
2062 defaultPort?: number,
2063 family?: number,
2064 headers?: {[key: string]: mixed, ...},
2065 host?: string,
2066 hostname?: string,
2067 localAddress?: string,
2068 method?: string,
2069 path?: string,
2070 port?: number,
2071 protocol?: string,
2072 setHost?: boolean,
2073 socketPath?: string,
2074 timeout?: number,
2075 |};
2076
2077 type http$requestOptions = {
2078 ...requestOptions,
2079 agent?: boolean | http$Agent<net$Socket>,
2080 createConnection?: (
2081 options: net$connectOptions,
2082 callback?: Function
2083 ) => net$Socket,
2084 ...
2085 };
2086
2087 declare module 'http' {
2088 declare class Server extends http$Server {}
2089 declare class Agent extends http$Agent<net$Socket> {
2090 createConnection(
2091 options: net$connectOptions,
2092 callback?: Function
2093 ): net$Socket;
2094 }
2095 declare class ClientRequest extends http$ClientRequest<net$Socket> {}
2096 declare class IncomingMessage extends http$IncomingMessage<net$Socket> {}
2097 declare class ServerResponse extends http$ServerResponse {}
2098
2099 declare function createServer(
2100 requestListener?: (
2101 request: IncomingMessage,
2102 response: ServerResponse
2103 ) => void
2104 ): Server;
2105 declare function request(
2106 options: http$requestOptions,
2107 callback?: (response: IncomingMessage) => void
2108 ): ClientRequest;
2109 declare function request(
2110 url: string,
2111 options?: http$requestOptions,
2112 callback?: (response: IncomingMessage) => void
2113 ): ClientRequest;
2114 declare function get(
2115 options: http$requestOptions,
2116 callback?: (response: IncomingMessage) => void
2117 ): ClientRequest;
2118 declare function get(
2119 url: string,
2120 options?: http$requestOptions,
2121 callback?: (response: IncomingMessage) => void
2122 ): ClientRequest;
2123
2124 declare var METHODS: Array<string>;
2125 declare var STATUS_CODES: {[key: number]: string, ...};
2126 declare var globalAgent: Agent;
2127 }
2128
2129 type https$requestOptions = {
2130 ...requestOptions,
2131 agent?: boolean | http$Agent<tls$TLSSocket>,
2132 createConnection?: (
2133 options: tls$connectOptions,
2134 callback?: Function
2135 ) => tls$TLSSocket,
2136 ...
2137 };
2138
2139 declare module 'https' {
2140 declare class Server extends https$Server {}
2141 declare class Agent extends http$Agent<tls$TLSSocket> {
2142 createConnection(
2143 port: ?number,
2144 host: ?string,
2145 options: tls$connectOptions
2146 ): tls$TLSSocket;
2147 createConnection(port: ?number, options: tls$connectOptions): tls$TLSSocket;
2148 createConnection(options: tls$connectOptions): tls$TLSSocket;
2149 }
2150
2151 declare class ClientRequest extends http$ClientRequest<tls$TLSSocket> {}
2152 declare class IncomingMessage extends http$IncomingMessage<tls$TLSSocket> {}
2153 declare class ServerResponse extends http$ServerResponse {}
2154
2155 declare function createServer(
2156 options: Object,
2157 requestListener?: (
2158 request: IncomingMessage,
2159 response: ServerResponse
2160 ) => void
2161 ): Server;
2162 declare function request(
2163 options: https$requestOptions,
2164 callback?: (response: IncomingMessage) => void
2165 ): ClientRequest;
2166 declare function request(
2167 url: string,
2168 options?: https$requestOptions,
2169 callback?: (response: IncomingMessage) => void
2170 ): ClientRequest;
2171 declare function get(
2172 options: https$requestOptions,
2173 callback?: (response: IncomingMessage) => void
2174 ): ClientRequest;
2175 declare function get(
2176 url: string,
2177 options?: https$requestOptions,
2178 callback?: (response: IncomingMessage) => void
2179 ): ClientRequest;
2180
2181 declare var globalAgent: Agent;
2182 }
2183
2184 type module$Module = {
2185 builtinModules: Array<string>,
2186 createRequire(filename: string | URL): typeof require,
2187 syncBuiltinESMExports(): void,
2188 Module: module$Module,
2189 ...
2190 };
2191
2192 declare module 'module' {
2193 declare module.exports: module$Module;
2194 }
2195
2196 declare class net$Socket extends stream$Duplex {
2197 constructor(options?: Object): void;
2198 address(): net$Socket$address;
2199 bufferSize: number;
2200 bytesRead: number;
2201 bytesWritten: number;
2202 connect(path: string, connectListener?: () => mixed): net$Socket;
2203 connect(
2204 port: number,
2205 host?: string,
2206 connectListener?: () => mixed
2207 ): net$Socket;
2208 connect(port: number, connectListener?: () => mixed): net$Socket;
2209 connect(options: Object, connectListener?: () => mixed): net$Socket;
2210 destroyed: boolean;
2211 end(
2212 chunkOrEncodingOrCallback?:
2213 | Buffer
2214 | Uint8Array
2215 | string
2216 | ((data: any) => void),
2217 encodingOrCallback?: string | ((data: any) => void),
2218 callback?: (data: any) => void
2219 ): this;
2220 localAddress: string;
2221 localPort: number;
2222 pause(): this;
2223 ref(): this;
2224 remoteAddress: string | void;
2225 remoteFamily: string;
2226 remotePort: number;
2227 resume(): this;
2228 setEncoding(encoding?: string): this;
2229 setKeepAlive(enable?: boolean, initialDelay?: number): this;
2230 setNoDelay(noDelay?: boolean): this;
2231 setTimeout(timeout: number, callback?: Function): this;
2232 unref(): this;
2233 write(
2234 chunk: Buffer | Uint8Array | string,
2235 encodingOrCallback?: string | ((data: any) => void),
2236 callback?: (data: any) => void
2237 ): boolean;
2238 }
2239
2240 declare class net$Server extends events$EventEmitter {
2241 listen(
2242 port?: number,
2243 hostname?: string,
2244 backlog?: number,
2245 callback?: Function
2246 ): net$Server;
2247 listen(path: string, callback?: Function): net$Server;
2248 listen(handle: Object, callback?: Function): net$Server;
2249 listening: boolean;
2250 close(callback?: Function): net$Server;
2251 address(): net$Socket$address;
2252 connections: number;
2253 maxConnections: number;
2254 getConnections(callback: Function): void;
2255 ref(): net$Server;
2256 unref(): net$Server;
2257 }
2258
2259 type net$connectOptions = {
2260 port?: number,
2261 host?: string,
2262 localAddress?: string,
2263 localPort?: number,
2264 family?: number,
2265 lookup?: (
2266 domain: string,
2267 options?: ?number | ?Object,
2268 callback?: (err: ?Error, address: string, family: number) => void
2269 ) => mixed,
2270 path?: string,
2271 ...
2272 };
2273
2274 declare module 'net' {
2275 declare class Server extends net$Server {}
2276 declare class Socket extends net$Socket {}
2277
2278 declare function isIP(input: string): number;
2279 declare function isIPv4(input: string): boolean;
2280 declare function isIPv6(input: string): boolean;
2281
2282 declare type connectionListener = (socket: Socket) => any;
2283 declare function createServer(
2284 options?:
2285 | {
2286 allowHalfOpen?: boolean,
2287 pauseOnConnect?: boolean,
2288 ...
2289 }
2290 | connectionListener,
2291 connectionListener?: connectionListener
2292 ): Server;
2293
2294 declare type connectListener = () => any;
2295 declare function connect(
2296 pathOrPortOrOptions: string | number | net$connectOptions,
2297 hostOrConnectListener?: string | connectListener,
2298 connectListener?: connectListener
2299 ): Socket;
2300
2301 declare function createConnection(
2302 pathOrPortOrOptions: string | number | net$connectOptions,
2303 hostOrConnectListener?: string | connectListener,
2304 connectListener?: connectListener
2305 ): Socket;
2306 }
2307
2308 type os$CPU = {
2309 model: string,
2310 speed: number,
2311 times: {
2312 idle: number,
2313 irq: number,
2314 nice: number,
2315 sys: number,
2316 user: number,
2317 ...
2318 },
2319 ...
2320 };
2321
2322 type os$NetIFAddr = {
2323 address: string,
2324 family: string,
2325 internal: boolean,
2326 mac: string,
2327 netmask: string,
2328 ...
2329 };
2330
2331 type os$UserInfo$buffer = {
2332 uid: number,
2333 gid: number,
2334 username: Buffer,
2335 homedir: Buffer,
2336 shell: ?Buffer,
2337 ...
2338 };
2339
2340 type os$UserInfo$string = {
2341 uid: number,
2342 gid: number,
2343 username: string,
2344 homedir: string,
2345 shell: ?string,
2346 ...
2347 };
2348
2349 declare module 'os' {
2350 declare function arch(): 'x64' | 'arm' | 'ia32';
2351 declare function availableParallelism(): number;
2352 declare function cpus(): Array<os$CPU>;
2353 declare function endianness(): 'BE' | 'LE';
2354 declare function freemem(): number;
2355 declare function homedir(): string;
2356 declare function hostname(): string;
2357 declare function loadavg(): [number, number, number];
2358 declare function networkInterfaces(): {
2359 [ifName: string]: Array<os$NetIFAddr>,
2360 ...
2361 };
2362 declare function platform(): string;
2363 declare function release(): string;
2364 declare function tmpdir(): string;
2365 declare function totalmem(): number;
2366 declare function type(): string;
2367 declare function uptime(): number;
2368 declare function userInfo(options: {
2369 encoding: 'buffer',
2370 ...
2371 }): os$UserInfo$buffer;
2372 declare function userInfo(options?: {
2373 encoding: 'utf8',
2374 ...
2375 }): os$UserInfo$string;
2376 declare var EOL: string;
2377 }
2378
2379 declare module 'path' {
2380 declare function normalize(path: string): string;
2381 declare function join(...parts: Array<string>): string;
2382 declare function resolve(...parts: Array<string>): string;
2383 declare function isAbsolute(path: string): boolean;
2384 declare function relative(from: string, to: string): string;
2385 declare function dirname(path: string): string;
2386 declare function basename(path: string, ext?: string): string;
2387 declare function extname(path: string): string;
2388 declare var sep: string;
2389 declare var delimiter: string;
2390 declare function parse(pathString: string): {
2391 root: string,
2392 dir: string,
2393 base: string,
2394 ext: string,
2395 name: string,
2396 ...
2397 };
2398 declare function format(pathObject: {
2399 root?: string,
2400 dir?: string,
2401 base?: string,
2402 ext?: string,
2403 name?: string,
2404 ...
2405 }): string;
2406 declare var posix: any;
2407 declare var win32: any;
2408 }
2409
2410 declare module 'punycode' {
2411 declare function decode(string: string): string;
2412 declare function encode(string: string): string;
2413 declare function toASCII(domain: string): string;
2414 declare function toUnicode(domain: string): string;
2415 declare var ucs2: {
2416 decode: (str: string) => Array<number>,
2417 encode: (codePoints: Array<number>) => string,
2418 ...
2419 };
2420 declare var version: string;
2421 }
2422
2423 declare module 'querystring' {
2424 declare function stringify(
2425 obj: Object,
2426 separator?: string,
2427 equal?: string,
2428 options?: {encodeURIComponent?: (str: string) => string, ...}
2429 ): string;
2430 declare function parse(
2431 str: string,
2432 separator: ?string,
2433 equal: ?string,
2434 options?: {
2435 decodeURIComponent?: (str: string) => string,
2436 maxKeys?: number,
2437 ...
2438 }
2439 ): any;
2440 declare function escape(str: string): string;
2441 declare function unescape(str: string, decodeSpaces?: boolean): string;
2442 }
2443
2444 type readline$InterfaceCompleter = (
2445 line: string
2446 ) =>
2447 | [Array<string>, string]
2448 | ((
2449 line: string,
2450 ((err: ?Error, data: [Array<string>, string]) => void)
2451 ) => void);
2452
2453 declare class readline$Interface extends events$EventEmitter {
2454 close(): void;
2455 pause(): void;
2456 prompt(preserveCursor?: boolean): void;
2457 question(
2458 query: string,
2459 optionsOrCallback: {|signal?: AbortSignal|} | ((answer: string) => void),
2460 callback?: (answer: string) => void
2461 ): void;
2462 resume(): void;
2463 setPrompt(prompt: string): void;
2464 write(
2465 val: string | void | null,
2466 key?: {
2467 name: string,
2468 ctrl?: boolean,
2469 shift?: boolean,
2470 meta?: boolean,
2471 ...
2472 }
2473 ): void;
2474 @@asyncIterator(): AsyncIterator<string>;
2475 }
2476
2477 declare module 'readline' {
2478 declare var Interface: typeof readline$Interface;
2479 declare function clearLine(
2480 stream: stream$Stream,
2481 dir: -1 | 1 | 0,
2482 callback?: () => void
2483 ): void;
2484 declare function clearScreenDown(
2485 stream: stream$Stream,
2486 callback?: () => void
2487 ): void;
2488 declare function createInterface(opts: {
2489 completer?: readline$InterfaceCompleter,
2490 crlfDelay?: number,
2491 escapeCodeTimeout?: number,
2492 historySize?: number,
2493 input: stream$Readable,
2494 output?: ?stream$Stream,
2495 prompt?: string,
2496 removeHistoryDuplicates?: boolean,
2497 terminal?: boolean,
2498 ...
2499 }): readline$Interface;
2500 declare function cursorTo(
2501 stream: stream$Stream,
2502 x?: number,
2503 y?: number,
2504 callback?: () => void
2505 ): void;
2506 declare function moveCursor(
2507 stream: stream$Stream,
2508 dx: number,
2509 dy: number,
2510 callback?: () => void
2511 ): void;
2512 declare function emitKeypressEvents(
2513 stream: stream$Stream,
2514 readlineInterface?: readline$Interface
2515 ): void;
2516 }
2517
2518 declare class stream$Stream extends events$EventEmitter {}
2519
2520 type readableStreamOptions = {
2521 highWaterMark?: number,
2522 encoding?: string,
2523 objectMode?: boolean,
2524 read?: (size: number) => void,
2525 destroy?: (error: ?Error, callback: (error?: Error) => void) => void,
2526 autoDestroy?: boolean,
2527 ...
2528 };
2529 declare class stream$Readable extends stream$Stream {
2530 static from(
2531 iterable: Iterable<any> | AsyncIterable<any>,
2532 options?: readableStreamOptions
2533 ): stream$Readable;
2534
2535 constructor(options?: readableStreamOptions): void;
2536 destroy(error?: Error): this;
2537 isPaused(): boolean;
2538 pause(): this;
2539 pipe<T: stream$Writable>(dest: T, options?: {end?: boolean, ...}): T;
2540 read(size?: number): ?(string | Buffer);
2541 readable: boolean;
2542 readableHighWaterMark: number;
2543 readableLength: number;
2544 resume(): this;
2545 setEncoding(encoding: string): this;
2546 unpipe(dest?: stream$Writable): this;
2547 unshift(chunk: Buffer | Uint8Array | string): void;
2548 wrap(oldReadable: stream$Stream): this;
2549 _read(size: number): void;
2550 _destroy(error: ?Error, callback: (error?: Error) => void): void;
2551 push(chunk: ?(Buffer | Uint8Array | string), encoding?: string): boolean;
2552 @@asyncIterator(): AsyncIterator<string | Buffer>;
2553 }
2554
2555 type writableStreamOptions = {
2556 highWaterMark?: number,
2557 decodeStrings?: boolean,
2558 defaultEncoding?: string,
2559 objectMode?: boolean,
2560 emitClose?: boolean,
2561 write?: (
2562 chunk: Buffer | string,
2563 encoding: string,
2564 callback: (error?: Error) => void
2565 ) => void,
2566 writev?: (
2567 chunks: Array<{
2568 chunk: Buffer | string,
2569 encoding: string,
2570 ...
2571 }>,
2572 callback: (error?: Error) => void
2573 ) => void,
2574 destroy?: (error: ?Error, callback: (error?: Error) => void) => void,
2575 final?: (callback: (error?: Error) => void) => void,
2576 autoDestroy?: boolean,
2577 ...
2578 };
2579 declare class stream$Writable extends stream$Stream {
2580 constructor(options?: writableStreamOptions): void;
2581 cork(): void;
2582 destroy(error?: Error): this;
2583 end(callback?: () => void): this;
2584 end(chunk?: string | Buffer | Uint8Array, callback?: () => void): this;
2585 end(
2586 chunk?: string | Buffer | Uint8Array,
2587 encoding?: string,
2588 callback?: () => void
2589 ): this;
2590 setDefaultEncoding(encoding: string): this;
2591 uncork(): void;
2592 writable: boolean;
2593 writableHighWaterMark: number;
2594 writableLength: number;
2595 write(
2596 chunk: string | Buffer | Uint8Array,
2597 callback?: (error?: Error) => void
2598 ): boolean;
2599 write(
2600 chunk: string | Buffer | Uint8Array,
2601 encoding?: string,
2602 callback?: (error?: Error) => void
2603 ): boolean;
2604 _write(
2605 chunk: Buffer | string,
2606 encoding: string,
2607 callback: (error?: Error) => void
2608 ): void;
2609 _writev(
2610 chunks: Array<{
2611 chunk: Buffer | string,
2612 encoding: string,
2613 ...
2614 }>,
2615 callback: (error?: Error) => void
2616 ): void;
2617 _destroy(error: ?Error, callback: (error?: Error) => void): void;
2618 _final(callback: (error?: Error) => void): void;
2619 }
2620
2621 //According to the NodeJS docs:
2622 //"Since JavaScript doesn't have multiple prototypal inheritance, this class
2623 //prototypally inherits from Readable, and then parasitically from Writable."
2624 //Source: <https://nodejs.org/api/stream.html#stream_class_stream_duplex_1
2625 type duplexStreamOptions = writableStreamOptions &
2626 readableStreamOptions & {
2627 allowHalfOpen?: boolean,
2628 readableObjectMode?: boolean,
2629 writableObjectMode?: boolean,
2630 readableHighWaterMark?: number,
2631 writableHighWaterMark?: number,
2632 ...
2633 };
2634 declare class stream$Duplex extends stream$Readable mixins stream$Writable {
2635 constructor(options?: duplexStreamOptions): void;
2636 }
2637 type transformStreamOptions = duplexStreamOptions & {
2638 flush?: (callback: (error: ?Error, data: ?(Buffer | string)) => void) => void,
2639 transform?: (
2640 chunk: Buffer | string,
2641 encoding: string,
2642 callback: (error: ?Error, data: ?(Buffer | string)) => void
2643 ) => void,
2644 ...
2645 };
2646 declare class stream$Transform extends stream$Duplex {
2647 constructor(options?: transformStreamOptions): void;
2648 _flush(callback: (error: ?Error, data: ?(Buffer | string)) => void): void;
2649 _transform(
2650 chunk: Buffer | string,
2651 encoding: string,
2652 callback: (error: ?Error, data: ?(Buffer | string)) => void
2653 ): void;
2654 }
2655 declare class stream$PassThrough extends stream$Transform {}
2656
2657 declare module 'stream' {
2658 declare var Stream: typeof stream$Stream;
2659 declare var Readable: typeof stream$Readable;
2660 declare var Writable: typeof stream$Writable;
2661 declare var Duplex: typeof stream$Duplex;
2662 declare var Transform: typeof stream$Transform;
2663 declare var PassThrough: typeof stream$PassThrough;
2664 declare function finished(
2665 stream: stream$Stream,
2666 callback: (error?: Error) => void
2667 ): () => void;
2668 declare function finished(
2669 stream: stream$Stream,
2670 options: ?{
2671 error?: boolean,
2672 readable?: boolean,
2673 writable?: boolean,
2674 ...
2675 },
2676 callback: (error?: Error) => void
2677 ): () => void;
2678 declare function pipeline<T: stream$Writable>(
2679 s1: stream$Readable,
2680 last: T,
2681 cb: (error?: Error) => void
2682 ): T;
2683 declare function pipeline<T: stream$Writable>(
2684 s1: stream$Readable,
2685 s2: stream$Duplex,
2686 last: T,
2687 cb: (error?: Error) => void
2688 ): T;
2689 declare function pipeline<T: stream$Writable>(
2690 s1: stream$Readable,
2691 s2: stream$Duplex,
2692 s3: stream$Duplex,
2693 last: T,
2694 cb: (error?: Error) => void
2695 ): T;
2696 declare function pipeline<T: stream$Writable>(
2697 s1: stream$Readable,
2698 s2: stream$Duplex,
2699 s3: stream$Duplex,
2700 s4: stream$Duplex,
2701 last: T,
2702 cb: (error?: Error) => void
2703 ): T;
2704 declare function pipeline<T: stream$Writable>(
2705 s1: stream$Readable,
2706 s2: stream$Duplex,
2707 s3: stream$Duplex,
2708 s4: stream$Duplex,
2709 s5: stream$Duplex,
2710 last: T,
2711 cb: (error?: Error) => void
2712 ): T;
2713 declare function pipeline<T: stream$Writable>(
2714 s1: stream$Readable,
2715 s2: stream$Duplex,
2716 s3: stream$Duplex,
2717 s4: stream$Duplex,
2718 s5: stream$Duplex,
2719 s6: stream$Duplex,
2720 last: T,
2721 cb: (error?: Error) => void
2722 ): T;
2723 declare function pipeline(
2724 streams: Array<stream$Stream>,
2725 cb: (error?: Error) => void
2726 ): stream$Stream;
2727
2728 declare interface StreamPipelineOptions {
2729 +signal?: AbortSignal;
2730 +end?: boolean;
2731 }
2732
2733 declare type StreamPromise = {
2734 pipeline(
2735 s1: stream$Readable,
2736 last: stream$Writable,
2737 options?: StreamPipelineOptions
2738 ): Promise<void>,
2739 pipeline(
2740 s1: stream$Readable,
2741 s2: stream$Duplex,
2742 last: stream$Writable,
2743 options?: StreamPipelineOptions
2744 ): Promise<void>,
2745 pipeline(
2746 s1: stream$Readable,
2747 s2: stream$Duplex,
2748 s3: stream$Duplex,
2749 last: stream$Writable,
2750 options?: StreamPipelineOptions
2751 ): Promise<void>,
2752 pipeline(
2753 s1: stream$Readable,
2754 s2: stream$Duplex,
2755 s3: stream$Duplex,
2756 s4: stream$Duplex,
2757 last: stream$Writable,
2758 options?: StreamPipelineOptions
2759 ): Promise<void>,
2760 pipeline(
2761 s1: stream$Readable,
2762 s2: stream$Duplex,
2763 s3: stream$Duplex,
2764 s4: stream$Duplex,
2765 s5: stream$Duplex,
2766 last: stream$Writable,
2767 options?: StreamPipelineOptions
2768 ): Promise<void>,
2769 pipeline(
2770 s1: stream$Readable,
2771 s2: stream$Duplex,
2772 s3: stream$Duplex,
2773 s4: stream$Duplex,
2774 s5: stream$Duplex,
2775 s6: stream$Duplex,
2776 last: stream$Writable,
2777 options?: StreamPipelineOptions
2778 ): Promise<void>,
2779 pipeline(
2780 streams: $ReadOnlyArray<stream$Stream>,
2781 options?: StreamPipelineOptions
2782 ): Promise<void>,
2783 ...
2784 };
2785
2786 declare var promises: StreamPromise;
2787 }
2788
2789 declare class tty$ReadStream extends net$Socket {
2790 constructor(fd: number, options?: Object): void;
2791 isRaw: boolean;
2792 setRawMode(mode: boolean): void;
2793 isTTY: true;
2794 }
2795 declare class tty$WriteStream extends net$Socket {
2796 constructor(fd: number): void;
2797 /**
2798 * Clears the current line of this `WriteStream` in a direction identified by `dir`.
2799 *
2800 * TODO: takes a callback and returns `boolean` in v12+
2801 */
2802 clearLine(dir: -1 | 0 | 1): void;
2803 columns: number;
2804 /**
2805 * Moves this WriteStream's cursor to the specified position
2806 *
2807 * TODO: takes a callback and returns `boolean` in v12+
2808 */
2809 cursorTo(x: number, y?: number): void;
2810 isTTY: true;
2811 /**
2812 * Moves this WriteStream's cursor relative to its current position
2813 *
2814 * TODO: takes a callback and returns `boolean` in v12+
2815 */
2816 moveCursor(dx: number, dy: number): void;
2817 rows: number;
2818
2819 /**
2820 * Clears this WriteStream from the current cursor down.
2821 */
2822 clearScreenDown(callback?: () => void): boolean;
2823
2824 /**
2825 * Use this to determine what colors the terminal supports. Due to the nature of colors in terminals it is possible to either have false positives or false negatives. It depends on process information and the environment variables that may lie about what terminal is used. It is possible to pass in an env object to simulate the usage of a specific terminal. This can be useful to check how specific environment settings behave.
2826 * To enforce a specific color support, use one of the below environment settings.
2827 *
2828 * 2 colors: FORCE_COLOR = 0 (Disables colors)
2829 * 16 colors: FORCE_COLOR = 1
2830 * 256 colors: FORCE_COLOR = 2
2831 * 16,777,216 colors: FORCE_COLOR = 3
2832 * Disabling color support is also possible by using the NO_COLOR and NODE_DISABLE_COLORS environment variables.
2833 */
2834 getColorDepth(env?: typeof process.env):
2835 | 1 // 2
2836 | 4 // 16
2837 | 8 // 256
2838 | 24; // 16,777,216
2839
2840 /**
2841 * Returns the size of the TTY corresponding to this WriteStream. The array is of the type [numColumns, numRows] where numColumns and numRows represent the number of columns and rows in the corresponding TTY.
2842 */
2843 getWindowSize(): [
2844 number, // columns
2845 number, // rows
2846 ];
2847
2848 /**
2849 * - count <integer> The number of colors that are requested (minimum 2). Default: 16.
2850 * - env <Object> An object containing the environment variables to check. This enables simulating the usage of a specific terminal. Default: process.env.
2851 * - Returns: <boolean>
2852 *
2853 * Returns true if the writeStream supports at least as many colors as provided in count. Minimum support is 2 (black and white).
2854 *
2855 * This has the same false positives and negatives as described in tty$WriteStream#getColorDepth().
2856 */
2857 hasColors(count?: number, env?: typeof process.env): boolean;
2858 }
2859
2860 declare module 'tty' {
2861 declare function isatty(fd: number): boolean;
2862 declare function setRawMode(mode: boolean): void;
2863 declare var ReadStream: typeof tty$ReadStream;
2864 declare var WriteStream: typeof tty$WriteStream;
2865 }
2866
2867 declare class string_decoder$StringDecoder {
2868 constructor(encoding?: 'utf8' | 'ucs2' | 'utf16le' | 'base64'): void;
2869 end(): string;
2870 write(buffer: Buffer): string;
2871 }
2872
2873 declare module 'string_decoder' {
2874 declare var StringDecoder: typeof string_decoder$StringDecoder;
2875 }
2876
2877 type tls$connectOptions = {
2878 port?: number,
2879 host?: string,
2880 socket?: net$Socket,
2881 rejectUnauthorized?: boolean,
2882 path?: string,
2883 lookup?: (
2884 domain: string,
2885 options?: ?number | ?Object,
2886 callback?: (err: ?Error, address: string, family: number) => void
2887 ) => mixed,
2888 requestOCSP?: boolean,
2889 ...
2890 };
2891
2892 type tls$Certificate$Subject = {
2893 C?: string,
2894 ST?: string,
2895 L?: string,
2896 O?: string,
2897 OU?: string,
2898 CN?: string,
2899 ...
2900 };
2901
2902 type tls$Certificate = {
2903 raw: Buffer,
2904 subject: tls$Certificate$Subject,
2905 issuer: tls$Certificate$Subject,
2906 valid_from: string,
2907 valid_to: string,
2908 serialNumber: string,
2909 fingerprint: string,
2910 fingerprint256: string,
2911 ext_key_usage?: Array<string>,
2912 subjectaltname?: string,
2913 infoAccess?: {[string]: Array<string>, ...},
2914 issuerCertificate?: tls$Certificate,
2915 ...
2916 };
2917
2918 declare class tls$TLSSocket extends net$Socket {
2919 constructor(socket: net$Socket, options?: Object): void;
2920 authorized: boolean;
2921 authorizationError: string | null;
2922 encrypted: true;
2923 getCipher(): {
2924 name: string,
2925 version: string,
2926 ...
2927 } | null;
2928 getEphemeralKeyInfo():
2929 | {
2930 type: 'DH',
2931 size: number,
2932 ...
2933 }
2934 | {
2935 type: 'EDHC',
2936 name: string,
2937 size: number,
2938 ...
2939 }
2940 | null;
2941 getPeerCertificate(detailed?: boolean): tls$Certificate | null;
2942 getSession(): ?Buffer;
2943 getTLSTicket(): Buffer | void;
2944 renegotiate(options: Object, callback: Function): boolean | void;
2945 setMaxSendFragment(size: number): boolean;
2946 }
2947
2948 declare class tls$Server extends net$Server {
2949 listen(
2950 port?: number,
2951 hostname?: string,
2952 backlog?: number,
2953 callback?: Function
2954 ): tls$Server;
2955 listen(path: string, callback?: Function): tls$Server;
2956 listen(handle: Object, callback?: Function): tls$Server;
2957 close(callback?: Function): tls$Server;
2958 addContext(hostname: string, context: Object): void;
2959 getTicketKeys(): Buffer;
2960 setTicketKeys(keys: Buffer): void;
2961 }
2962
2963 declare module 'tls' {
2964 declare var CLIENT_RENEG_LIMIT: number;
2965 declare var CLIENT_RENEG_WINDOW: number;
2966 declare var SLAB_BUFFER_SIZE: number;
2967 declare var DEFAULT_CIPHERS: string;
2968 declare var DEFAULT_ECDH_CURVE: string;
2969 declare function getCiphers(): Array<string>;
2970 declare function convertNPNProtocols(
2971 NPNProtocols: Array<string>,
2972 out: Object
2973 ): void;
2974 declare function checkServerIdentity(
2975 servername: string,
2976 cert: string
2977 ): Error | void;
2978 declare function parseCertString(s: string): Object;
2979 declare function createSecureContext(details: Object): Object;
2980 declare var SecureContext: Object;
2981 declare var TLSSocket: typeof tls$TLSSocket;
2982 declare var Server: typeof tls$Server;
2983 declare function createServer(
2984 options: Object,
2985 secureConnectionListener?: Function
2986 ): tls$Server;
2987 declare function connect(
2988 options: tls$connectOptions,
2989 callback?: Function
2990 ): tls$TLSSocket;
2991 declare function connect(
2992 port: number,
2993 host?: string,
2994 options?: tls$connectOptions,
2995 callback?: Function
2996 ): tls$TLSSocket;
2997 declare function createSecurePair(
2998 context?: Object,
2999 isServer?: boolean,
3000 requestCert?: boolean,
3001 rejectUnauthorized?: boolean,
3002 options?: Object
3003 ): Object;
3004 }
3005
3006 type url$urlObject = {
3007 +href?: string,
3008 +protocol?: string | null,
3009 +slashes?: boolean | null,
3010 +auth?: string | null,
3011 +hostname?: string | null,
3012 +port?: string | number | null,
3013 +host?: string | null,
3014 +pathname?: string | null,
3015 +search?: string | null,
3016 +query?: Object | null,
3017 +hash?: string | null,
3018 ...
3019 };
3020
3021 declare module 'url' {
3022 declare type Url = {|
3023 protocol: string | null,
3024 slashes: boolean | null,
3025 auth: string | null,
3026 host: string | null,
3027 port: string | null,
3028 hostname: string | null,
3029 hash: string | null,
3030 search: string | null,
3031 query: string | null | {[string]: string, ...},
3032 pathname: string | null,
3033 path: string | null,
3034 href: string,
3035 |};
3036
3037 declare type UrlWithStringQuery = {|
3038 ...Url,
3039 query: string | null,
3040 |};
3041
3042 declare type UrlWithParsedQuery = {|
3043 ...Url,
3044 query: {[string]: string, ...},
3045 |};
3046
3047 declare function parse(
3048 urlStr: string,
3049 parseQueryString: true,
3050 slashesDenoteHost?: boolean
3051 ): UrlWithParsedQuery;
3052 declare function parse(
3053 urlStr: string,
3054 parseQueryString?: false | void,
3055 slashesDenoteHost?: boolean
3056 ): UrlWithStringQuery;
3057 declare function parse(
3058 urlStr: string,
3059 parseQueryString?: boolean,
3060 slashesDenoteHost?: boolean
3061 ): Url;
3062 declare function format(urlObj: url$urlObject): string;
3063 declare function resolve(from: string, to: string): string;
3064 declare function domainToASCII(domain: string): string;
3065 declare function domainToUnicode(domain: string): string;
3066 declare function pathToFileURL(path: string): url$urlObject;
3067 declare function fileURLToPath(path: url$urlObject | string): string;
3068 declare class URLSearchParams {
3069 @@iterator(): Iterator<[string, string]>;
3070
3071 size: number;
3072
3073 constructor(
3074 init?:
3075 | string
3076 | URLSearchParams
3077 | Array<[string, string]>
3078 | {[string]: string, ...}
3079 ): void;
3080 append(name: string, value: string): void;
3081 delete(name: string, value?: void): void;
3082 entries(): Iterator<[string, string]>;
3083 forEach<This>(
3084 callback: (
3085 this: This,
3086 value: string,
3087 name: string,
3088 searchParams: URLSearchParams
3089 ) => mixed,
3090 thisArg?: This
3091 ): void;
3092 get(name: string): string | null;
3093 getAll(name: string): string[];
3094 has(name: string, value?: string): boolean;
3095 keys(): Iterator<string>;
3096 set(name: string, value: string): void;
3097 sort(): void;
3098 values(): Iterator<string>;
3099 toString(): string;
3100 }
3101 declare class URL {
3102 static canParse(url: string, base?: string): boolean;
3103 static createObjectURL(blob: Blob): string;
3104 static createObjectURL(mediaSource: MediaSource): string;
3105 static revokeObjectURL(url: string): void;
3106 constructor(input: string, base?: string | URL): void;
3107 hash: string;
3108 host: string;
3109 hostname: string;
3110 href: string;
3111 +origin: string;
3112 password: string;
3113 pathname: string;
3114 port: string;
3115 protocol: string;
3116 search: string;
3117 +searchParams: URLSearchParams;
3118 username: string;
3119 toString(): string;
3120 toJSON(): string;
3121 }
3122 }
3123
3124 type util$InspectOptions = {
3125 showHidden?: boolean,
3126 depth?: ?number,
3127 colors?: boolean,
3128 customInspect?: boolean,
3129 ...
3130 };
3131
3132 declare type util$ParseArgsOption =
3133 | {|
3134 type: 'boolean',
3135 multiple?: false,
3136 short?: string,
3137 default?: boolean,
3138 |}
3139 | {|
3140 type: 'boolean',
3141 multiple: true,
3142 short?: string,
3143 default?: Array<boolean>,
3144 |}
3145 | {|
3146 type: 'string',
3147 multiple?: false,
3148 short?: string,
3149 default?: string,
3150 |}
3151 | {|
3152 type: 'string',
3153 multiple: true,
3154 short?: string,
3155 default?: Array<string>,
3156 |};
3157
3158 type util$ParseArgsOptionToValue<TOption> = TOption['type'] extends 'boolean'
3159 ? TOption['multiple'] extends true
3160 ? Array<boolean>
3161 : boolean
3162 : TOption['type'] extends 'string'
3163 ? TOption['multiple'] extends true
3164 ? Array<string>
3165 : string
3166 : empty;
3167
3168 type util$ParseArgsOptionsToValues<TOptions> = {
3169 [key in keyof TOptions]: util$ParseArgsOptionToValue<{|
3170 multiple: false,
3171 ...TOptions[key],
3172 |}>,
3173 };
3174
3175 type util$ParseArgsToken =
3176 | {|
3177 kind: 'option',
3178 index: number,
3179 name: string,
3180 rawName: string,
3181 value?: string,
3182 inlineValue?: boolean,
3183 |}
3184 | {|
3185 kind: 'positional',
3186 index: number,
3187 value: string,
3188 |}
3189 | {|
3190 kind: 'option-terminator',
3191 index: number,
3192 |};
3193
3194 declare module 'util' {
3195 declare function debuglog(section: string): (data: any, ...args: any) => void;
3196 declare function format(format: string, ...placeholders: any): string;
3197 declare function log(string: string): void;
3198 declare function inspect(object: any, options?: util$InspectOptions): string;
3199 declare function isArray(object: any): boolean;
3200 declare function isRegExp(object: any): boolean;
3201 declare function isDate(object: any): boolean;
3202 declare function isError(object: any): boolean;
3203 declare function inherits(
3204 constructor: Function,
3205 superConstructor: Function
3206 ): void;
3207 declare function deprecate(f: Function, string: string): Function;
3208 declare function promisify(f: Function): Function;
3209 declare function callbackify(f: Function): Function;
3210 declare function stripVTControlCharacters(str: string): string;
3211
3212 declare function parseArgs<
3213 TOptions: {[string]: util$ParseArgsOption} = {||},
3214 >(config: {|
3215 args?: Array<string>,
3216 options?: TOptions,
3217 strict?: boolean,
3218 allowPositionals?: boolean,
3219 tokens?: false,
3220 |}): {|
3221 values: util$ParseArgsOptionsToValues<TOptions>,
3222 positionals: Array<string>,
3223 |};
3224
3225 declare function parseArgs<
3226 TOptions: {[string]: util$ParseArgsOption} = {||},
3227 >(config: {|
3228 args?: Array<string>,
3229 options?: TOptions,
3230 strict?: boolean,
3231 allowPositionals?: boolean,
3232 tokens: true,
3233 |}): {|
3234 values: util$ParseArgsOptionsToValues<TOptions>,
3235 positionals: Array<string>,
3236 tokens: Array<util$ParseArgsToken>,
3237 |};
3238
3239 declare class TextDecoder {
3240 constructor(
3241 encoding?: string,
3242 options?: {
3243 fatal?: boolean,
3244 ignoreBOM?: boolean,
3245 ...
3246 }
3247 ): void;
3248 decode(
3249 input?: ArrayBuffer | DataView | $TypedArray,
3250 options?: {stream?: boolean, ...}
3251 ): string;
3252 encoding: string;
3253 fatal: boolean;
3254 ignoreBOM: boolean;
3255 }
3256
3257 declare class TextEncoder {
3258 constructor(): void;
3259 encode(input: string): Uint8Array;
3260 encodeInto(
3261 input: string,
3262 buffer: Uint8Array
3263 ): {written: number, read: number};
3264 encoding: 'utf-8';
3265 }
3266
3267 declare var types: {
3268 isAnyArrayBuffer: (value: mixed) => boolean,
3269 isArgumentsObject: (value: mixed) => boolean,
3270 isArrayBuffer: (value: mixed) => boolean,
3271 isAsyncFunction: (value: mixed) => boolean,
3272 isBigInt64Array: (value: mixed) => boolean,
3273 isBigUint64Array: (value: mixed) => boolean,
3274 isBooleanObject: (value: mixed) => boolean,
3275 isBoxedPrimitive: (value: mixed) => boolean,
3276 isDataView: (value: mixed) => boolean,
3277 isDate: (value: mixed) => boolean,
3278 isExternal: (value: mixed) => boolean,
3279 isFloat32Array: (value: mixed) => boolean,
3280 isFloat64Array: (value: mixed) => boolean,
3281 isGeneratorFunction: (value: mixed) => boolean,
3282 isGeneratorObject: (value: mixed) => boolean,
3283 isInt8Array: (value: mixed) => boolean,
3284 isInt16Array: (value: mixed) => boolean,
3285 isInt32Array: (value: mixed) => boolean,
3286 isMap: (value: mixed) => boolean,
3287 isMapIterator: (value: mixed) => boolean,
3288 isModuleNamespaceObject: (value: mixed) => boolean,
3289 isNativeError: (value: mixed) => boolean,
3290 isNumberObject: (value: mixed) => boolean,
3291 isPromise: (value: mixed) => boolean,
3292 isProxy: (value: mixed) => boolean,
3293 isRegExp: (value: mixed) => boolean,
3294 isSet: (value: mixed) => boolean,
3295 isSetIterator: (value: mixed) => boolean,
3296 isSharedArrayBuffer: (value: mixed) => boolean,
3297 isStringObject: (value: mixed) => boolean,
3298 isSymbolObject: (value: mixed) => boolean,
3299 isTypedArray: (value: mixed) => boolean,
3300 isUint8Array: (value: mixed) => boolean,
3301 isUint8ClampedArray: (value: mixed) => boolean,
3302 isUint16Array: (value: mixed) => boolean,
3303 isUint32Array: (value: mixed) => boolean,
3304 isWeakMap: (value: mixed) => boolean,
3305 isWeakSet: (value: mixed) => boolean,
3306 isWebAssemblyCompiledModule: (value: mixed) => boolean,
3307 ...
3308 };
3309 }
3310
3311 type vm$ScriptOptions = {
3312 cachedData?: Buffer,
3313 columnOffset?: number,
3314 displayErrors?: boolean,
3315 filename?: string,
3316 lineOffset?: number,
3317 produceCachedData?: boolean,
3318 timeout?: number,
3319 ...
3320 };
3321
3322 type vm$CreateContextOptions = {
3323 name?: string,
3324 origin?: string,
3325 codeGeneration?: {
3326 strings?: boolean,
3327 wasm?: boolean,
3328 ...
3329 },
3330 ...
3331 };
3332
3333 type vm$CompileFunctionOptions = {
3334 filename?: string,
3335 lineOffset?: number,
3336 columnOffset?: number,
3337 cachedData?: Buffer,
3338 produceCachedData?: boolean,
3339 parsingContext?: {[key: string]: any, ...},
3340 contextExtensions?: Array<{[key: string]: any, ...}>,
3341 ...
3342 };
3343
3344 declare class vm$Script {
3345 constructor(code: string, options?: vm$ScriptOptions | string): void;
3346 cachedData: ?Buffer;
3347 cachedDataRejected: ?boolean;
3348 cachedDataProduced: ?boolean;
3349 runInContext(
3350 contextifiedSandbox: vm$Context,
3351 options?: vm$ScriptOptions
3352 ): any;
3353 runInNewContext(
3354 sandbox?: {[key: string]: any, ...},
3355 options?: vm$ScriptOptions
3356 ): any;
3357 runInThisContext(options?: vm$ScriptOptions): any;
3358 createCachedData(): Buffer;
3359 }
3360
3361 declare class vm$Context {}
3362
3363 declare module 'vm' {
3364 declare var Script: typeof vm$Script;
3365 declare function createContext(
3366 sandbox?: interface {[key: string]: any},
3367 options?: vm$CreateContextOptions
3368 ): vm$Context;
3369 declare function isContext(sandbox: {[key: string]: any, ...}): boolean;
3370 declare function runInContext(
3371 code: string,
3372 contextifiedSandbox: vm$Context,
3373 options?: vm$ScriptOptions | string
3374 ): any;
3375 declare function runInDebugContext(code: string): any;
3376 declare function runInNewContext(
3377 code: string,
3378 sandbox?: {[key: string]: any, ...},
3379 options?: vm$ScriptOptions | string
3380 ): any;
3381 declare function runInThisContext(
3382 code: string,
3383 options?: vm$ScriptOptions | string
3384 ): any;
3385 declare function compileFunction(
3386 code: string,
3387 params: string[],
3388 options: vm$CompileFunctionOptions
3389 ): Function;
3390 }
3391
3392 type zlib$options = {
3393 flush?: number,
3394 chunkSize?: number,
3395 windowBits?: number,
3396 level?: number,
3397 memLevel?: number,
3398 strategy?: number,
3399 dictionary?: Buffer,
3400 ...
3401 };
3402
3403 type zlib$brotliOptions = {
3404 flush?: number,
3405 finishFlush?: number,
3406 chunkSize?: number,
3407 params?: {
3408 [number]: boolean | number,
3409 ...
3410 },
3411 maxOutputLength?: number,
3412 ...
3413 };
3414
3415 type zlib$syncFn = (
3416 buffer: Buffer | $TypedArray | DataView | ArrayBuffer | string,
3417 options?: zlib$options
3418 ) => Buffer;
3419
3420 type zlib$asyncFn = (
3421 buffer: Buffer | $TypedArray | DataView | ArrayBuffer | string,
3422 options?: zlib$options,
3423 callback?: (error: ?Error, result: Buffer) => void
3424 ) => void;
3425
3426 type zlib$brotliSyncFn = (
3427 buffer: Buffer | $TypedArray | DataView | ArrayBuffer | string,
3428 options?: zlib$brotliOptions
3429 ) => Buffer;
3430
3431 type zlib$brotliAsyncFn = (
3432 buffer: Buffer | $TypedArray | DataView | ArrayBuffer | string,
3433 options?: zlib$brotliOptions,
3434 callback?: (error: ?Error, result: Buffer) => void
3435 ) => void;
3436
3437 // Accessing the constants directly from the module is currently still
3438 // possible but should be considered deprecated.
3439 // ref: https://github.com/nodejs/node/blob/master/doc/api/zlib.md
3440 declare module 'zlib' {
3441 declare var Z_NO_FLUSH: number;
3442 declare var Z_PARTIAL_FLUSH: number;
3443 declare var Z_SYNC_FLUSH: number;
3444 declare var Z_FULL_FLUSH: number;
3445 declare var Z_FINISH: number;
3446 declare var Z_BLOCK: number;
3447 declare var Z_TREES: number;
3448 declare var Z_OK: number;
3449 declare var Z_STREAM_END: number;
3450 declare var Z_NEED_DICT: number;
3451 declare var Z_ERRNO: number;
3452 declare var Z_STREAM_ERROR: number;
3453 declare var Z_DATA_ERROR: number;
3454 declare var Z_MEM_ERROR: number;
3455 declare var Z_BUF_ERROR: number;
3456 declare var Z_VERSION_ERROR: number;
3457 declare var Z_NO_COMPRESSION: number;
3458 declare var Z_BEST_SPEED: number;
3459 declare var Z_BEST_COMPRESSION: number;
3460 declare var Z_DEFAULT_COMPRESSION: number;
3461 declare var Z_FILTERED: number;
3462 declare var Z_HUFFMAN_ONLY: number;
3463 declare var Z_RLE: number;
3464 declare var Z_FIXED: number;
3465 declare var Z_DEFAULT_STRATEGY: number;
3466 declare var Z_BINARY: number;
3467 declare var Z_TEXT: number;
3468 declare var Z_ASCII: number;
3469 declare var Z_UNKNOWN: number;
3470 declare var Z_DEFLATED: number;
3471 declare var Z_NULL: number;
3472 declare var Z_DEFAULT_CHUNK: number;
3473 declare var Z_DEFAULT_LEVEL: number;
3474 declare var Z_DEFAULT_MEMLEVEL: number;
3475 declare var Z_DEFAULT_WINDOWBITS: number;
3476 declare var Z_MAX_CHUNK: number;
3477 declare var Z_MAX_LEVEL: number;
3478 declare var Z_MAX_MEMLEVEL: number;
3479 declare var Z_MAX_WINDOWBITS: number;
3480 declare var Z_MIN_CHUNK: number;
3481 declare var Z_MIN_LEVEL: number;
3482 declare var Z_MIN_MEMLEVEL: number;
3483 declare var Z_MIN_WINDOWBITS: number;
3484 declare var constants: {
3485 Z_NO_FLUSH: number,
3486 Z_PARTIAL_FLUSH: number,
3487 Z_SYNC_FLUSH: number,
3488 Z_FULL_FLUSH: number,
3489 Z_FINISH: number,
3490 Z_BLOCK: number,
3491 Z_TREES: number,
3492 Z_OK: number,
3493 Z_STREAM_END: number,
3494 Z_NEED_DICT: number,
3495 Z_ERRNO: number,
3496 Z_STREAM_ERROR: number,
3497 Z_DATA_ERROR: number,
3498 Z_MEM_ERROR: number,
3499 Z_BUF_ERROR: number,
3500 Z_VERSION_ERROR: number,
3501 Z_NO_COMPRESSION: number,
3502 Z_BEST_SPEED: number,
3503 Z_BEST_COMPRESSION: number,
3504 Z_DEFAULT_COMPRESSION: number,
3505 Z_FILTERED: number,
3506 Z_HUFFMAN_ONLY: number,
3507 Z_RLE: number,
3508 Z_FIXED: number,
3509 Z_DEFAULT_STRATEGY: number,
3510 Z_BINARY: number,
3511 Z_TEXT: number,
3512 Z_ASCII: number,
3513 Z_UNKNOWN: number,
3514 Z_DEFLATED: number,
3515 Z_NULL: number,
3516 Z_DEFAULT_CHUNK: number,
3517 Z_DEFAULT_LEVEL: number,
3518 Z_DEFAULT_MEMLEVEL: number,
3519 Z_DEFAULT_WINDOWBITS: number,
3520 Z_MAX_CHUNK: number,
3521 Z_MAX_LEVEL: number,
3522 Z_MAX_MEMLEVEL: number,
3523 Z_MAX_WINDOWBITS: number,
3524 Z_MIN_CHUNK: number,
3525 Z_MIN_LEVEL: number,
3526 Z_MIN_MEMLEVEL: number,
3527 Z_MIN_WINDOWBITS: number,
3528
3529 BROTLI_DECODE: number,
3530 BROTLI_ENCODE: number,
3531 BROTLI_OPERATION_PROCESS: number,
3532 BROTLI_OPERATION_FLUSH: number,
3533 BROTLI_OPERATION_FINISH: number,
3534 BROTLI_OPERATION_EMIT_METADATA: number,
3535 BROTLI_PARAM_MODE: number,
3536 BROTLI_MODE_GENERIC: number,
3537 BROTLI_MODE_TEXT: number,
3538 BROTLI_MODE_FONT: number,
3539 BROTLI_DEFAULT_MODE: number,
3540 BROTLI_PARAM_QUALITY: number,
3541 BROTLI_MIN_QUALITY: number,
3542 BROTLI_MAX_QUALITY: number,
3543 BROTLI_DEFAULT_QUALITY: number,
3544 BROTLI_PARAM_LGWIN: number,
3545 BROTLI_MIN_WINDOW_BITS: number,
3546 BROTLI_MAX_WINDOW_BITS: number,
3547 BROTLI_LARGE_MAX_WINDOW_BITS: number,
3548 BROTLI_DEFAULT_WINDOW: number,
3549 BROTLI_PARAM_LGBLOCK: number,
3550 BROTLI_MIN_INPUT_BLOCK_BITS: number,
3551 BROTLI_MAX_INPUT_BLOCK_BITS: number,
3552 BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: number,
3553 BROTLI_PARAM_SIZE_HINT: number,
3554 BROTLI_PARAM_LARGE_WINDOW: number,
3555 BROTLI_PARAM_NPOSTFIX: number,
3556 BROTLI_PARAM_NDIRECT: number,
3557 BROTLI_DECODER_RESULT_ERROR: number,
3558 BROTLI_DECODER_RESULT_SUCCESS: number,
3559 BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: number,
3560 BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: number,
3561 BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: number,
3562 BROTLI_DECODER_PARAM_LARGE_WINDOW: number,
3563 BROTLI_DECODER_NO_ERROR: number,
3564 BROTLI_DECODER_SUCCESS: number,
3565 BROTLI_DECODER_NEEDS_MORE_INPUT: number,
3566 BROTLI_DECODER_NEEDS_MORE_OUTPUT: number,
3567 BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: number,
3568 BROTLI_DECODER_ERROR_FORMAT_RESERVED: number,
3569 BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: number,
3570 BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: number,
3571 BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: number,
3572 BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: number,
3573 BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: number,
3574 BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: number,
3575 BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: number,
3576 BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: number,
3577 BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: number,
3578 BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: number,
3579 BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: number,
3580 BROTLI_DECODER_ERROR_FORMAT_PADDING_1: number,
3581 BROTLI_DECODER_ERROR_FORMAT_PADDING_2: number,
3582 BROTLI_DECODER_ERROR_FORMAT_DISTANCE: number,
3583 BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: number,
3584 BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: number,
3585 BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: number,
3586 BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: number,
3587 BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: number,
3588 BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: number,
3589 BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: number,
3590 BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number,
3591 BROTLI_DECODER_ERROR_UNREACHABL: number,
3592 ...
3593 };
3594 declare var codes: {
3595 Z_OK: number,
3596 Z_STREAM_END: number,
3597 Z_NEED_DICT: number,
3598 Z_ERRNO: number,
3599 Z_STREAM_ERROR: number,
3600 Z_DATA_ERROR: number,
3601 Z_MEM_ERROR: number,
3602 Z_BUF_ERROR: number,
3603 Z_VERSION_ERROR: number,
3604 ...
3605 };
3606 declare class Zlib extends stream$Duplex {
3607 // TODO
3608 }
3609 declare class BrotliCompress extends Zlib {}
3610 declare class BrotliDecompress extends Zlib {}
3611 declare class Deflate extends Zlib {}
3612 declare class Inflate extends Zlib {}
3613 declare class Gzip extends Zlib {}
3614 declare class Gunzip extends Zlib {}
3615 declare class DeflateRaw extends Zlib {}
3616 declare class InflateRaw extends Zlib {}
3617 declare class Unzip extends Zlib {}
3618 declare function createBrotliCompress(
3619 options?: zlib$brotliOptions
3620 ): BrotliCompress;
3621 declare function createBrotliDecompress(
3622 options?: zlib$brotliOptions
3623 ): BrotliDecompress;
3624 declare function createDeflate(options?: zlib$options): Deflate;
3625 declare function createInflate(options?: zlib$options): Inflate;
3626 declare function createDeflateRaw(options?: zlib$options): DeflateRaw;
3627 declare function createInflateRaw(options?: zlib$options): InflateRaw;
3628 declare function createGzip(options?: zlib$options): Gzip;
3629 declare function createGunzip(options?: zlib$options): Gunzip;
3630 declare function createUnzip(options?: zlib$options): Unzip;
3631 declare var brotliCompress: zlib$brotliAsyncFn;
3632 declare var brotliCompressSync: zlib$brotliSyncFn;
3633 declare var brotliDeompress: zlib$brotliAsyncFn;
3634 declare var brotliDecompressSync: zlib$brotliSyncFn;
3635 declare var deflate: zlib$asyncFn;
3636 declare var deflateSync: zlib$syncFn;
3637 declare var gzip: zlib$asyncFn;
3638 declare var gzipSync: zlib$syncFn;
3639 declare var deflateRaw: zlib$asyncFn;
3640 declare var deflateRawSync: zlib$syncFn;
3641 declare var unzip: zlib$asyncFn;
3642 declare var unzipSync: zlib$syncFn;
3643 declare var inflate: zlib$asyncFn;
3644 declare var inflateSync: zlib$syncFn;
3645 declare var gunzip: zlib$asyncFn;
3646 declare var gunzipSync: zlib$syncFn;
3647 declare var inflateRaw: zlib$asyncFn;
3648 declare var inflateRawSync: zlib$syncFn;
3649 }
3650
3651 declare module 'assert' {
3652 declare class AssertionError extends Error {}
3653 declare type AssertStrict = {
3654 (value: any, message?: string): void,
3655 ok(value: any, message?: string): void,
3656 fail(message?: string | Error): void,
3657 // deprecated since v10.15
3658 fail(actual: any, expected: any, message: string, operator: string): void,
3659 equal(actual: any, expected: any, message?: string): void,
3660 notEqual(actual: any, expected: any, message?: string): void,
3661 deepEqual(actual: any, expected: any, message?: string): void,
3662 notDeepEqual(actual: any, expected: any, message?: string): void,
3663 throws(
3664 block: Function,
3665 error?: Function | RegExp | ((err: any) => boolean),
3666 message?: string
3667 ): void,
3668 doesNotThrow(block: Function, message?: string): void,
3669 ifError(value: any): void,
3670 AssertionError: typeof AssertionError,
3671 strict: AssertStrict,
3672 ...
3673 };
3674 declare module.exports: {
3675 (value: any, message?: string): void,
3676 ok(value: any, message?: string): void,
3677 fail(message?: string | Error): void,
3678 // deprecated since v10.15
3679 fail(actual: any, expected: any, message: string, operator: string): void,
3680 equal(actual: any, expected: any, message?: string): void,
3681 notEqual(actual: any, expected: any, message?: string): void,
3682 deepEqual(actual: any, expected: any, message?: string): void,
3683 notDeepEqual(actual: any, expected: any, message?: string): void,
3684 strictEqual(actual: any, expected: any, message?: string): void,
3685 notStrictEqual(actual: any, expected: any, message?: string): void,
3686 deepStrictEqual(actual: any, expected: any, message?: string): void,
3687 notDeepStrictEqual(actual: any, expected: any, message?: string): void,
3688 throws(
3689 block: Function,
3690 error?: Function | RegExp | ((err: any) => boolean),
3691 message?: string
3692 ): void,
3693 doesNotThrow(block: Function, message?: string): void,
3694 ifError(value: any): void,
3695 AssertionError: typeof AssertionError,
3696 strict: AssertStrict,
3697 ...
3698 };
3699 }
3700
3701 type HeapCodeStatistics = {
3702 code_and_metadata_size: number,
3703 bytecode_and_metadata_size: number,
3704 external_script_source_size: number,
3705 ...
3706 };
3707
3708 type HeapStatistics = {
3709 total_heap_size: number,
3710 total_heap_size_executable: number,
3711 total_physical_size: number,
3712 total_available_size: number,
3713 used_heap_size: number,
3714 heap_size_limit: number,
3715 malloced_memory: number,
3716 peak_malloced_memory: number,
3717 does_zap_garbage: 0 | 1,
3718 number_of_native_contexts: number,
3719 number_of_detached_contexts: number,
3720 ...
3721 };
3722
3723 type HeapSpaceStatistics = {
3724 space_name: string,
3725 space_size: number,
3726 space_used_size: number,
3727 space_available_size: number,
3728 physical_space_size: number,
3729 ...
3730 };
3731
3732 // Adapted from DefinitelyTyped for Node v14:
3733 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/dea4d99dc302a0b0a25270e46e72c1fe9b741a17/types/node/v14/v8.d.ts
3734 declare module 'v8' {
3735 /**
3736 * Returns an integer representing a "version tag" derived from the V8 version, command line flags and detected CPU features.
3737 * This is useful for determining whether a vm.Script cachedData buffer is compatible with this instance of V8.
3738 */
3739 declare function cachedDataVersionTag(): number;
3740
3741 /**
3742 * Generates a snapshot of the current V8 heap and returns a Readable
3743 * Stream that may be used to read the JSON serialized representation.
3744 * This conversation was marked as resolved by joyeecheung
3745 * This JSON stream format is intended to be used with tools such as
3746 * Chrome DevTools. The JSON schema is undocumented and specific to the
3747 * V8 engine, and may change from one version of V8 to the next.
3748 */
3749 declare function getHeapSnapshot(): stream$Readable;
3750
3751 /**
3752 *
3753 * @param fileName The file path where the V8 heap snapshot is to be
3754 * saved. If not specified, a file name with the pattern
3755 * `'Heap-${yyyymmdd}-${hhmmss}-${pid}-${thread_id}.heapsnapshot'` will be
3756 * generated, where `{pid}` will be the PID of the Node.js process,
3757 * `{thread_id}` will be `0` when `writeHeapSnapshot()` is called from
3758 * the main Node.js thread or the id of a worker thread.
3759 */
3760 declare function writeHeapSnapshot(fileName?: string): string;
3761
3762 declare function getHeapCodeStatistics(): HeapCodeStatistics;
3763
3764 declare function getHeapStatistics(): HeapStatistics;
3765 declare function getHeapSpaceStatistics(): Array<HeapSpaceStatistics>;
3766 declare function setFlagsFromString(flags: string): void;
3767
3768 declare class Serializer {
3769 constructor(): void;
3770
3771 /**
3772 * Writes out a header, which includes the serialization format version.
3773 */
3774 writeHeader(): void;
3775
3776 /**
3777 * Serializes a JavaScript value and adds the serialized representation to the internal buffer.
3778 * This throws an error if value cannot be serialized.
3779 */
3780 writeValue(val: any): boolean;
3781
3782 /**
3783 * Returns the stored internal buffer.
3784 * This serializer should not be used once the buffer is released.
3785 * Calling this method results in undefined behavior if a previous write has failed.
3786 */
3787 releaseBuffer(): Buffer;
3788
3789 /**
3790 * Marks an ArrayBuffer as having its contents transferred out of band.\
3791 * Pass the corresponding ArrayBuffer in the deserializing context to deserializer.transferArrayBuffer().
3792 */
3793 transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
3794
3795 /**
3796 * Write a raw 32-bit unsigned integer.
3797 */
3798 writeUint32(value: number): void;
3799
3800 /**
3801 * Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
3802 */
3803 writeUint64(hi: number, lo: number): void;
3804
3805 /**
3806 * Write a JS number value.
3807 */
3808 writeDouble(value: number): void;
3809
3810 /**
3811 * Write raw bytes into the serializer’s internal buffer.
3812 * The deserializer will require a way to compute the length of the buffer.
3813 */
3814 writeRawBytes(buffer: Buffer | $TypedArray | DataView): void;
3815 }
3816
3817 /**
3818 * A subclass of `Serializer` that serializes `TypedArray` (in particular `Buffer`) and `DataView` objects as host objects,
3819 * and only stores the part of their underlying `ArrayBuffers` that they are referring to.
3820 */
3821 declare class DefaultSerializer extends Serializer {}
3822
3823 declare class Deserializer {
3824 constructor(data: Buffer | $TypedArray | DataView): void;
3825
3826 /**
3827 * Reads and validates a header (including the format version).
3828 * May, for example, reject an invalid or unsupported wire format.
3829 * In that case, an Error is thrown.
3830 */
3831 readHeader(): boolean;
3832
3833 /**
3834 * Deserializes a JavaScript value from the buffer and returns it.
3835 */
3836 readValue(): any;
3837
3838 /**
3839 * Marks an ArrayBuffer as having its contents transferred out of band.
3840 * Pass the corresponding `ArrayBuffer` in the serializing context to serializer.transferArrayBuffer()
3841 * (or return the id from serializer._getSharedArrayBufferId() in the case of SharedArrayBuffers).
3842 */
3843 transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
3844
3845 /**
3846 * Reads the underlying wire format version.
3847 * Likely mostly to be useful to legacy code reading old wire format versions.
3848 * May not be called before .readHeader().
3849 */
3850 getWireFormatVersion(): number;
3851
3852 /**
3853 * Read a raw 32-bit unsigned integer and return it.
3854 */
3855 readUint32(): number;
3856
3857 /**
3858 * Read a raw 64-bit unsigned integer and return it as an array [hi, lo] with two 32-bit unsigned integer entries.
3859 */
3860 readUint64(): [number, number];
3861
3862 /**
3863 * Read a JS number value.
3864 */
3865 readDouble(): number;
3866
3867 /**
3868 * Read raw bytes from the deserializer’s internal buffer.
3869 * The length parameter must correspond to the length of the buffer that was passed to serializer.writeRawBytes().
3870 */
3871 readRawBytes(length: number): Buffer;
3872 }
3873
3874 /**
3875 * A subclass of `Serializer` that serializes `TypedArray` (in particular `Buffer`) and `DataView` objects as host objects,
3876 * and only stores the part of their underlying `ArrayBuffers` that they are referring to.
3877 */
3878 declare class DefaultDeserializer extends Deserializer {}
3879
3880 /**
3881 * Uses a `DefaultSerializer` to serialize value into a buffer.
3882 */
3883 declare function serialize(value: any): Buffer;
3884
3885 /**
3886 * Uses a `DefaultDeserializer` with default options to read a JS value from a buffer.
3887 */
3888 declare function deserialize(data: Buffer | $TypedArray | DataView): any;
3889 }
3890
3891 type repl$DefineCommandOptions = (...args: Array<any>) => void | {
3892 action: (...args: Array<any>) => void,
3893 help?: string,
3894 ...
3895 };
3896
3897 declare class $SymbolReplModeMagic mixins Symbol {}
3898 declare class $SymbolReplModeSloppy mixins Symbol {}
3899 declare class $SymbolReplModeStrict mixins Symbol {}
3900
3901 declare module 'repl' {
3902 declare var REPL_MODE_MAGIC: $SymbolReplModeMagic;
3903 declare var REPL_MODE_SLOPPY: $SymbolReplModeSloppy;
3904 declare var REPL_MODE_STRICT: $SymbolReplModeStrict;
3905
3906 declare class REPLServer extends readline$Interface {
3907 context: vm$Context;
3908 defineCommand(command: string, options: repl$DefineCommandOptions): void;
3909 displayPrompt(preserveCursor?: boolean): void;
3910 }
3911
3912 declare function start(prompt: string): REPLServer;
3913 declare function start(options: {
3914 prompt?: string,
3915 input?: stream$Readable,
3916 output?: stream$Writable,
3917 terminal?: boolean,
3918 eval?: Function,
3919 useColors?: boolean,
3920 useGlobal?: boolean,
3921 ignoreUndefined?: boolean,
3922 writer?: (object: any, options?: util$InspectOptions) => string,
3923 completer?: readline$InterfaceCompleter,
3924 replMode?:
3925 | $SymbolReplModeMagic
3926 | $SymbolReplModeSloppy
3927 | $SymbolReplModeStrict,
3928 breakEvalOnSigint?: boolean,
3929 ...
3930 }): REPLServer;
3931
3932 declare class Recoverable extends SyntaxError {
3933 constructor(err: Error): void;
3934 }
3935 }
3936
3937 declare module 'inspector' {
3938 declare function open(port?: number, host?: string, wait?: boolean): void;
3939
3940 declare function close(): void;
3941 declare function url(): string | void;
3942 declare var console: Object;
3943 declare function waitForDebugger(): void;
3944
3945 declare class Session extends events$EventEmitter {
3946 constructor(): void;
3947 connect(): void;
3948 connectToMainThread(): void;
3949 disconnect(): void;
3950 post(method: string, params?: Object, callback?: Function): void;
3951 }
3952 }
3953
3954 /* globals: https://nodejs.org/api/globals.html */
3955
3956 type process$CPUUsage = {
3957 user: number,
3958 system: number,
3959 ...
3960 };
3961
3962 declare class Process extends events$EventEmitter {
3963 abort(): void;
3964 allowedNodeEnvironmentFlags: Set<string>;
3965 arch: string;
3966 argv: Array<string>;
3967 chdir(directory: string): void;
3968 config: Object;
3969 connected: boolean;
3970 cpuUsage(previousValue?: process$CPUUsage): process$CPUUsage;
3971 cwd(): string;
3972 disconnect?: () => void;
3973 domain?: domain$Domain;
3974 env: {[key: string]: string | void, ...};
3975 emitWarning(warning: string | Error): void;
3976 emitWarning(
3977 warning: string,
3978 typeOrCtor: string | ((...empty) => mixed)
3979 ): void;
3980 emitWarning(
3981 warning: string,
3982 type: string,
3983 codeOrCtor: string | ((...empty) => mixed)
3984 ): void;
3985 emitWarning(
3986 warning: string,
3987 type: string,
3988 code: string,
3989 ctor?: (...empty) => mixed
3990 ): void;
3991 execArgv: Array<string>;
3992 execPath: string;
3993 exit(code?: number): empty;
3994 exitCode?: number;
3995 getegid?: () => number;
3996 geteuid?: () => number;
3997 getgid?: () => number;
3998 getgroups?: () => Array<number>;
3999 getuid?: () => number;
4000 hrtime: {
4001 (time?: [number, number]): [number, number],
4002 bigint: () => bigint,
4003 ...
4004 };
4005 initgroups?: (user: number | string, extra_group: number | string) => void;
4006 kill(pid: number, signal?: string | number): void;
4007 mainModule: Object;
4008 memoryUsage(): {
4009 arrayBuffers: number,
4010 rss: number,
4011 heapTotal: number,
4012 heapUsed: number,
4013 external: number,
4014 ...
4015 };
4016 nextTick: <T>(cb: (...T) => mixed, ...T) => void;
4017 pid: number;
4018 platform: string;
4019 release: {
4020 name: string,
4021 lts?: string,
4022 sourceUrl: string,
4023 headersUrl: string,
4024 libUrl: string,
4025 ...
4026 };
4027 send?: (
4028 message: any,
4029 sendHandleOrCallback?: net$Socket | net$Server | Function,
4030 callback?: Function
4031 ) => void;
4032 setegid?: (id: number | string) => void;
4033 seteuid?: (id: number | string) => void;
4034 setgid?: (id: number | string) => void;
4035 setgroups?: <Group: string | number>(groups: Array<Group>) => void;
4036 setuid?: (id: number | string) => void;
4037 stderr: stream$Writable | tty$WriteStream;
4038 stdin: stream$Readable | tty$ReadStream;
4039 stdout: stream$Writable | tty$WriteStream;
4040 title: string;
4041 umask(mask?: number): number;
4042 uptime(): number;
4043 version: string;
4044 versions: {
4045 [key: string]: ?string,
4046 node: string,
4047 v8: string,
4048 ...
4049 };
4050 }
4051 declare var process: Process;
4052
4053 declare var __filename: string;
4054 declare var __dirname: string;
4055
4056 declare function setImmediate(
4057 callback: (...args: Array<any>) => mixed,
4058 ...args: Array<any>
4059 ): Object;
4060 declare function clearImmediate(immediateObject: any): Object;
4061
4062 // https://nodejs.org/api/esm.html#node-imports
4063
4064 declare module 'node:assert' {
4065 declare module.exports: $Exports<'assert'>;
4066 }
4067
4068 declare module 'node:assert/strict' {
4069 declare module.exports: $Exports<'assert'>['strict'];
4070 }
4071
4072 declare module 'node:events' {
4073 declare module.exports: $Exports<'events'>;
4074 }
4075
4076 declare module 'node:fs' {
4077 declare module.exports: $Exports<'fs'>;
4078 }
4079
4080 declare module 'node:os' {
4081 declare module.exports: $Exports<'os'>;
4082 }
4083
4084 declare module 'fs/promises' {
4085 declare module.exports: $Exports<'fs'>['promises'];
4086 }
4087
4088 declare module 'node:fs/promises' {
4089 declare module.exports: $Exports<'fs'>['promises'];
4090 }
4091
4092 declare module 'node:path' {
4093 declare module.exports: $Exports<'path'>;
4094 }
4095
4096 declare module 'process' {
4097 declare module.exports: Process;
4098 }
4099
4100 declare module 'node:process' {
4101 declare module.exports: $Exports<'process'>;
4102 }
4103
4104 declare module 'node:util' {
4105 declare module.exports: $Exports<'util'>;
4106 }
4107
4108 declare module 'node:url' {
4109 declare module.exports: $Exports<'url'>;
4110 }
4111
4112 declare module 'worker_threads' {
4113 declare var isMainThread: boolean;
4114 declare var parentPort: null | MessagePort;
4115 declare var threadId: number;
4116 declare var workerData: any;
4117
4118 declare class MessageChannel {
4119 +port1: MessagePort;
4120 +port2: MessagePort;
4121 }
4122
4123 declare class MessagePort extends events$EventEmitter {
4124 close(): void;
4125 postMessage(
4126 value: any,
4127 transferList?: Array<ArrayBuffer | MessagePort>
4128 ): void;
4129 ref(): void;
4130 unref(): void;
4131 start(): void;
4132
4133 addListener(event: 'close', listener: () => void): this;
4134 addListener(event: 'message', listener: (value: any) => void): this;
4135 addListener(
4136 event: string | Symbol,
4137 listener: (...args: any[]) => void
4138 ): this;
4139
4140 emit(event: 'close'): boolean;
4141 emit(event: 'message', value: any): boolean;
4142 emit(event: string | Symbol, ...args: any[]): boolean;
4143
4144 on(event: 'close', listener: () => void): this;
4145 on(event: 'message', listener: (value: any) => void): this;
4146 on(event: string | Symbol, listener: (...args: any[]) => void): this;
4147
4148 once(event: 'close', listener: () => void): this;
4149 once(event: 'message', listener: (value: any) => void): this;
4150 once(event: string | Symbol, listener: (...args: any[]) => void): this;
4151
4152 prependListener(event: 'close', listener: () => void): this;
4153 prependListener(event: 'message', listener: (value: any) => void): this;
4154 prependListener(
4155 event: string | Symbol,
4156 listener: (...args: any[]) => void
4157 ): this;
4158
4159 prependOnceListener(event: 'close', listener: () => void): this;
4160 prependOnceListener(event: 'message', listener: (value: any) => void): this;
4161 prependOnceListener(
4162 event: string | Symbol,
4163 listener: (...args: any[]) => void
4164 ): this;
4165
4166 removeListener(event: 'close', listener: () => void): this;
4167 removeListener(event: 'message', listener: (value: any) => void): this;
4168 removeListener(
4169 event: string | Symbol,
4170 listener: (...args: any[]) => void
4171 ): this;
4172
4173 off(event: 'close', listener: () => void): this;
4174 off(event: 'message', listener: (value: any) => void): this;
4175 off(event: string | Symbol, listener: (...args: any[]) => void): this;
4176 }
4177
4178 declare type WorkerOptions = {|
4179 env?: Object,
4180 eval?: boolean,
4181 workerData?: any,
4182 stdin?: boolean,
4183 stdout?: boolean,
4184 stderr?: boolean,
4185 execArgv?: string[],
4186 |};
4187
4188 declare class Worker extends events$EventEmitter {
4189 +stdin: stream$Writable | null;
4190 +stdout: stream$Readable;
4191 +stderr: stream$Readable;
4192 +threadId: number;
4193
4194 constructor(filename: string, options?: WorkerOptions): void;
4195
4196 postMessage(
4197 value: any,
4198 transferList?: Array<ArrayBuffer | MessagePort>
4199 ): void;
4200 ref(): void;
4201 unref(): void;
4202 terminate(callback?: (err: Error, exitCode: number) => void): void;
4203 /**
4204 * Transfer a `MessagePort` to a different `vm` Context. The original `port`
4205 * object will be rendered unusable, and the returned `MessagePort` instance will
4206 * take its place.
4207 *
4208 * The returned `MessagePort` will be an object in the target context, and will
4209 * inherit from its global `Object` class. Objects passed to the
4210 * `port.onmessage()` listener will also be created in the target context
4211 * and inherit from its global `Object` class.
4212 *
4213 * However, the created `MessagePort` will no longer inherit from
4214 * `EventEmitter`, and only `port.onmessage()` can be used to receive
4215 * events using it.
4216 */
4217 moveMessagePortToContext(
4218 port: MessagePort,
4219 context: vm$Context
4220 ): MessagePort;
4221
4222 addListener(event: 'error', listener: (err: Error) => void): this;
4223 addListener(event: 'exit', listener: (exitCode: number) => void): this;
4224 addListener(event: 'message', listener: (value: any) => void): this;
4225 addListener(event: 'online', listener: () => void): this;
4226 addListener(
4227 event: string | Symbol,
4228 listener: (...args: any[]) => void
4229 ): this;
4230
4231 emit(event: 'error', err: Error): boolean;
4232 emit(event: 'exit', exitCode: number): boolean;
4233 emit(event: 'message', value: any): boolean;
4234 emit(event: 'online'): boolean;
4235 emit(event: string | Symbol, ...args: any[]): boolean;
4236
4237 on(event: 'error', listener: (err: Error) => void): this;
4238 on(event: 'exit', listener: (exitCode: number) => void): this;
4239 on(event: 'message', listener: (value: any) => void): this;
4240 on(event: 'online', listener: () => void): this;
4241 on(event: string | Symbol, listener: (...args: any[]) => void): this;
4242
4243 once(event: 'error', listener: (err: Error) => void): this;
4244 once(event: 'exit', listener: (exitCode: number) => void): this;
4245 once(event: 'message', listener: (value: any) => void): this;
4246 once(event: 'online', listener: () => void): this;
4247 once(event: string | Symbol, listener: (...args: any[]) => void): this;
4248
4249 prependListener(event: 'error', listener: (err: Error) => void): this;
4250 prependListener(event: 'exit', listener: (exitCode: number) => void): this;
4251 prependListener(event: 'message', listener: (value: any) => void): this;
4252 prependListener(event: 'online', listener: () => void): this;
4253 prependListener(
4254 event: string | Symbol,
4255 listener: (...args: any[]) => void
4256 ): this;
4257
4258 prependOnceListener(event: 'error', listener: (err: Error) => void): this;
4259 prependOnceListener(
4260 event: 'exit',
4261 listener: (exitCode: number) => void
4262 ): this;
4263 prependOnceListener(event: 'message', listener: (value: any) => void): this;
4264 prependOnceListener(event: 'online', listener: () => void): this;
4265 prependOnceListener(
4266 event: string | Symbol,
4267 listener: (...args: any[]) => void
4268 ): this;
4269
4270 removeListener(event: 'error', listener: (err: Error) => void): this;
4271 removeListener(event: 'exit', listener: (exitCode: number) => void): this;
4272 removeListener(event: 'message', listener: (value: any) => void): this;
4273 removeListener(event: 'online', listener: () => void): this;
4274 removeListener(
4275 event: string | Symbol,
4276 listener: (...args: any[]) => void
4277 ): this;
4278
4279 off(event: 'error', listener: (err: Error) => void): this;
4280 off(event: 'exit', listener: (exitCode: number) => void): this;
4281 off(event: 'message', listener: (value: any) => void): this;
4282 off(event: 'online', listener: () => void): this;
4283 off(event: string | Symbol, listener: (...args: any[]) => void): this;
4284 }
4285 }
4286
4287 declare module 'node:worker_threads' {
4288 declare module.exports: $Exports<'worker_threads'>;
4289 }