Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,33 @@ package object child_process {

implicit final class ChildProcessObjectExtensions(private val cp: ChildProcess.type) extends AnyVal {
@inline
def execFuture(
command: String,
options: js.UndefOr[ExecOptions] = js.undefined
): Future[(Output, Output)] = {
promiseWithError2[nodejs.Error, Output, Output](cp.exec(command, options.orNull, _))
def execFuture(command: String, options: ExecOptions): Future[(Output, Output)] = {
promiseWithError2[nodejs.Error, Output, Output](cp.exec(command, options, _))
}

@inline
def execFileFuture(
file: String,
args: js.UndefOr[js.Array[String]] = js.undefined,
options: js.UndefOr[ExecOptions] = js.undefined
): Future[(Output, Output)] = {
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, args.orNull, options.orNull, _))
def execFuture(command: String): Future[(Output, Output)] = {
promiseWithError2[nodejs.Error, Output, Output](cp.exec(command, _))
}

@inline
def execFileFuture(file: String, args: js.Array[String], options: ExecOptions): Future[(Output, Output)] = {
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, args, options, _))
}

@inline
def execFileFuture(file: String, args: js.Array[String]): Future[(Output, Output)] = {
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, args, _))
}

@inline
def execFileFuture(file: String, options: ExecOptions): Future[(Output, Output)] = {
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, options, _))
}

@inline
def execFileFuture(file: String): Future[(Output, Output)] = {
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, _))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ sealed trait Decipher extends Transform {
* The decipher.setAutoPadding() method must be called before decipher.update().
* @example decipher.setAutoPadding(auto_padding=true)
*/
def setAutoPadding(auto_padding: Boolean = true): Decipher = js.native
def setAutoPadding(auto_padding: Boolean): Decipher = js.native
def setAutoPadding(): Decipher = js.native

/**
* Updates the decipher with data. If the input_encoding argument is given, it's value must be one of 'binary',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,15 @@ package object dns {
* @param hostname the hostname
*/
@inline
def resolveFuture(hostname: String, rrtype: RRType = null): Future[ResolveResult] = {
def resolveFuture(hostname: String, rrtype: RRType): Future[ResolveResult] = {
promiseWithError1[DnsError, ResolveResult](dns.resolve(hostname, rrtype, _))
}

@inline
def resolveFuture(hostname: String): Future[js.Array[String]] = {
promiseWithError1[DnsError, js.Array[String]](dns.resolve(hostname, _))
}

/**
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of hostnames.
* The callback function has arguments (err, hostnames), where hostnames is an array of resolved hostnames for the given ip.
Expand Down
15 changes: 4 additions & 11 deletions app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/Fs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ trait Fs extends js.Object with FSConstants {
* @param length the desired length
* @return undefined.
*/
def ftruncateSync(fd: FileDescriptor, length: Int = 0): Unit = js.native
def ftruncateSync(fd: FileDescriptor, length: Int): Unit = js.native
def ftruncateSync(fd: FileDescriptor): Unit = js.native

/**
* Change the file timestamps of a file referenced by the supplied file descriptor.
Expand Down Expand Up @@ -657,18 +658,10 @@ trait Fs extends js.Object with FSConstants {
* of the names of the files in the directory excluding '.' and '..'.
* @example fs.readdir(path[, options], callback)
*/
def readdir(path: Path, options: String, callback: FsCallback1[ReaddirArrays]): Unit = js.native
def readdir(path: Path, options: String, callback: FsCallback1[js.Array[String]]): Unit = js.native
def readdir(path: Path, options: FileEncodingOptions, callback: FsCallback1[ReaddirArrays]): Unit = js.native
def readdir(path: Path, options: ReaddirOptions, callback: FsCallback1[ReaddirArrays2]): Unit = js.native

/**
* Asynchronous readdir(3). Reads the contents of a directory.
* @param path the path (Buffer | String)
* @param callback the callback gets two arguments (err, files) where files is an array
* of the names of the files in the directory excluding '.' and '..'.
* @example fs.readdir(path[, options], callback)
*/
def readdir(path: Path, callback: FsCallback1[js.Array[String]]): Unit = js.native
def readdir(path: Path, callback: FsCallback1[js.Array[String]]): Unit = js.native

/**
* Synchronous readdir(3).
Expand Down
25 changes: 16 additions & 9 deletions app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,13 @@ package object fs {
}

@inline
def readdirFuture(path: Path, encoding: String = "utf8"): Future[js.Array[String]] = {
val callback: FsCallback1[js.Array[String]] => Unit = { callback =>
instance.readdir(path, encoding, callback.asInstanceOf[FsCallback1[ReaddirArrays]])
}
promiseWithError1[FileIOError, js.Array[String]](callback)
def readdirFuture(path: Path, encoding: String): Future[js.Array[String]] = {
promiseWithError1[FileIOError, js.Array[String]](instance.readdir(path, encoding, _))
}

@inline
def readdirFuture(path: Path): Future[js.Array[String]] = {
promiseWithError1[FileIOError, js.Array[String]](instance.readdir(path, _))
}

@inline
Expand Down Expand Up @@ -453,9 +455,9 @@ package object fs {
@inline
def writeFuture(fd: FileDescriptor,
buffer: typedarray.Uint8Array,
offset: Int | Null = null,
length: Int | Null = null,
position: Int | Null = null
offset: Int | Null,
length: Int | Null,
position: Int | Null
): Future[(FileType, Buffer)] = {
promiseWithError2[FileIOError, Int, Buffer](instance.write(fd, buffer, offset, length, position, _))
}
Expand Down Expand Up @@ -486,10 +488,15 @@ package object fs {
}

@inline
def writeFileFuture(file: String, data: typedarray.Uint8Array, options: FileWriteOptions = null): Future[Unit] = {
def writeFileFuture(file: String, data: typedarray.Uint8Array, options: FileWriteOptions): Future[Unit] = {
promiseWithError0[FileIOError](instance.writeFile(file, data, options, _))
}

@inline
def writeFileFuture(file: String, data: typedarray.Uint8Array): Future[Unit] = {
promiseWithError0[FileIOError](instance.writeFile(file, data, _))
}

@inline
def writeFileFuture(file: String, data: BufferLike): Future[Unit] = {
promiseWithError0[FileIOError](instance.writeFile(file, data, _))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ class Socket(options: SocketOptions) extends stream.Duplex with HasHandle {
* @return socket
* @example socket.setKeepAlive([enable][, initialDelay])
*/
def setKeepAlive(enable: Boolean = false, initialDelay: Int = 0): this.type = js.native
def setKeepAlive(enable: Boolean, initialDelay: Int): this.type = js.native
def setKeepAlive(enable: Boolean): this.type = js.native
def setKeepAlive(initialDelay: Int): this.type = js.native
def setKeepAlive(): this.type = js.native

/**
* Disables the Nagle algorithm. By default TCP connections use the Nagle algorithm, they buffer data before sending
Expand All @@ -161,7 +164,8 @@ class Socket(options: SocketOptions) extends stream.Duplex with HasHandle {
* @return socket.
* @example socket.setTimeout(timeout[, callback])
*/
def setTimeout(timeout: Int = 0, callback: js.Function = null): this.type = js.native
def setTimeout(timeout: Int, callback: js.Function): this.type = js.native
def setTimeout(timeout: Int): this.type = js.native

/**
* Calling unref on a socket will allow the program to exit if this is the only active socket in the event system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@ package object querystring {
*/
implicit final class QueryStringEnrichment(private val qs: QueryString) extends AnyVal {
@inline
def parseAs[T <: js.Object](str: String,
sep: String = null,
eq: String = null,
options: QueryDecodeOptions = null
): T = {
def parseAs[T <: js.Object](str: String, sep: String, eq: String, options: QueryDecodeOptions): T = {
qs.parse(str, sep, eq, options).asInstanceOf[T]
}

@inline
def parseAs[T <: js.Object](str: String, sep: String, eq: String): T = {
qs.parse(str, sep, eq).asInstanceOf[T]
}

@inline
def parseAs[T <: js.Object](str: String, sep: String): T = {
qs.parse(str, sep).asInstanceOf[T]
}

@inline
def parseAs[T <: js.Object](str: String): T = {
qs.parse(str).asInstanceOf[T]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,15 @@ package object stream {
def endFuture(chunk: Buffer): Future[Unit] = promiseWithError0[Error](writable.end(chunk, _))

@inline
def endFuture(chunk: String, encoding: String = null): Future[Unit] = {
def endFuture(chunk: String, encoding: String): Future[Unit] = {
promiseWithError0[Error](writable.end(chunk, encoding, _))
}

@inline
def endFuture(chunk: String): Future[Unit] = {
promiseWithError0[Error](writable.end(chunk, _))
}

@inline
def endFuture(): Future[Unit] = promiseWithError0[Error](writable.end(_))

Expand All @@ -183,9 +188,14 @@ package object stream {
}

@inline
def writeFuture(chunk: String, encoding: String = null): Future[Unit] = {
def writeFuture(chunk: String, encoding: String): Future[Unit] = {
promiseWithError0[Error](writable.write(chunk, encoding, _))
}

@inline
def writeFuture(chunk: String): Future[Unit] = {
promiseWithError0[Error](writable.write(chunk, _))
}
}

}
71 changes: 43 additions & 28 deletions app/nodejs-v14/src/main/scala/io/scalajs/nodejs/zlib/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,59 +25,74 @@ package object zlib {
*/
implicit final class ZlibExtensions[T <: Zlib](private val zlib: T) extends AnyVal {

/**
* Asynchronously compresses a Buffer or string with Deflate.
*/
@inline
def deflateFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
def deflateFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.deflate(buffer, options, _))
}

/**
* Asynchronously compresses a Buffer or string with DeflateRaw.
*/
@inline
def deflateRawFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
def deflateFuture(buffer: Data): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.deflate(buffer, _))
}

@inline
def deflateRawFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.deflateRaw(buffer, options, _))
}

/**
* Compress a Buffer or string with Gzip.
*/
@inline
def gzipFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
def deflateRawFuture(buffer: Data): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.deflateRaw(buffer, _))
}

@inline
def gzipFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.gzip(buffer, options, _))
}

/**
* Decompress a Buffer or string with Gunzip.
*/
@inline
def gunzipFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
def gzipFuture(buffer: Data): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.gzip(buffer, _))
}

@inline
def gunzipFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.gunzip(buffer, options, _))
}

/**
* Decompress a Buffer or string with Inflate.
*/
@inline
def inflateFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
def gunzipFuture(buffer: Data): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.gunzip(buffer, _))
}

@inline
def inflateFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.inflate(buffer, options, _))
}

/**
* Decompress a Buffer or string with InflateRaw.
*/
def inflateRawFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
@inline
def inflateFuture(buffer: Data): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.inflate(buffer, _))
}

@inline
def inflateRawFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.inflateRaw(buffer, options, _))
}

/**
* Decompress a Buffer or string with Unzip.
*/
@inline
def unzipFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
def inflateRawFuture(buffer: Data): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.inflateRaw(buffer, _))
}

@inline
def unzipFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.unzip(buffer, options, _))
}

@inline
def unzipFuture(buffer: Data): Future[Buffer] = {
promiseWithError1[Error, Buffer](zlib.unzip(buffer, _))
}
}
}