@@ -528,15 +528,17 @@ trait Fs extends js.Object with FSConstants {
528
528
def openSync (path : Path ): FileDescriptor = js.native
529
529
530
530
@ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
531
- def opendir (path : Path , options : OpendirOptions , callback : FsCallback1 [Fs .Dir ]): Unit = js.native
531
+ def opendir (path : Path , options : OpendirOptions , callback : FsCallback1 [Fs .Dir [String ] | Fs .Dir [Buffer ]]): Unit =
532
+ js.native
532
533
533
534
@ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
534
- def opendir (path : Path , callback : FsCallback1 [Fs .Dir ]): Unit = js.native
535
+ def opendir (path : Path , callback : FsCallback1 [Fs .Dir [ String ] ]): Unit = js.native
535
536
536
537
@ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12) def opendirSync (path : Path ,
537
538
options : OpendirOptions
538
- ): Fs .Dir = js.native
539
- @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12) def opendirSync (path : Path ): Fs .Dir = js.native
539
+ ): Fs .Dir [String ] | Fs .Dir [Buffer ] = js.native
540
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12) def opendirSync (path : Path ): Fs .Dir [String ] =
541
+ js.native
540
542
541
543
/** Read data from the file specified by fd.
542
544
* @param fd is the file descriptor
@@ -600,7 +602,7 @@ trait Fs extends js.Object with FSConstants {
600
602
* of the names of the files in the directory excluding '.' and '..'.
601
603
* @example fs.readdir(path[, options], callback)
602
604
*/
603
- def readdir (path : Path , options : String , callback : FsCallback1 [js. Array [ String ]] ): Unit = js.native
605
+ def readdir (path : Path , options : String , callback : FsCallback1 [ReaddirArrays ] ): Unit = js.native
604
606
def readdir (path : Path , options : FileEncodingOptions , callback : FsCallback1 [ReaddirArrays ]): Unit = js.native
605
607
def readdir (path : Path , options : ReaddirOptions , callback : FsCallback1 [ReaddirArrays2 ]): Unit = js.native
606
608
def readdir (path : Path , callback : FsCallback1 [js.Array [String ]]): Unit = js.native
@@ -613,9 +615,10 @@ trait Fs extends js.Object with FSConstants {
613
615
* to 'buffer', the filenames returned will be passed as Buffer objects.
614
616
* @return an array of filenames excluding '.' and '..'.
615
617
*/
616
- def readdirSync (path : Path , options : String ): js.Array [String ] = js.native
617
- def readdirSync (path : Path , options : ReaddirOptions ): js.Array [String ] = js.native
618
- def readdirSync (path : Path ): js.Array [String ] = js.native
618
+ def readdirSync (path : Path , options : String ): ReaddirArrays = js.native
619
+ def readdirSync (path : Path , options : FileEncodingOptions ): ReaddirArrays = js.native
620
+ def readdirSync (path : Path , options : ReaddirOptions ): ReaddirArrays2 = js.native
621
+ def readdirSync (path : Path ): js.Array [String ] = js.native
619
622
620
623
/** Asynchronously reads the entire contents of a file.
621
624
* @param file filename or file descriptor
@@ -1108,18 +1111,20 @@ object Fs extends Fs {
1108
1111
def open (path : Path ): js.Promise [FileHandle ] = js.native
1109
1112
@ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12) def opendir (path : Path ,
1110
1113
options : OpendirOptions
1111
- ): js.Promise [Dir ] = js.native
1112
- @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12) def opendir (path : Path ): js.Promise [Dir ] =
1114
+ ): js.Promise [Dir [String ] | Dir [Buffer ]] = js.native
1115
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12) def opendir (
1116
+ path : Path
1117
+ ): js.Promise [Dir [String ]] =
1113
1118
js.native
1114
- def readdir (path : Path , options : ReaddirOptions ): js.Promise [js. Array [ String ] | js. Array [ Dirent ]] = js.native
1115
- def readdir (path : Path , encoding : String ): js.Promise [js. Array [ String ]] = js.native
1116
- def readdir (path : Path , options : FileEncodingOptions ): js.Promise [js. Array [ String ]] = js.native
1117
- def readdir (path : Path ): js.Promise [js.Array [String ]] = js.native
1118
- def readlink (path : Path ): js.Promise [String ] = js.native
1119
- def readlink (path : Path , options : String ): js.Promise [Output ] = js.native
1120
- def readlink (path : Path , options : FileEncodingOptions ): js.Promise [Output ] = js.native
1121
- def rename (oldPath : Path , newPath : Path ): js.Promise [Unit ] = js.native
1122
- def rmdir (path : Path ): js.Promise [Unit ] = js.native
1119
+ def readdir (path : Path , options : ReaddirOptions ): js.Promise [ReaddirArrays2 ] = js.native
1120
+ def readdir (path : Path , encoding : String ): js.Promise [ReaddirArrays ] = js.native
1121
+ def readdir (path : Path , options : FileEncodingOptions ): js.Promise [ReaddirArrays ] = js.native
1122
+ def readdir (path : Path ): js.Promise [js.Array [String ]] = js.native
1123
+ def readlink (path : Path ): js.Promise [String ] = js.native
1124
+ def readlink (path : Path , options : String ): js.Promise [Output ] = js.native
1125
+ def readlink (path : Path , options : FileEncodingOptions ): js.Promise [Output ] = js.native
1126
+ def rename (oldPath : Path , newPath : Path ): js.Promise [Unit ] = js.native
1127
+ def rmdir (path : Path ): js.Promise [Unit ] = js.native
1123
1128
@ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
1124
1129
def rmdir (path : Path , options : RmdirOptions ): js.Promise [Unit ] = js.native
1125
1130
def stat (path : Path , options : StatOptions ): js.Promise [StatsVariant ] = js.native
@@ -1194,27 +1199,27 @@ object Fs extends Fs {
1194
1199
val promises : FsPromises = js.native
1195
1200
1196
1201
@ js.native
1197
- class Dirent () extends js.Object {
1202
+ class Dirent [ TName ] () extends js.Object {
1198
1203
def isBlockDevice (): Boolean = js.native
1199
1204
def isCharacterDevice (): Boolean = js.native
1200
1205
def isDirectory (): Boolean = js.native
1201
1206
def isFIFO (): Boolean = js.native
1202
1207
def isFile (): Boolean = js.native
1203
1208
def isSocket (): Boolean = js.native
1204
1209
def isSymbolicLink (): Boolean = js.native
1205
- val name : String | Buffer = js.native
1210
+ val name : TName = js.native
1206
1211
}
1207
1212
1208
1213
@ enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
1209
1214
@ js.native
1210
- trait Dir extends js.Object {
1211
- def close (): js.Promise [Unit ] = js.native
1212
- def close (callback : js.Function1 [js.Error , Any ]): Unit = js.native
1213
- def closeSync (): Unit = js.native
1214
- def path : String = js.native
1215
- def read (): js.Promise [Dirent ] = js.native
1216
- def read (callback : js.Function2 [js.Error , Dirent , Any ]): Unit = js.native
1217
- def readSync (): Dirent = js.native
1215
+ trait Dir [ T ] extends js.Object {
1216
+ def close (): js.Promise [Unit ] = js.native
1217
+ def close (callback : js.Function1 [js.Error , Any ]): Unit = js.native
1218
+ def closeSync (): Unit = js.native
1219
+ def path : String = js.native
1220
+ def read (): js.Promise [Dirent [ T ] ] = js.native
1221
+ def read (callback : js.Function2 [js.Error , Dirent [ T ] , Any ]): Unit = js.native
1222
+ def readSync (): Dirent [ T ] = js.native
1218
1223
1219
1224
// TODO: Implement AsyncIterable[Dirent]
1220
1225
}
0 commit comments