@@ -5,6 +5,7 @@ import io.scalajs.util.PromiseHelper._
5
5
6
6
import scala .concurrent .Promise
7
7
import scala .scalajs .js
8
+ import scala .scalajs .js .typedarray .Uint8Array
8
9
import scala .scalajs .js .|
9
10
10
11
/**
@@ -124,6 +125,27 @@ package object fs {
124
125
def watchAsync (filename : String , options : FSWatcherOptions = null ): Promise [(String , String )] =
125
126
promiseCallback2[String , String ](fs.watch(filename, options, _))
126
127
128
+ @ inline
129
+ def writeAsync (fd : FileDescriptor ,
130
+ buffer : Buffer | Uint8Array ,
131
+ offset : Integer = null ,
132
+ length : Integer = null ,
133
+ position : Integer = null ): Promise [(FileType , Buffer )] = {
134
+ promiseWithError2[FileIOError , Int , Buffer ](fs.write(fd, buffer, offset, length, position, _))
135
+ }
136
+
137
+ @ inline
138
+ def writeAsync (fd : FileDescriptor , string : String , position : Int , encoding : String ): Promise [(FileType , String )] =
139
+ promiseWithError2[FileIOError , Int , String ](fs.write(fd, string, position, encoding, _))
140
+
141
+ @ inline
142
+ def writeAsync (fd : FileDescriptor , string : String , position : Int ): Promise [(FileType , String )] =
143
+ promiseWithError2[FileIOError , Int , String ](fs.write(fd, string, position, null , _))
144
+
145
+ @ inline
146
+ def writeAsync (fd : FileDescriptor , string : String ): Promise [(FileType , String )] =
147
+ promiseWithError2[FileIOError , Int , String ](fs.write(fd, string, _))
148
+
127
149
@ inline
128
150
def writeFileAsync (file : String , data : Buffer | String , options : FileOutputOptions = null ): Promise [Unit ] =
129
151
promiseWithError0[FileIOError ](fs.writeFile(file, data, options, _))
0 commit comments