Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/third_party/closure-compiler/node-externs/fs.js
6172 views
1
/*
2
* Copyright 2012 The Closure Compiler Authors.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
/**
18
* @fileoverview Definitions for node's fs module. Depends on the stream and events module.
19
* @see http://nodejs.org/api/fs.html
20
* @see https://github.com/joyent/node/blob/master/lib/fs.js
21
* @externs
22
* @author Daniel Wirtz <[email protected]>
23
*/
24
25
/**
26
BEGIN_NODE_INCLUDE
27
var fs = require('fs');
28
END_NODE_INCLUDE
29
*/
30
31
var fs = {};
32
33
/**
34
* @param {string} oldPath
35
* @param {string} newPath
36
* @param {function(...)=} callback
37
*/
38
fs.rename = function(oldPath, newPath, callback) {};
39
40
/**
41
* @param {string} oldPath
42
* @param {string} newPath
43
*/
44
fs.renameSync = function(oldPath, newPath) {};
45
46
/**
47
* @param {*} fd
48
* @param {number} len
49
* @param {function(...)=} callback
50
*/
51
fs.truncate = function(fd, len, callback) {};
52
53
/**
54
* @param {*} fd
55
* @param {number} len
56
*/
57
fs.truncateSync = function(fd, len) {};
58
59
/**
60
* @param {*} fd
61
* @param {number} len
62
*/
63
fs.ftruncateSync = function(fd, len) {};
64
65
/**
66
* @param {string} path
67
* @param {number} uid
68
* @param {number} gid
69
* @param {function(...)=} callback
70
*/
71
fs.chown = function(path, uid, gid, callback) {};
72
73
/**
74
* @param {string} path
75
* @param {number} uid
76
* @param {number} gid
77
*/
78
fs.chownSync = function(path, uid, gid) {};
79
80
/**
81
* @param {*} fd
82
* @param {number} uid
83
* @param {number} gid
84
* @param {function(...)=} callback
85
*/
86
fs.fchown = function(fd, uid, gid, callback) {};
87
88
/**
89
* @param {*} fd
90
* @param {number} uid
91
* @param {number} gid
92
*/
93
fs.fchownSync = function(fd, uid, gid) {};
94
95
/**
96
* @param {string} path
97
* @param {number} uid
98
* @param {number} gid
99
* @param {function(...)=} callback
100
*/
101
fs.lchown = function(path, uid, gid, callback) {};
102
103
/**
104
* @param {string} path
105
* @param {number} uid
106
* @param {number} gid
107
*/
108
fs.lchownSync = function(path, uid, gid) {};
109
110
/**
111
* @param {string} path
112
* @param {number} mode
113
* @param {function(...)=} callback
114
*/
115
fs.chmod = function(path, mode, callback) {};
116
117
/**
118
* @param {string} path
119
* @param {number} mode
120
*/
121
fs.chmodSync = function(path, mode) {};
122
123
/**
124
* @param {*} fd
125
* @param {number} mode
126
* @param {function(...)=} callback
127
*/
128
fs.fchmod = function(fd, mode, callback) {};
129
130
/**
131
* @param {*} fd
132
* @param {number} mode
133
*/
134
fs.fchmodSync = function(fd, mode) {};
135
136
/**
137
* @param {string} path
138
* @param {number} mode
139
* @param {function(...)=} callback
140
*/
141
fs.lchmod = function(path, mode, callback) {};
142
143
/**
144
* @param {string} path
145
* @param {number} mode
146
*/
147
fs.lchmodSync = function(path, mode) {};
148
149
/**
150
* @param {string} path
151
* @param {function(string, fs.Stats)=} callback
152
*/
153
fs.stat = function(path, callback) {};
154
155
/**
156
* @param {string} path
157
* @return {fs.Stats}
158
* @nosideeffects
159
*/
160
fs.statSync = function(path) {}
161
162
/**
163
* @param {*} fd
164
* @param {function(string, fs.Stats)=} callback
165
*/
166
fs.fstat = function(fd, callback) {};
167
168
/**
169
* @param {*} fd
170
* @return {fs.Stats}
171
* @nosideeffects
172
*/
173
fs.fstatSync = function(fd) {}
174
175
/**
176
* @param {string} path
177
* @param {function(string, fs.Stats)=} callback
178
*/
179
fs.lstat = function(path, callback) {};
180
181
/**
182
* @param {string} path
183
* @return {fs.Stats}
184
* @nosideeffects
185
*/
186
fs.lstatSync = function(path) {}
187
188
/**
189
* @param {string} srcpath
190
* @param {string} dstpath
191
* @param {function(...)=} callback
192
*/
193
fs.link = function(srcpath, dstpath, callback) {};
194
195
/**
196
* @param {string} srcpath
197
* @param {string} dstpath
198
*/
199
fs.linkSync = function(srcpath, dstpath) {};
200
201
/**
202
* @param {string} srcpath
203
* @param {string} dstpath
204
* @param {string=} type
205
* @param {function(...)=} callback
206
*/
207
fs.symlink = function(srcpath, dstpath, type, callback) {};
208
209
/**
210
* @param {string} srcpath
211
* @param {string} dstpath
212
* @param {string=} type
213
*/
214
fs.symlinkSync = function(srcpath, dstpath, type) {};
215
216
/**
217
* @param {string} path
218
* @param {function(string, string)=} callback
219
*/
220
fs.readlink = function(path, callback) {};
221
222
/**
223
* @param {string} path
224
* @return {string}
225
* @nosideeffects
226
*/
227
fs.readlinkSync = function(path) {};
228
229
/**
230
* @param {string} path
231
* @param {Object.<string,string>|function(string, string)=} cache
232
* @param {function(string, string)=} callback
233
*/
234
fs.realpath = function(path, cache, callback) {};
235
236
/**
237
* @param {string} path
238
* @param {Object.<string,string>=} cache
239
* @return {string}
240
* @nosideeffects
241
*/
242
fs.realpathSync = function(path, cache) {};
243
244
/**
245
* @param {string} path
246
* @param {function(...)=} callback
247
*/
248
fs.unlink = function(path, callback) {};
249
250
/**
251
* @param {string} path
252
*/
253
fs.unlinkSync = function(path) {};
254
255
/**
256
* @param {string} path
257
* @param {function(...)=} callback
258
*/
259
fs.rmdir = function(path, callback) {};
260
261
/**
262
* @param {string} path
263
*/
264
fs.rmdirSync = function(path) {};
265
266
/**
267
* @param {string} path
268
* @param {number=} mode
269
* @param {function(...)=} callback
270
*/
271
fs.mkdir = function(path, mode, callback) {};
272
273
/**
274
* @param {string} path
275
* @param {number=} mode
276
*/
277
fs.mkdirSync = function(path, mode) {};
278
279
/**
280
* @param {string} path
281
* @param {function(string,Array.<string>)=} callback
282
*/
283
fs.readdir = function(path, callback) {};
284
285
/**
286
* @param {string} path
287
* @return {Array.<string>}
288
* @nosideeffects
289
*/
290
fs.readdirSync = function(path) {};
291
292
/**
293
* @param {*} fd
294
* @param {function(...)=} callback
295
*/
296
fs.close = function(fd, callback) {};
297
298
/**
299
* @param {*} fd
300
*/
301
fs.closeSync = function(fd) {};
302
303
/**
304
* @param {string} path
305
* @param {string} flags
306
* @param {number=} mode
307
* @param {function(string, *)=} callback
308
*/
309
fs.open = function(path, flags, mode, callback) {};
310
311
/**
312
* @param {string} path
313
* @param {string} flags
314
* @param {number=} mode
315
* @return {*}
316
* @nosideeffects
317
*/
318
fs.openSync = function(path, flags, mode) {};
319
320
/**
321
* @param {string} path
322
* @param {number|Date} atime
323
* @param {number|Date} mtime
324
* @param {function(...)=} callback
325
*/
326
fs.utimes = function(path, atime, mtime, callback) {};
327
328
/**
329
* @param {string} path
330
* @param {number|Date} atime
331
* @param {number|Date} mtime
332
* @nosideeffects
333
*/
334
fs.utimesSync = function(path, atime, mtime) {};
335
336
/**
337
* @param {*} fd
338
* @param {number|Date} atime
339
* @param {number|Date} mtime
340
* @param {function(...)=} callback
341
*/
342
fs.futimes = function(fd, atime, mtime, callback) {};
343
344
/**
345
* @param {*} fd
346
* @param {number|Date} atime
347
* @param {number|Date} mtime
348
* @nosideeffects
349
*/
350
fs.futimesSync = function(fd, atime, mtime) {};
351
352
/**
353
* @param {*} fd
354
* @param {function(...)=} callback
355
*/
356
fs.fsync = function(fd, callback) {};
357
358
/**
359
* @param {*} fd
360
*/
361
fs.fsyncSync = function(fd) {};
362
363
/**
364
* @param {*} fd
365
* @param {*} buffer
366
* @param {number} offset
367
* @param {number} length
368
* @param {number} position
369
* @param {function(string, number, *)=} callback
370
*/
371
fs.write = function(fd, buffer, offset, length, position, callback) {};
372
373
/**
374
* @param {*} fd
375
* @param {*} buffer
376
* @param {number=} offset
377
* @param {number=} length
378
* @param {number=} position
379
* @return {number}
380
*/
381
fs.writeSync = function(fd, buffer, offset, length, position) {};
382
383
/**
384
* @param {*} fd
385
* @param {*} buffer
386
* @param {number} offset
387
* @param {number} length
388
* @param {number} position
389
* @param {function(string, number, *)=} callback
390
*/
391
fs.read = function(fd, buffer, offset, length, position, callback) {};
392
393
/**
394
* @param {*} fd
395
* @param {*} buffer
396
* @param {number} offset
397
* @param {number} length
398
* @param {number=} position
399
* @return {number}
400
* @nosideeffects
401
*/
402
fs.readSync = function(fd, buffer, offset, length, position) {};
403
404
/**
405
* @param {string} filename
406
* @param {string|{encoding:(string|undefined),flag:(string|undefined)}|function(string, (string|nodeBuffer.Buffer))=} encodingOrOptions
407
* @param {function(string, (string|nodeBuffer.Buffer))=} callback
408
*/
409
fs.readFile = function(filename, encodingOrOptions, callback) {};
410
411
/**
412
* @param {string} filename
413
* @param {string|{encoding:(string|undefined),flag:(string|undefined)}=} encodingOrOptions
414
* @return {string|nodeBuffer.Buffer}
415
* @nosideeffects
416
*/
417
fs.readFileSync = function(filename, encodingOrOptions) {};
418
419
/**
420
* @param {string} filename
421
* @param {*} data
422
* @param {string|{encoding:(string|undefined),mode:(number|undefined),flag:(string|undefined)}|function(string)=} encodingOrOptions
423
* @param {function(string)=} callback
424
*/
425
fs.writeFile = function(filename, data, encodingOrOptions, callback) {};
426
427
/**
428
* @param {string} filename
429
* @param {*} data
430
* @param {string|{encoding:(string|undefined),mode:(number|undefined),flag:(string|undefined)}|function(string)=} encodingOrOptions
431
*/
432
fs.writeFileSync = function(filename, data, encodingOrOptions) {};
433
434
/**
435
* @param {string} filename
436
* @param {*} data
437
* @param {string|function(string)=} encoding
438
* @param {function(string)=} callback
439
*/
440
fs.appendFile = function(filename, data, encoding, callback) {};
441
442
/**
443
* @param {string} filename
444
* @param {*} data
445
* @param {string|function(string)=} encoding
446
*/
447
fs.appendFileSync = function(filename, data, encoding) {};
448
449
/**
450
* @param {string} filename
451
* @param {{persistent: boolean, interval: number}|function(*,*)=} options
452
* @param {function(*,*)=} listener
453
*/
454
fs.watchFile = function(filename, options, listener) {};
455
456
/**
457
* @param {string} filename
458
* @param {function(string, string)=} listener
459
*/
460
fs.unwatchFile = function(filename, listener) {};
461
462
/**
463
*
464
* @param {string} filename
465
* @param {{persistent: boolean}|function(string, string)=} options
466
* @param {function(string, string)=} listener
467
* @return {fs.FSWatcher}
468
*/
469
fs.watch = function(filename, options, listener) {};
470
471
/**
472
* @param {string} path
473
* @param {function(boolean)} callback
474
*/
475
fs.exists = function(path, callback) {};
476
477
/**
478
* @param {string} path
479
* @nosideeffects
480
*/
481
fs.existsSync = function(path) {};
482
483
/**
484
* @constructor
485
*/
486
fs.Stats = function() {};
487
488
/**
489
* @return {boolean}
490
* @nosideeffects
491
*/
492
fs.Stats.prototype.isFile = function() {};
493
494
/**
495
* @return {boolean}
496
* @nosideeffects
497
*/
498
fs.Stats.prototype.isDirectory = function() {};
499
500
/**
501
* @return {boolean}
502
* @nosideeffects
503
*/
504
fs.Stats.prototype.isBlockDevice = function() {};
505
506
/**
507
* @return {boolean}
508
* @nosideeffects
509
*/
510
fs.Stats.prototype.isCharacterDevice = function() {};
511
512
/**
513
* @return {boolean}
514
* @nosideeffects
515
*/
516
fs.Stats.prototype.isSymbolicLink = function() {};
517
518
/**
519
* @return {boolean}
520
* @nosideeffects
521
*/
522
fs.Stats.prototype.isFIFO = function() {};
523
524
/**
525
* @return {boolean}
526
* @nosideeffects
527
*/
528
fs.Stats.prototype.isSocket = function() {};
529
530
/**
531
* @type {number}
532
*/
533
fs.Stats.prototype.dev = 0;
534
535
/**
536
* @type {number}
537
*/
538
fs.Stats.prototype.ino = 0;
539
540
/**
541
* @type {number}
542
*/
543
fs.Stats.prototype.mode = 0;
544
545
/**
546
* @type {number}
547
*/
548
fs.Stats.prototype.nlink = 0;
549
550
/**
551
* @type {number}
552
*/
553
fs.Stats.prototype.uid = 0;
554
555
/**
556
* @type {number}
557
*/
558
fs.Stats.prototype.gid = 0;
559
560
/**
561
* @type {number}
562
*/
563
fs.Stats.prototype.rdev = 0;
564
565
/**
566
* @type {number}
567
*/
568
fs.Stats.prototype.size = 0;
569
570
/**
571
* @type {number}
572
*/
573
fs.Stats.prototype.blkSize = 0;
574
575
/**
576
* @type {number}
577
*/
578
fs.Stats.prototype.blocks = 0;
579
580
/**
581
* @type {Date}
582
*/
583
fs.Stats.prototype.atime;
584
585
/**
586
* @type {Date}
587
*/
588
fs.Stats.prototype.mtime;
589
590
/**
591
* @type {Date}
592
*/
593
fs.Stats.prototype.ctime;
594
595
/**
596
* @param {string} path
597
* @param {{flags: string, encoding: ?string, fd: *, mode: number, bufferSize: number}=} options
598
* @return {fs.ReadStream}
599
* @nosideeffects
600
*/
601
fs.createReadStream = function(path, options) {};
602
603
/**
604
* @constructor
605
* @extends stream.ReadableStream
606
*/
607
fs.ReadStream = function() {};
608
609
/**
610
* @param {string} path
611
* @param {{flags: string, encoding: ?string, mode: number}=} options
612
* @return {fs.WriteStream}
613
* @nosideeffects
614
*/
615
fs.createWriteStream = function(path, options) {};
616
617
/**
618
* @constructor
619
* @extends stream.WritableStream
620
*/
621
fs.WriteStream = function() {};
622
623
/**
624
* @constructor
625
* @extends events.EventEmitter
626
*/
627
fs.FSWatcher = function() {};
628
629
/**
630
*/
631
fs.FSWatcher.prototype.close = function() {};
632
633