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

Commit 83f7a76

Browse files
authored
Merge pull request #260 from exoego/overload
Prefer overload over default parameter
2 parents b028081 + 98061b3 commit 83f7a76

File tree

8 files changed

+45
-65
lines changed

8 files changed

+45
-65
lines changed

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/Assert.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,8 @@ trait Assert extends js.Object {
102102
* of the message parameter. If the message parameter is undefined, a default error message is assigned.
103103
* @example assert.throws(block[, error][, message])
104104
*/
105-
def throws(block: js.Function,
106-
error: js.RegExp | js.Function | js.Object | Error,
107-
message: String = js.native
108-
): Unit = js.native
105+
def throws(block: js.Function, error: js.RegExp | js.Function | js.Object | Error, message: String): Unit = js.native
106+
def throws(block: js.Function, error: js.RegExp | js.Function | js.Object | Error): Unit = js.native
109107

110108
def rejects(asyncFn: js.Function | js.Promise[_],
111109
error: js.RegExp | js.Function | js.Object | Error,

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ trait Crypto extends js.Object {
5555
def createCipheriv(algorithm: String,
5656
key: String | BufferLike,
5757
iv: String | BufferLike,
58-
options: TransformOptions = js.native
59-
): Cipher = js.native
58+
options: TransformOptions
59+
): Cipher = js.native
60+
def createCipheriv(algorithm: String, key: String | BufferLike, iv: String | BufferLike): Cipher = js.native
6061
@enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12)
6162
def createCipheriv(algorithm: String, key: KeyObject, iv: String | BufferLike, options: TransformOptions): Cipher =
6263
js.native
@@ -80,8 +81,9 @@ trait Crypto extends js.Object {
8081
def createDecipheriv(algorithm: String,
8182
key: String | BufferLike,
8283
iv: String | BufferLike,
83-
options: TransformOptions = js.native
84-
): Decipher = js.native
84+
options: TransformOptions
85+
): Decipher = js.native
86+
def createDecipheriv(algorithm: String, key: String | BufferLike, iv: String | BufferLike): Decipher = js.native
8587
def createDecipheriv(algorithm: String,
8688
key: KeyObject,
8789
iv: String | BufferLike,

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

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,17 +1099,13 @@ trait Fs extends js.Object with FSConstants {
10991099
* @return undefined.
11001100
* @example fs.writeFileSync(file, data[, options])
11011101
*/
1102-
def writeFileSync(file: Path | FileDescriptor,
1103-
data: js.typedarray.Uint8Array,
1104-
options: FileWriteOptions = js.native
1105-
): Unit =
1102+
def writeFileSync(file: Path | FileDescriptor, data: js.typedarray.Uint8Array, options: FileWriteOptions): Unit =
11061103
js.native
1107-
def writeFileSync(file: Path | FileDescriptor, data: String, options: FileWriteOptions): Unit =
1108-
js.native
1109-
def writeFileSync(file: Path | FileDescriptor, data: String): Unit = js.native
1110-
def writeFileSync(file: Path | FileDescriptor, data: BufferLike, options: FileWriteOptions): Unit =
1111-
js.native
1112-
def writeFileSync(file: Path | FileDescriptor, data: BufferLike): Unit = js.native
1104+
def writeFileSync(file: Path | FileDescriptor, data: js.typedarray.Uint8Array): Unit = js.native
1105+
def writeFileSync(file: Path | FileDescriptor, data: String, options: FileWriteOptions): Unit = js.native
1106+
def writeFileSync(file: Path | FileDescriptor, data: String): Unit = js.native
1107+
def writeFileSync(file: Path | FileDescriptor, data: BufferLike, options: FileWriteOptions): Unit = js.native
1108+
def writeFileSync(file: Path | FileDescriptor, data: BufferLike): Unit = js.native
11131109

11141110
/**
11151111
* Write buffer to the file specified by fd.
@@ -1121,13 +1117,9 @@ trait Fs extends js.Object with FSConstants {
11211117
* @param position refers to the offset from the beginning of the file where this data should be written.
11221118
* @example {{{ fs.writeSync(fd, buffer[, offset[, length[, position]]]) }}}
11231119
*/
1124-
def writeSync(fd: FileDescriptor,
1125-
buffer: js.typedarray.Uint8Array,
1126-
offset: Int,
1127-
length: Int,
1128-
position: Int = js.native
1129-
): Unit =
1120+
def writeSync(fd: FileDescriptor, buffer: js.typedarray.Uint8Array, offset: Int, length: Int, position: Int): Unit =
11301121
js.native
1122+
def writeSync(fd: FileDescriptor, buffer: js.typedarray.Uint8Array, offset: Int, length: Int): Unit = js.native
11311123
def writeSync(fd: FileDescriptor, buffer: js.typedarray.Uint8Array, offset: Int): Unit = js.native
11321124
def writeSync(fd: FileDescriptor, buffer: js.typedarray.Uint8Array): Unit = js.native
11331125
def writeSync(fd: FileDescriptor, buffer: BufferLike, offset: Int, length: Int, position: Int): Unit = js.native
@@ -1155,10 +1147,9 @@ trait Fs extends js.Object with FSConstants {
11551147
fsCallback2: FsCallback2[Int, js.Array[js.typedarray.ArrayBufferView]]
11561148
): Unit = js.native
11571149
@enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12)
1158-
def writevSync(fd: FileDescriptor,
1159-
buffers: js.Array[js.typedarray.ArrayBufferView],
1160-
position: Int = js.native
1161-
): Unit = js.native
1150+
def writevSync(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView], position: Int): Unit = js.native
1151+
@enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12)
1152+
def writevSync(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView]): Unit = js.native
11621153
}
11631154

11641155
/**
@@ -1171,10 +1162,10 @@ object Fs extends Fs {
11711162
trait FsPromises extends js.Object {
11721163
def access(path: Path, mode: FileMode): js.Promise[Unit] = js.native
11731164

1174-
def appendFile(file: Path | FileDescriptor,
1175-
data: String | Buffer,
1176-
options: FileAppendOptions | String = js.native
1177-
): js.Promise[Unit] = js.native
1165+
def appendFile(file: Path | FileDescriptor, data: String | Buffer, options: FileAppendOptions): js.Promise[Unit] =
1166+
js.native
1167+
def appendFile(file: Path | FileDescriptor, data: String | Buffer, encoding: String): js.Promise[Unit] = js.native
1168+
def appendFile(file: Path | FileDescriptor, data: String | Buffer): js.Promise[Unit] = js.native
11781169

11791170
def chmod(path: Path, mode: FileMode): js.Promise[Unit] = js.native
11801171
def chown(path: Path, uid: UID, gid: GID): js.Promise[Unit] = js.native

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ import scala.scalajs.js.|
1010

1111
@js.native
1212
trait Http2 extends js.Object {
13-
def createServer(
14-
options: Http2ServerOptions,
15-
onRequestHandler: js.Function2[Http2ServerRequest, Http2ServerResponse, Any] = js.native
16-
): Http2Server = js.native
17-
18-
def createSecureServer(
19-
options: Http2SecureServerOptions,
20-
onRequestHandler: js.Function2[Http2ServerRequest, Http2ServerResponse, Any] = js.native
21-
): Http2SecureServer = js.native
13+
def createServer(options: Http2ServerOptions, onRequestHandler: ServerCallback): Http2Server = js.native
14+
def createServer(options: Http2ServerOptions): Http2Server = js.native
15+
16+
def createSecureServer(options: Http2SecureServerOptions, onRequestHandler: ServerCallback): Http2SecureServer =
17+
js.native
18+
def createSecureServer(options: Http2SecureServerOptions): Http2SecureServer = js.native
2219

2320
def connect(authority: String | URL, options: Http2ConnectOptions, listener: js.Function): ClientHttp2Session =
2421
js.native

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import scala.scalajs.js
77
import scala.scalajs.js.|
88

99
package object http2 {
10-
type Origin = String | URL | HasOrigin
11-
type Path = String | Buffer | URL
10+
type Origin = String | URL | HasOrigin
11+
type Path = String | Buffer | URL
12+
type ServerCallback = js.Function2[Http2ServerRequest, Http2ServerResponse, Any]
1213

1314
implicit final class Http2SessionExtensions[T <: Http2Session](private val instance: T) extends AnyVal {
1415
@inline def onClose(handler: () => Any): T = instance.on("close", handler)

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/https/Https.scala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ trait Https extends js.Object {
4141
def get(url: String | URL, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native
4242
def get(options: RequestOptions, callback: js.Function): ClientRequest = js.native
4343

44-
def request(url: String | URL,
45-
options: RequestOptions,
46-
callback: js.Function1[ServerResponse, Any] = js.native
47-
): Unit = js.native
48-
def request(url: String | URL, callback: js.Function1[ServerResponse, Any]): Unit = js.native
49-
def request(url: String | URL): Unit = js.native
50-
def request(options: RequestOptions): Unit = js.native
51-
def request(options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native
44+
def request(url: String | URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native
45+
def request(url: String | URL, options: RequestOptions): Unit = js.native
46+
def request(url: String | URL, callback: js.Function1[ServerResponse, Any]): Unit = js.native
47+
def request(url: String | URL): Unit = js.native
48+
def request(options: RequestOptions): Unit = js.native
49+
def request(options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native
5250
}
5351

5452
/**

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/process/Process.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,8 @@ trait Process extends IEventEmitter {
321321
* @example {{{ process.send(message[, sendHandle[, options]][, callback]) }}}
322322
* @since 0.5.9
323323
*/
324-
def send(message: js.Any,
325-
sendHandle: SendHandle,
326-
options: TransferOptions,
327-
callback: js.Function = js.native
328-
): Boolean = js.native
324+
def send(message: js.Any, sendHandle: SendHandle, options: TransferOptions, callback: js.Function): Boolean =
325+
js.native
329326
def send(message: js.Any, sendHandle: SendHandle, options: TransferOptions): Boolean = js.native
330327
def send(message: js.Any, sendHandle: SendHandle, callback: js.Function): Boolean = js.native
331328
def send(message: js.Any, sendHandle: SendHandle): Boolean = js.native

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/vm/VM.scala

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ import scala.scalajs.js.|
1313
*/
1414
@js.native
1515
trait VM extends js.Object {
16-
def compileFunction(code: String,
17-
params: js.Array[String],
18-
options: CompileFunctionOptions = js.native
19-
): js.Function = js.native
20-
def compileFunction(code: String): js.Function = js.native
16+
def compileFunction(code: String, params: js.Array[String], options: CompileFunctionOptions): js.Function = js.native
17+
def compileFunction(code: String, params: js.Array[String]): js.Function = js.native
18+
def compileFunction(code: String): js.Function = js.native
2119

2220
/**
2321
* If given a sandbox object, the vm.createContext() method will
@@ -54,10 +52,8 @@ trait VM extends js.Object {
5452
* @param options the optional options
5553
* @example script.runInContext(contextifiedSandbox[, options])
5654
*/
57-
def runInContext(code: String,
58-
contextifiedSandbox: ScriptContext,
59-
options: VMRunInContextOptions = js.native
60-
): js.Any = js.native
55+
def runInContext(code: String, contextifiedSandbox: ScriptContext, options: VMRunInContextOptions): js.Any = js.native
56+
def runInContext(code: String, contextifiedSandbox: ScriptContext): js.Any = js.native
6157

6258
/**
6359
* First contextifies the given sandbox, runs the compiled code contained by the vm.Script object within the created

0 commit comments

Comments
 (0)