-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
node.js
1544 lines (1417 loc) · 52 KB
/
node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the "flow" directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
interface ErrnoError extends Error {
errno?: number;
code?: string;
path?: string;
syscall?: string;
}
type buffer$NonBufferEncoding =
'hex' | 'HEX' |
'utf8' | 'UTF8' | 'utf-8' | 'UTF-8' |
'ascii' | 'ASCII' |
'binary' | 'BINARY' |
'base64' | 'BASE64' |
'ucs2' | 'UCS2' | 'ucs-2' | 'UCS-2' |
'utf16le' | 'UTF16LE' | 'utf-16le' | 'UTF-16LE';
type buffer$Encoding = buffer$NonBufferEncoding | 'buffer'
type buffer$ToJSONRet = { type: string, data: Array<number> }
declare class Buffer {
constructor(
value: Array<number> | number | string | Buffer | ArrayBuffer,
encoding?: buffer$Encoding
): void;
[i: number]: number;
length: number;
compare(otherBuffer: Buffer): number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
entries(): Iterator<[number, number]>;
equals(otherBuffer: Buffer): boolean;
fill(value: string | number, offset?: number, end?: number): void;
includes(
value: string | Buffer | number,
offsetOrEncoding?: number | buffer$Encoding,
encoding?: buffer$Encoding
): boolean;
indexOf(
value: string | Buffer | number,
offsetOrEncoding?: number | buffer$Encoding,
encoding?: buffer$Encoding
): number;
inspect(): string;
keys(): Iterator<number>,
lastIndexOf(
value: string | Buffer | number,
offsetOrEncoding?: number | buffer$Encoding,
encoding?: buffer$Encoding
): number;
readDoubleBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number;
readFloatBE(offset: number, noAssert?: boolean): number;
readFloatLE(offset: number, noAssert?: boolean): number;
readInt16BE(offset: number, noAssert?: boolean): number;
readInt16LE(offset: number, noAssert?: boolean): number;
readInt32BE(offset: number, noAssert?: boolean): number;
readInt32LE(offset: number, noAssert?: boolean): number;
readInt8(offset: number, noAssert?: boolean): number;
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readUInt16BE(offset: number, noAssert?: boolean): number;
readUInt16LE(offset: number, noAssert?: boolean): number;
readUInt32BE(offset: number, noAssert?: boolean): number;
readUInt32LE(offset: number, noAssert?: boolean): number;
readUInt8(offset: number, noAssert?: boolean): number;
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
slice(start?: number, end?: number): Buffer;
swap16(): Buffer;
swap32(): Buffer;
toJSON(): buffer$ToJSONRet;
toString(encoding?: buffer$Encoding, start?: number, end?: number): string;
values(): Iterator<number>;
write(string: string, offset?: number, length?: number, encoding?: buffer$Encoding): void;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeInt8(value: number, offset: number, noAssert?: boolean): number;
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
static alloc(size: number, fill?: string | number, encoding?: buffer$Encoding): Buffer;
static allocUnsafe(size: number): Buffer;
static allocUnsafeSlow(size: number): Buffer;
static byteLength(string: string | Buffer | $TypedArray | DataView | ArrayBuffer, encoding?: buffer$Encoding): number;
static compare(buf1: Buffer, buf2: Buffer): number;
static concat(list: Array<Buffer>, totalLength?: number): Buffer;
// `UNUSED` argument strictly enforces arity to enable overloading this
// function with 1-arg and 2-arg variants.
static from(value: Array<number>, UNUSED: void): Buffer;
static from(value: Buffer, UNUSED: void): Buffer;
static from(value: string, encoding?: buffer$Encoding): Buffer;
static from(value: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
static isBuffer(obj: any): boolean;
static isEncoding(encoding: string): boolean;
}
declare module "buffer" {
declare var INSPECT_MAX_BYTES: number;
}
type child_process$execOpts = {
cwd?: string;
env?: Object;
encoding?: string;
shell?: string;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
uid?: number;
gid?: number;
};
declare class child_process$Error extends Error {
code: number,
signal: ?string,
}
type child_process$execCallback = (error: ?child_process$Error, stdout: string | Buffer, stderr: string | Buffer) => void;
type child_process$execSyncOpts = {
cwd?: string;
input?: string | Buffer;
stdio?: Array<any>;
env?: Object;
uid?: number;
gid?: number;
timeout?: number;
killSignal?: string;
maxBuffer?: number;
encoding?: string;
};
type child_process$execFileOpts = {
cwd?: string;
env?: Object;
encoding?: string;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
uid?: number;
gid?: number;
};
type child_process$execFileCallback = (error: ?child_process$Error, stdout: Buffer, stderr: Buffer) => void;
type child_process$forkOpts = {
cwd?: string;
env?: Object;
execPath?: string;
execArgv?: Array<string>;
silent?: boolean;
stdio?: Array<any>;
uid?: number;
gid?: number;
};
type child_process$Handle = any; // TODO
type child_process$spawnOpts = {
cwd?: string;
env?: Object;
stdio?: string | Array<any>;
detached?: boolean;
uid?: number;
gid?: number;
};
type child_process$spawnRet = {
pid: number;
output: Array<any>;
stdout: Buffer | string;
stderr: Buffer | string;
status: number;
signal: string;
error: Error;
};
declare class child_process$ChildProcess extends events$EventEmitter {
stdin: stream$Writable;
stdout: stream$Readable;
stderr: stream$Readable;
pid: number;
connected: boolean;
disconnect(): void;
kill(signal?: string): void;
send(message: Object, sendHandle?: child_process$Handle): boolean;
}
declare module "child_process" {
declare var ChildProcess: typeof child_process$ChildProcess;
declare function exec(
command: string,
optionsOrCallback?: child_process$execOpts | child_process$execCallback,
callback?: child_process$execCallback
): child_process$ChildProcess;
declare function execSync(
command: string,
options: {encoding: buffer$NonBufferEncoding} & child_process$execSyncOpts
): string;
declare function execSync(
command: string,
options?: child_process$execSyncOpts
): Buffer;
declare function execFile(
file: string,
argsOrOptionsOrCallback?:
Array<string> | child_process$execFileOpts | child_process$execFileCallback,
optionsOrCallback?: child_process$execFileOpts | child_process$execFileCallback,
callback?: child_process$execFileCallback
): child_process$ChildProcess;
declare function execFileSync(
command: string,
argsOrOptions?: Array<string> | child_process$execFileOpts,
options?: child_process$execFileOpts
): Buffer | string;
declare function fork(
modulePath: string,
argsOrOptions?: Array<string> | child_process$forkOpts,
options?: child_process$forkOpts
): child_process$ChildProcess;
declare function spawn(
command: string,
argsOrOptions?: Array<string> | child_process$spawnOpts,
options?: child_process$spawnOpts
): child_process$ChildProcess;
declare function spawnSync(
command: string,
argsOrOptions?: Array<string> | child_process$spawnOpts,
options?: child_process$spawnOpts
): child_process$spawnRet;
}
type cluster$Worker = {
id: string;
process: child_process$ChildProcess;
suicide: boolean;
disconnect(): void;
kill(signal?: string): void;
send(message: Object, sendHandle?: child_process$Handle): boolean;
}
declare module "cluster" {
declare var isMaster: boolean;
declare var isWorker: boolean;
declare var settings: {
args: Array<string>;
exec: string;
execArgv: Array<string>;
silent: boolean;
};
declare var worker: cluster$Worker;
declare var workers: Object;
declare function disconnect(callback?: () => void): void;
declare function fork(env?: Object): cluster$Worker;
declare function setupMaster(settings?: Object): void;
}
type crypto$createCredentialsDetails = any; // TODO
declare class crypto$Cipher extends stream$Duplex {
final(output_encoding: 'binary' | 'base64' | 'hex'): string;
final(output_encoding: void): Buffer;
getAuthTag(): Buffer;
setAAD(buffer: Buffer): void;
setAuthTag(buffer: Buffer): void;
setAutoPadding(auto_padding?: boolean): crypto$Cipher;
update(
data: string,
input_encoding: 'utf8'| 'ascii' | 'binary',
output_encoding: 'binary' | 'base64' | 'hex'
): string;
update(
data: string,
input_encoding: 'utf8'| 'ascii' | 'binary',
output_encoding: void
): Buffer;
update(
data: Buffer,
input_encoding: void,
output_encoding: 'binary' | 'base64' | 'hex'
): string;
update(
data: Buffer,
input_encoding: void,
output_encoding: void
): Buffer;
}
type crypto$Credentials = {
// TODO
}
type crypto$DiffieHellman = {
computeSecret(
other_public_key: string,
input_encoding?: string,
output_encoding?: string
): any;
generateKeys(encoding?: string): any;
getGenerator(encoding?: string): any;
getPrime(encoding?: string): any;
getPrivateKey(encoding?: string): any;
getPublicKey(encoding?: string): any;
setPrivateKey(private_key: any, encoding?: string): void;
setPublicKey(public_key: any, encoding?: string): void;
}
declare class crypto$Decipher extends stream$Duplex {
final(output_encoding: 'binary' | 'base64' | 'hex'): string;
final(output_encoding: void): Buffer;
getAuthTag(): Buffer;
setAAD(buffer: Buffer): void;
setAuthTag(buffer: Buffer): void;
setAutoPadding(auto_padding?: boolean): crypto$Cipher;
update(
data: string,
input_encoding: 'utf8'| 'ascii' | 'binary',
output_encoding: 'binary' | 'base64' | 'hex'
): string;
update(
data: string,
input_encoding: 'utf8'| 'ascii' | 'binary',
output_encoding: void
): Buffer;
update(
data: Buffer,
input_encoding: void,
output_encoding: 'binary' | 'base64' | 'hex'
): string;
update(
data: Buffer,
input_encoding: void,
output_encoding: void
): Buffer;
}
declare class crypto$Hash extends stream$Duplex {
digest(encoding: 'hex' | 'binary' | 'base64'): string;
digest(encoding: void): Buffer;
update(data: Buffer, input_encoding?: void): crypto$Hash;
update(data: string, input_encoding?: 'utf8' | 'ascii' | 'binary'): crypto$Hash;
}
declare class crypto$Hmac extends stream$Duplex {
digest(encoding: 'hex' | 'binary' | 'base64'): string;
digest(encoding: void): Buffer;
update(data: Buffer, input_encoding?: void): crypto$Hmac;
update(data: string, input_encoding?: 'utf8' | 'ascii' | 'binary'): crypto$Hmac;
}
type crypto$Sign$private_key = string | {
key: string,
passphrase: string,
}
declare class crypto$Sign extends stream$Writable {
sign(
private_key: crypto$Sign$private_key,
output_format: 'binary' | 'hex' | 'base64'
): string;
sign(
private_key: crypto$Sign$private_key,
output_format: void
): Buffer;
update(data: Buffer, input_encoding?: void): crypto$Sign;
update(data: string, input_encoding?: 'utf8' | 'ascii' | 'binary'): crypto$Sign;
}
declare class crypto$Verify extends stream$Writable {
update(data: Buffer, input_encoding?: void): crypto$Verify;
update(data: string, input_encoding?: 'utf8' | 'ascii' | 'binary'): crypto$Verify;
verify(
object: string,
signature: string,
signature_format: 'binary' | 'hex' | 'base64'
): boolean;
verify(object: string, signature: Buffer, signature_format: void): boolean;
}
declare module "crypto" {
declare var DEFAULT_ENCODING: string;
declare function createCipher(algorithm: string, password: string | Buffer): crypto$Cipher;
declare function createCipheriv(
algorithm: string,
key: string | Buffer,
iv: string | Buffer
): crypto$Cipher;
declare function createCredentials(
details?: crypto$createCredentialsDetails
): crypto$Credentials
declare function createDecipher(algorithm: string, password: string | Buffer): crypto$Decipher;
declare function createDecipheriv(
algorithm: string,
key: string | Buffer,
iv: string | Buffer
): crypto$Decipher;
declare function createDiffieHellman(prime_length: number): crypto$DiffieHellman;
declare function createDiffieHellman(prime: number, encoding?: string): crypto$DiffieHellman;
declare function createHash(algorithm: string): crypto$Hash;
declare function createHmac(algorithm: string, key: string | Buffer): crypto$Hmac;
declare function createSign(algorithm: string): crypto$Sign;
declare function createVerify(algorithm: string): crypto$Verify;
declare function getCiphers(): Array<string>;
declare function getDiffieHellman(group_name: string): crypto$DiffieHellman;
declare function getHashes(): Array<string>;
declare function pbkdf2(
password: string | Buffer,
salt: string | Buffer,
iterations: number,
keylen: number,
digestOrCallback: string | ((err: ?Error, derivedKey: Buffer) => void),
callback?: (err: ?Error, derivedKey: Buffer) => void
): void;
declare function pbkdf2Sync(
password: string | Buffer,
salt: string | Buffer,
iterations: number,
keylen: number,
digest?: string
): Buffer;
// `UNUSED` argument strictly enforces arity to enable overloading this
// function with 1-arg and 2-arg variants.
declare function pseudoRandomBytes(size: number, UNUSED: void): Buffer;
declare function pseudoRandomBytes(
size: number,
callback: (err: ?Error, buffer: Buffer) => void
): void;
// `UNUSED` argument strictly enforces arity to enable overloading this
// function with 1-arg and 2-arg variants.
declare function randomBytes(size: number, UNUSED: void): Buffer;
declare function randomBytes(
size: number,
callback: (err: ?Error, buffer: Buffer) => void
): void;
}
type net$Socket$address = {address: string; family: string; port: number};
type dgram$Socket = {
addMembership(multicastAddress: string, multicastInterface?: string): void;
address(): net$Socket$address;
bind(port: number, address?: string, callback?: () => void): void;
close(): void;
dropMembership(multicastAddress: string, multicastInterface?: string): void;
ref(): void;
send(
buf: Buffer,
offset: number,
length: number,
port: number,
address: string,
callback?: (err: ?Error, bytes: any) => void
): void;
setBroadcast(flag: boolean): void;
setMulticastLoopback(flag: boolean): void;
setMulticastTTL(ttl: number): void;
setTTL(ttl: number): void;
unref(): void;
};
declare module "dgram" {
declare function createSocket(type: string, callback?: () => void): dgram$Socket;
}
declare module "dns" {
declare var ADDRGETNETWORKPARAMS: string;
declare var BADFAMILY: string;
declare var BADFLAGS: string;
declare var BADHINTS: string;
declare var BADQUERY: string;
declare var BADNAME: string;
declare var BADRESP: string;
declare var BADSTR: string;
declare var CANCELLED: string;
declare var CONNREFUSED: string;
declare var DESTRUCTION: string;
declare var EOF: string;
declare var FILE: string;
declare var FORMER: string;
declare var LOADIPHLPAPI: string;
declare var NODATA: string;
declare var NOMEM: string;
declare var NONAME: string;
declare var NOTFOUND: string;
declare var NOTIMP: string;
declare var NOTINITIALIZED: string;
declare var REFUSED: string;
declare var SERVFAIL: string;
declare var TIMEOUT: string;
declare function lookup(
domain: string,
family?: ?number,
callback?: (err: ?Error, address: string, family: number) => void
): void;
declare function resolve(
domain: string,
rrtype?: string,
callback?: (err: ?Error, addresses: Array<any>) => void
): void;
declare function resolve4(
domain: string,
callback: (err: ?Error, addresses: Array<any>) => void
): void;
declare function resolve6(
domain: string,
callback: (err: ?Error, addresses: Array<any>) => void
): void;
declare function resolveCname(
domain: string,
callback: (err: ?Error, addresses: Array<any>) => void
): void;
declare function resolveMx(
domain: string,
callback: (err: ?Error, addresses: Array<any>) => void
): void;
declare function resolveNs(
domain: string,
callback: (err: ?Error, addresses: Array<any>) => void
): void;
declare function resolveSrv(
domain: string,
callback: (err: ?Error, addresses: Array<any>) => void
): void;
declare function resolveTxt(
domain: string,
callback: (err: ?Error, addresses: Array<any>) => void
): void;
declare function reverse(
ip: string,
callback: (err: ?Error, domains: Array<any>) => void
): void;
}
declare class events$EventEmitter {
// deprecated
static listenerCount(emitter: events$EventEmitter, event: string): number;
addListener(event: string, listener: Function): events$EventEmitter;
emit(event: string, ...args:Array<any>): boolean;
eventNames(): Array<string>;
listeners(event: string): Array<Function>;
listenerCount(event: string): number;
on(event: string, listener: Function): events$EventEmitter;
once(event: string, listener: Function): events$EventEmitter;
prependListener(event: string, listener: Function): events$EventEmitter;
prependOnceListener(event: string, listener: Function): events$EventEmitter;
removeAllListeners(event?: string): events$EventEmitter;
removeListener(event: string, listener: Function): events$EventEmitter;
setMaxListeners(n: number): void;
getMaxListeners(): number;
}
declare module "events" {
// TODO: See the comment above the events$EventEmitter declaration
declare class EventEmitter extends events$EventEmitter {
static EventEmitter: typeof EventEmitter;
}
declare var exports: typeof EventEmitter;
}
declare class domain$Domain extends events$EventEmitter {
members: Array<any>;
add(emitter: events$EventEmitter): void;
bind(callback: Function): Function;
dispose(): void;
enter(): void;
exit(): void;
intercept(callback: Function): Function;
remove(emitter: events$EventEmitter): void;
run(fn: Function): void;
}
declare module "domain" {
declare function create(): domain$Domain;
}
declare module "fs" {
declare class Stats {
dev: number;
ino: number;
mode: number;
nlink: number;
uid: number;
gid: number;
rdev: number;
size: number;
blksize: number;
blocks: number;
atime: Date;
mtime: Date;
ctime: Date;
isFile(): boolean;
isDirectory(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
}
declare class FSWatcher extends events$EventEmitter {
close(): void
}
declare class ReadStream extends stream$Readable {
close(): void
}
declare class WriteStream extends stream$Writable {
close(): void
}
declare function rename(oldPath: string, newPath: string, callback?: (err: ?ErrnoError) => void): void;
declare function renameSync(oldPath: string, newPath: string): void;
declare function ftruncate(fd: number, len: number, callback?: (err: ?ErrnoError) => void): void;
declare function ftruncateSync(fd: number, len: number): void;
declare function truncate(path: string, len: number, callback?: (err: ?ErrnoError) => void): void;
declare function truncateSync(path: string, len: number): void;
declare function chown(path: string, uid: number, gid: number, callback?: (err: ?ErrnoError) => void): void;
declare function chownSync(path: string, uid: number, gid: number): void;
declare function fchown(fd: number, uid: number, gid: number, callback?: (err: ?ErrnoError) => void): void;
declare function fchownSync(fd: number, uid: number, gid: number): void;
declare function lchown(path: string, uid: number, gid: number, callback?: (err: ?ErrnoError) => void): void;
declare function lchownSync(path: string, uid: number, gid: number): void;
declare function chmod(path: string, mode: number | string, callback?: (err: ?ErrnoError) => void): void;
declare function chmodSync(path: string, mode: number | string): void;
declare function fchmod(fd: number, mode: number | string, callback?: (err: ?ErrnoError) => void): void;
declare function fchmodSync(fd: number, mode: number | string): void;
declare function lchmod(path: string, mode: number | string, callback?: (err: ?ErrnoError) => void): void;
declare function lchmodSync(path: string, mode: number | string): void;
declare function stat(path: string, callback?: (err: ?ErrnoError, stats: Stats) => any): void;
declare function statSync(path: string): Stats;
declare function fstat(fd: number, callback?: (err: ?ErrnoError, stats: Stats) => any): void;
declare function fstatSync(fd: number): Stats;
declare function lstat(path: string, callback?: (err: ?ErrnoError, stats: Stats) => any): void;
declare function lstatSync(path: string): Stats;
declare function link(srcpath: string, dstpath: string, callback?: (err: ?ErrnoError) => void): void;
declare function linkSync(srcpath: string, dstpath: string): void;
declare function symlink(srcpath: string, dtspath: string, type?: string, callback?: (err: ?ErrnoError) => void): void;
declare function symlinkSync(srcpath: string, dstpath: string, type: string): void;
declare function readlink(path: string, callback: (err: ?ErrnoError, linkString: string) => void): void;
declare function readlinkSync(path: string): string;
declare function realpath(path: string, cache?: Object, callback?: (err: ?ErrnoError, resolvedPath: string) => void): void;
declare function realpathSync(path: string, cache?: Object): string;
declare function unlink(path: string, callback?: (err: ?ErrnoError) => void): void;
declare function unlinkSync(path: string): void;
declare function rmdir(path: string, callback?: (err: ?ErrnoError) => void): void;
declare function rmdirSync(path: string): void;
declare function mkdir(path: string, mode?: number, callback?: (err: ?ErrnoError) => void): void;
declare function mkdirSync(path: string, mode?: number): void;
declare function mkdtemp(prefix: string, callback: (err: ?ErrnoError, folderPath: string) => void): void;
declare function mkdtempSync(prefix: string): string;
declare function readdir(path: string, callback?: (err: ?ErrnoError, files: Array<string>) => void): void;
declare function readdirSync(path: string): Array<string>;
declare function close(fd: number, callback?: (err: ?ErrnoError) => void): void;
declare function closeSync(fd: number): void;
declare function open(path: string | Buffer, flags: string | number, mode?: number, callback?: (err: ?ErrnoError, fd: number) => void): void;
declare function openSync(path: string | Buffer, flags: string | number, mode?: number): number;
declare function utimes(path: string, atime: number, mtime: number, callback?: (err: ?ErrnoError) => void): void;
declare function utimesSync(path: string, atime: number, mtime: number): void;
declare function futimes(fd: number, atime: number, mtime: number, callback?: (err: ?ErrnoError) => void): void;
declare function futimesSync(fd: number, atime: number, mtime: number): void;
declare function fsync(fd: number, callback?: (err: ?ErrnoError) => void): void;
declare function fsyncSync(fd: number): void;
declare var write: (fd: number, buffer: Buffer, offset: number, length: number, position?: mixed, callback?: (err: ?ErrnoError, write: number, str: string) => void) => void
| (fd: number, data: mixed, position?: mixed, encoding?: string, callback?: (err: ?ErrnoError, write: number, str: string) => void) => void;
declare var writeSync: (fd: number, buffer: Buffer, offset: number, length: number, position?: number) => number
| (fd: number, data: mixed, position?: mixed, encoding?: string) => number;
declare function read(
fd: number,
buffer: Buffer,
offset: number,
length: number,
position: ?number,
callback?: (err: ?ErrnoError, bytesRead: number, buffer: Buffer) => void
): void;
declare function readSync(
fd: number,
buffer: Buffer,
offset: number,
length: number,
position: number
): number;
declare function readFile(
filename: string,
callback: (err: ?ErrnoError, data: Buffer) => void
): void;
declare function readFile(
filename: string,
encoding: string,
callback: (err: ?ErrnoError, data: string) => void
): void;
declare function readFile(
filename: string,
options: { encoding: string; flag?: string },
callback: (err: ?ErrnoError, data: string) => void
): void;
declare function readFile(
filename: string,
options: { flag?: string },
callback: (err: ?ErrnoError, data: Buffer) => void
): void;
declare function readFileSync(filename: string, _: void): Buffer;
declare function readFileSync(filename: string, encoding: string): string;
declare function readFileSync(filename: string, options: { encoding: string, flag?: string }): string;
declare function readFileSync(filename: string, options: { encoding?: void, flag?: string }): Buffer;
declare function writeFile(
filename: string,
data: Buffer | string,
options?: Object | string,
callback?: (err: ?ErrnoError) => void
): void;
declare function writeFileSync(
filename: string,
data: Buffer | string,
options?: Object | string
): void;
declare function appendFile(filename: string, data: string | Buffer, options?: Object, callback?: (err: ?ErrnoError) => void): void;
declare function appendFileSync(filename: string, data: string | Buffer, options?: Object): void;
declare function watchFile(filename: string, options?: Object, listener?: (curr: Stats, prev: Stats) => void): void;
declare function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void;
declare function watch(filename: string, options?: Object, listener?: (event: string, filename: string) => void): FSWatcher;
declare function exists(path: string, callback?: (exists: boolean) => void): void;
declare function existsSync(path: string): boolean;
declare function access(path: string, mode?: any, callback?: (err: ?ErrnoError) => void): void;
declare function accessSync(path: string, mode?: any): void;
declare function createReadStream(path: string, options?: Object): ReadStream;
declare function createWriteStream(path: string, options?: Object): WriteStream;
declare var F_OK: number;
declare var R_OK: number;
declare var W_OK: number;
declare var X_OK: number;
}
declare class http$IncomingMessage extends stream$Readable {
headers: Object;
httpVersion: string;
method: string;
trailers: Object;
setTimeout(msecs: number, callback: Function): void;
socket: net$Socket;
statusCode: number;
url: string;
}
declare class http$ClientRequest extends stream$Writable {
flushHeaders(): void;
abort(): void;
setHeader(name: string, value: string | Array<string>): void;
setTimeout(msecs: number, callback?: Function): void;
setNoDelay(noDelay?: boolean): void;
setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
}
declare class http$ServerResponse extends stream$Writable {
addTrailers(headers: {[key: string] : string}): void;
finished: boolean;
getHeader(name: string): void;
headersSent: boolean;
removeHeader(name: string): void;
sendDate: boolean;
setHeader(name: string, value: string | Array<string>): void;
setTimeout(msecs: number, callback?: Function): http$ServerResponse;
statusCode: number;
statusMessage: string;
writeContinue(): void;
writeHead(status: number, statusMessage?: string, headers?: {[key: string] : string}): void;
writeHead(status: number, headers?: {[key: string] : string}): void;
}
declare module "http" {
declare class Server extends net$Server {
listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server;
listen(path: string, callback?: Function): Server;
listen(handle: Object, callback?: Function): Server;
close(callback?: Function): Server;
maxHeadersCount: number;
setTimeout(msecs: number, callback: Function): Server;
timeout: number;
}
declare class ClientRequest extends http$ClientRequest {}
declare class IncomingMessage extends http$IncomingMessage {}
declare class ServerResponse extends http$ServerResponse {}
declare function createServer(
requestListener?: (request: IncomingMessage, response: ServerResponse) => void
): Server;
declare function request(
options: Object | string,
callback?: (response: IncomingMessage) => void
): ClientRequest;
declare function get(
options: Object | string,
callback?: (response: IncomingMessage) => void
): ClientRequest;
}
declare module "https" {
declare class Server extends tls$Server {
listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server;
listen(path: string, callback?: Function): Server;
listen(handle: Object, callback?: Function): Server;
close(callback?: Function): Server;
setTimeout(msecs: number, callback: Function): Server;
timeout: number;
}
declare class ClientRequest extends http$ClientRequest {}
declare class IncomingMessage extends http$IncomingMessage {}
declare class ServerResponse extends http$ServerResponse {}
declare function createServer(
options: Object,
requestListener?: (request: IncomingMessage, response: ServerResponse) => void
): Server;
declare function request(
options: Object | string,
callback?: (response: IncomingMessage) => void
): ClientRequest;
declare function get(
options: Object | string,
callback?: (response: IncomingMessage) => void
): ClientRequest;
}
declare class net$Socket extends stream$Duplex {
constructor(options?: Object): void;
address(): net$Socket$address;
bufferSize: number;
bytesRead: number;
bytesWritten: number;
connect(options: Object, connectListener?: function): void;
destroy(): void;
end(
chunk?: string | Buffer,
encodingOrCallback?: string | (data: any) => void,
callback?: (data: any) => void
): void;
localAddress: string;
localPort: number;
pause(): stream$Readable;
ref(): net$Socket;
remoteAddress: string | void;
remoteFamily: string;
remotePort: number;
resume(): stream$Readable;
setEncoding(encoding?: string): stream$Readable;
setKeepAlive(enable?: boolean, initialDelay?: number): net$Socket;
setNoDelay(noDelay?: boolean): net$Socket;
setTimeout(timeout: number, callback?: function): net$Socket;
unref(): net$Socket;
write(
chunk?: string | Buffer,
encodingOrCallback?: string | (data: any) => void,
callback?: (data: any) => void
): boolean;
}
declare class net$Server extends events$EventEmitter {
listen(port: number, hostname?: string, backlog?: number, callback?: Function): net$Server;
listen(path: string, callback?: Function): net$Server;
listen(handle: Object, callback?: Function): net$Server;
close(callback?: Function): net$Server;
address(): net$Socket$address;
connections: number;
maxConnections: number;
getConnections(callback: Function): void;
ref(): net$Server;
unref(): net$Server;
}
type net$connectOptions = {
port?: number,
host?: string,
localAddress?: string,
localPort?: number,
family?: number,
lookup?: string,
path?: string,
};
declare module "net" {
declare class Server extends net$Server {}
declare class Socket extends net$Socket {}
declare function isIP(input: string): number;
declare function isIPv4(input: string): boolean;
declare function isIPv6(input: string): boolean;
declare type connectionListener = (socket: Socket) => any;
declare function createServer(
options?: {
allowHalfOpen?: boolean,
pauseOnConnect?: boolean,
} | connectionListener,
connectionListener?: connectionListener,
): Server;
declare type connectListener = () => any;
declare function connect(
pathOrPortOrOptions: string | number | net$connectOptions,
hostOrConnectListener?: string | connectListener,
connectListener?: connectListener,
): Socket;
declare function createConnection(
pathOrPortOrOptions: string | number | net$connectOptions,
hostOrConnectListener?: string | connectListener,
connectListener?: connectListener,
): Socket;
}
type os$CPU = {
model: string,
speed: number,
times: {
idle: number,
irq: number,
nice: number,
sys: number,
user: number,
}
};
type os$NetIFAddr = {
address: string,
family: string,
internal: boolean,
mac: string,
netmask: string
};
declare module "os" {
declare function arch(): "x64"|"arm"|"ia32";
declare function cpus(): Array<os$CPU>;
declare function endianness(): "BE"|"LE";
declare function freemem(): number;
declare function homedir(): string;
declare function hostname(): string;
declare function loadavg(): [number, number, number];
declare function networkInterfaces(): {[ifName: string]: Array<os$NetIFAddr>};
declare function platform(): string;
declare function release(): string;
declare function tmpdir(): string;
declare function totalmem(): number;
declare function type(): string;
declare function uptime(): number;