Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 8244f5c

Browse files
authored
Merge pull request #262 from exoego/cleanup-default-values
More cleanup default values
2 parents c8a9f95 + 68cfe7b commit 8244f5c

File tree

9 files changed

+129
-70
lines changed

9 files changed

+129
-70
lines changed

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/child_process/package.scala

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,33 @@ package object child_process {
1919

2020
implicit final class ChildProcessObjectExtensions(private val cp: ChildProcess.type) extends AnyVal {
2121
@inline
22-
def execFuture(
23-
command: String,
24-
options: js.UndefOr[ExecOptions] = js.undefined
25-
): Future[(Output, Output)] = {
26-
promiseWithError2[nodejs.Error, Output, Output](cp.exec(command, options.orNull, _))
22+
def execFuture(command: String, options: ExecOptions): Future[(Output, Output)] = {
23+
promiseWithError2[nodejs.Error, Output, Output](cp.exec(command, options, _))
2724
}
2825

2926
@inline
30-
def execFileFuture(
31-
file: String,
32-
args: js.UndefOr[js.Array[String]] = js.undefined,
33-
options: js.UndefOr[ExecOptions] = js.undefined
34-
): Future[(Output, Output)] = {
35-
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, args.orNull, options.orNull, _))
27+
def execFuture(command: String): Future[(Output, Output)] = {
28+
promiseWithError2[nodejs.Error, Output, Output](cp.exec(command, _))
29+
}
30+
31+
@inline
32+
def execFileFuture(file: String, args: js.Array[String], options: ExecOptions): Future[(Output, Output)] = {
33+
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, args, options, _))
34+
}
35+
36+
@inline
37+
def execFileFuture(file: String, args: js.Array[String]): Future[(Output, Output)] = {
38+
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, args, _))
39+
}
40+
41+
@inline
42+
def execFileFuture(file: String, options: ExecOptions): Future[(Output, Output)] = {
43+
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, options, _))
44+
}
45+
46+
@inline
47+
def execFileFuture(file: String): Future[(Output, Output)] = {
48+
promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, _))
3649
}
3750
}
3851

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Decipher.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ sealed trait Decipher extends Transform {
6161
* The decipher.setAutoPadding() method must be called before decipher.update().
6262
* @example decipher.setAutoPadding(auto_padding=true)
6363
*/
64-
def setAutoPadding(auto_padding: Boolean = true): Decipher = js.native
64+
def setAutoPadding(auto_padding: Boolean): Decipher = js.native
65+
def setAutoPadding(): Decipher = js.native
6566

6667
/**
6768
* Updates the decipher with data. If the input_encoding argument is given, it's value must be one of 'binary',

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/dns/package.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ package object dns {
105105
* @param hostname the hostname
106106
*/
107107
@inline
108-
def resolveFuture(hostname: String, rrtype: RRType = null): Future[ResolveResult] = {
108+
def resolveFuture(hostname: String, rrtype: RRType): Future[ResolveResult] = {
109109
promiseWithError1[DnsError, ResolveResult](dns.resolve(hostname, rrtype, _))
110110
}
111111

112+
@inline
113+
def resolveFuture(hostname: String): Future[js.Array[String]] = {
114+
promiseWithError1[DnsError, js.Array[String]](dns.resolve(hostname, _))
115+
}
116+
112117
/**
113118
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of hostnames.
114119
* The callback function has arguments (err, hostnames), where hostnames is an array of resolved hostnames for the given ip.

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/Fs.scala

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ trait Fs extends js.Object with FSConstants {
345345
* @param length the desired length
346346
* @return undefined.
347347
*/
348-
def ftruncateSync(fd: FileDescriptor, length: Int = 0): Unit = js.native
348+
def ftruncateSync(fd: FileDescriptor, length: Int): Unit = js.native
349+
def ftruncateSync(fd: FileDescriptor): Unit = js.native
349350

350351
/**
351352
* Change the file timestamps of a file referenced by the supplied file descriptor.
@@ -657,18 +658,10 @@ trait Fs extends js.Object with FSConstants {
657658
* of the names of the files in the directory excluding '.' and '..'.
658659
* @example fs.readdir(path[, options], callback)
659660
*/
660-
def readdir(path: Path, options: String, callback: FsCallback1[ReaddirArrays]): Unit = js.native
661+
def readdir(path: Path, options: String, callback: FsCallback1[js.Array[String]]): Unit = js.native
661662
def readdir(path: Path, options: FileEncodingOptions, callback: FsCallback1[ReaddirArrays]): Unit = js.native
662663
def readdir(path: Path, options: ReaddirOptions, callback: FsCallback1[ReaddirArrays2]): Unit = js.native
663-
664-
/**
665-
* Asynchronous readdir(3). Reads the contents of a directory.
666-
* @param path the path (Buffer | String)
667-
* @param callback the callback gets two arguments (err, files) where files is an array
668-
* of the names of the files in the directory excluding '.' and '..'.
669-
* @example fs.readdir(path[, options], callback)
670-
*/
671-
def readdir(path: Path, callback: FsCallback1[js.Array[String]]): Unit = js.native
664+
def readdir(path: Path, callback: FsCallback1[js.Array[String]]): Unit = js.native
672665

673666
/**
674667
* Synchronous readdir(3).

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/package.scala

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,13 @@ package object fs {
244244
}
245245

246246
@inline
247-
def readdirFuture(path: Path, encoding: String = "utf8"): Future[js.Array[String]] = {
248-
val callback: FsCallback1[js.Array[String]] => Unit = { callback =>
249-
instance.readdir(path, encoding, callback.asInstanceOf[FsCallback1[ReaddirArrays]])
250-
}
251-
promiseWithError1[FileIOError, js.Array[String]](callback)
247+
def readdirFuture(path: Path, encoding: String): Future[js.Array[String]] = {
248+
promiseWithError1[FileIOError, js.Array[String]](instance.readdir(path, encoding, _))
249+
}
250+
251+
@inline
252+
def readdirFuture(path: Path): Future[js.Array[String]] = {
253+
promiseWithError1[FileIOError, js.Array[String]](instance.readdir(path, _))
252254
}
253255

254256
@inline
@@ -453,9 +455,9 @@ package object fs {
453455
@inline
454456
def writeFuture(fd: FileDescriptor,
455457
buffer: typedarray.Uint8Array,
456-
offset: Int | Null = null,
457-
length: Int | Null = null,
458-
position: Int | Null = null
458+
offset: Int | Null,
459+
length: Int | Null,
460+
position: Int | Null
459461
): Future[(FileType, Buffer)] = {
460462
promiseWithError2[FileIOError, Int, Buffer](instance.write(fd, buffer, offset, length, position, _))
461463
}
@@ -486,10 +488,15 @@ package object fs {
486488
}
487489

488490
@inline
489-
def writeFileFuture(file: String, data: typedarray.Uint8Array, options: FileWriteOptions = null): Future[Unit] = {
491+
def writeFileFuture(file: String, data: typedarray.Uint8Array, options: FileWriteOptions): Future[Unit] = {
490492
promiseWithError0[FileIOError](instance.writeFile(file, data, options, _))
491493
}
492494

495+
@inline
496+
def writeFileFuture(file: String, data: typedarray.Uint8Array): Future[Unit] = {
497+
promiseWithError0[FileIOError](instance.writeFile(file, data, _))
498+
}
499+
493500
@inline
494501
def writeFileFuture(file: String, data: BufferLike): Future[Unit] = {
495502
promiseWithError0[FileIOError](instance.writeFile(file, data, _))

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/net/Socket.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ class Socket(options: SocketOptions) extends stream.Duplex with HasHandle {
140140
* @return socket
141141
* @example socket.setKeepAlive([enable][, initialDelay])
142142
*/
143-
def setKeepAlive(enable: Boolean = false, initialDelay: Int = 0): this.type = js.native
143+
def setKeepAlive(enable: Boolean, initialDelay: Int): this.type = js.native
144+
def setKeepAlive(enable: Boolean): this.type = js.native
145+
def setKeepAlive(initialDelay: Int): this.type = js.native
146+
def setKeepAlive(): this.type = js.native
144147

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

166170
/**
167171
* Calling unref on a socket will allow the program to exit if this is the only active socket in the event system.

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/querystring/package.scala

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,23 @@ package object querystring {
1313
*/
1414
implicit final class QueryStringEnrichment(private val qs: QueryString) extends AnyVal {
1515
@inline
16-
def parseAs[T <: js.Object](str: String,
17-
sep: String = null,
18-
eq: String = null,
19-
options: QueryDecodeOptions = null
20-
): T = {
16+
def parseAs[T <: js.Object](str: String, sep: String, eq: String, options: QueryDecodeOptions): T = {
2117
qs.parse(str, sep, eq, options).asInstanceOf[T]
2218
}
19+
20+
@inline
21+
def parseAs[T <: js.Object](str: String, sep: String, eq: String): T = {
22+
qs.parse(str, sep, eq).asInstanceOf[T]
23+
}
24+
25+
@inline
26+
def parseAs[T <: js.Object](str: String, sep: String): T = {
27+
qs.parse(str, sep).asInstanceOf[T]
28+
}
29+
30+
@inline
31+
def parseAs[T <: js.Object](str: String): T = {
32+
qs.parse(str).asInstanceOf[T]
33+
}
2334
}
2435
}

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/stream/package.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,15 @@ package object stream {
170170
def endFuture(chunk: Buffer): Future[Unit] = promiseWithError0[Error](writable.end(chunk, _))
171171

172172
@inline
173-
def endFuture(chunk: String, encoding: String = null): Future[Unit] = {
173+
def endFuture(chunk: String, encoding: String): Future[Unit] = {
174174
promiseWithError0[Error](writable.end(chunk, encoding, _))
175175
}
176176

177+
@inline
178+
def endFuture(chunk: String): Future[Unit] = {
179+
promiseWithError0[Error](writable.end(chunk, _))
180+
}
181+
177182
@inline
178183
def endFuture(): Future[Unit] = promiseWithError0[Error](writable.end(_))
179184

@@ -183,9 +188,14 @@ package object stream {
183188
}
184189

185190
@inline
186-
def writeFuture(chunk: String, encoding: String = null): Future[Unit] = {
191+
def writeFuture(chunk: String, encoding: String): Future[Unit] = {
187192
promiseWithError0[Error](writable.write(chunk, encoding, _))
188193
}
194+
195+
@inline
196+
def writeFuture(chunk: String): Future[Unit] = {
197+
promiseWithError0[Error](writable.write(chunk, _))
198+
}
189199
}
190200

191201
}

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/zlib/package.scala

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,59 +25,74 @@ package object zlib {
2525
*/
2626
implicit final class ZlibExtensions[T <: Zlib](private val zlib: T) extends AnyVal {
2727

28-
/**
29-
* Asynchronously compresses a Buffer or string with Deflate.
30-
*/
3128
@inline
32-
def deflateFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
29+
def deflateFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
3330
promiseWithError1[Error, Buffer](zlib.deflate(buffer, options, _))
3431
}
3532

36-
/**
37-
* Asynchronously compresses a Buffer or string with DeflateRaw.
38-
*/
3933
@inline
40-
def deflateRawFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
34+
def deflateFuture(buffer: Data): Future[Buffer] = {
35+
promiseWithError1[Error, Buffer](zlib.deflate(buffer, _))
36+
}
37+
38+
@inline
39+
def deflateRawFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
4140
promiseWithError1[Error, Buffer](zlib.deflateRaw(buffer, options, _))
4241
}
4342

44-
/**
45-
* Compress a Buffer or string with Gzip.
46-
*/
4743
@inline
48-
def gzipFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
44+
def deflateRawFuture(buffer: Data): Future[Buffer] = {
45+
promiseWithError1[Error, Buffer](zlib.deflateRaw(buffer, _))
46+
}
47+
48+
@inline
49+
def gzipFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
4950
promiseWithError1[Error, Buffer](zlib.gzip(buffer, options, _))
5051
}
5152

52-
/**
53-
* Decompress a Buffer or string with Gunzip.
54-
*/
5553
@inline
56-
def gunzipFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
54+
def gzipFuture(buffer: Data): Future[Buffer] = {
55+
promiseWithError1[Error, Buffer](zlib.gzip(buffer, _))
56+
}
57+
58+
@inline
59+
def gunzipFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
5760
promiseWithError1[Error, Buffer](zlib.gunzip(buffer, options, _))
5861
}
5962

60-
/**
61-
* Decompress a Buffer or string with Inflate.
62-
*/
6363
@inline
64-
def inflateFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
64+
def gunzipFuture(buffer: Data): Future[Buffer] = {
65+
promiseWithError1[Error, Buffer](zlib.gunzip(buffer, _))
66+
}
67+
68+
@inline
69+
def inflateFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
6570
promiseWithError1[Error, Buffer](zlib.inflate(buffer, options, _))
6671
}
6772

68-
/**
69-
* Decompress a Buffer or string with InflateRaw.
70-
*/
71-
def inflateRawFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
73+
@inline
74+
def inflateFuture(buffer: Data): Future[Buffer] = {
75+
promiseWithError1[Error, Buffer](zlib.inflate(buffer, _))
76+
}
77+
78+
@inline
79+
def inflateRawFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
7280
promiseWithError1[Error, Buffer](zlib.inflateRaw(buffer, options, _))
7381
}
7482

75-
/**
76-
* Decompress a Buffer or string with Unzip.
77-
*/
7883
@inline
79-
def unzipFuture(buffer: Data, options: CompressionOptions = null): Future[Buffer] = {
84+
def inflateRawFuture(buffer: Data): Future[Buffer] = {
85+
promiseWithError1[Error, Buffer](zlib.inflateRaw(buffer, _))
86+
}
87+
88+
@inline
89+
def unzipFuture(buffer: Data, options: CompressionOptions): Future[Buffer] = {
8090
promiseWithError1[Error, Buffer](zlib.unzip(buffer, options, _))
8191
}
92+
93+
@inline
94+
def unzipFuture(buffer: Data): Future[Buffer] = {
95+
promiseWithError1[Error, Buffer](zlib.unzip(buffer, _))
96+
}
8297
}
8398
}

0 commit comments

Comments
 (0)