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

Commit 1e75317

Browse files
authored
Merge pull request #64 from exoego/avoid-raw-options
Avoid RawOptions where options have its own class.
2 parents 5c03fbb + fc380a7 commit 1e75317

File tree

21 files changed

+107
-153
lines changed

21 files changed

+107
-153
lines changed

app/current/src/main/scala/io/scalajs/nodejs/child_process/ChildProcess.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trait ChildProcess extends IEventEmitter {
2121
def unref(): Unit = js.native
2222
// TODO: Are those available in limited scenario?
2323
//def disconnect(): Unit = js.native
24-
//def send(message: js.Any, sendHandle: Handle = js.native, options: SendOptions | RawOptions = js.native, callback: js.Function1[nodejs.Error, Any] = js.native): Boolean = js.native
24+
//def send(message: js.Any, sendHandle: Handle = js.native, options: SendOptions = js.native, callback: js.Function1[nodejs.Error, Any] = js.native): Boolean = js.native
2525

2626
val channel: js.UndefOr[js.Object] = js.native
2727
val connected: Boolean = js.native

app/current/src/main/scala/io/scalajs/nodejs/dns/DNS.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.scalajs.nodejs.dns
22

3-
import io.scalajs.RawOptions
4-
53
import scala.scalajs.js
64
import scala.scalajs.js.annotation.JSImport
75
import scala.scalajs.js.|
@@ -44,7 +42,7 @@ trait DNS extends js.Object {
4442
* All properties are optional.
4543
* @example dns.lookup(hostname[, options], callback)
4644
*/
47-
def lookup(hostname: String, options: DnsOptions | RawOptions | Int, callback: DnsCallback1[String]): Unit = js.native
45+
def lookup(hostname: String, options: DnsOptions | Int, callback: DnsCallback1[String]): Unit = js.native
4846

4947
/**
5048
* Resolves a hostname (e.g. 'nodejs.org') into the first found A (IPv4) or AAAA (IPv6) record. options can be an

app/current/src/main/scala/io/scalajs/nodejs/dns/package.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.scalajs.nodejs
22

3-
import io.scalajs.RawOptions
43
import io.scalajs.util.PromiseHelper._
54

65
import scala.concurrent.Future
@@ -70,7 +69,7 @@ package object dns {
7069
* integer, then it must be 4 or 6.
7170
*/
7271
@inline
73-
def lookupFuture(hostname: String, options: DnsOptions | RawOptions | Int = null): Future[String] = {
72+
def lookupFuture(hostname: String, options: DnsOptions | Int = null): Future[String] = {
7473
promiseWithError1[DnsError, String](dns.lookup(hostname, options, _))
7574
}
7675

app/current/src/main/scala/io/scalajs/nodejs/fs/Fs.scala

Lines changed: 42 additions & 51 deletions
Large diffs are not rendered by default.

app/current/src/main/scala/io/scalajs/nodejs/fs/package.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ import scala.scalajs.js.|
1515
*/
1616
package object fs {
1717

18-
type Path = Uint8Array | String | URL
19-
type Time = Int | String | js.Date
20-
type BufferLike = TypedArray[_, _] | DataView
21-
type Output = String | Buffer
18+
type Path = Uint8Array | String | URL
19+
type Time = Int | String | js.Date
20+
type BufferLike = TypedArray[_, _] | DataView
21+
type Output = String | Buffer
22+
type FileWriteOptions = FileAppendOptions
2223

2324
@enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs10)
2425
type Dirent = Fs.Dirent
@@ -135,7 +136,7 @@ package object fs {
135136
@inline
136137
def readdirDirentFuture(path: Buffer | String): Future[js.Array[Dirent]] = {
137138
val callback: FsCallback1[js.Array[Dirent]] => Unit = { callback =>
138-
fs.readdir(path, new ReaddirOptions(withFileTypes = true), callback.asInstanceOf[FsCallback1[ReaddirArrays]])
139+
fs.readdir(path, new ReaddirOptions(withFileTypes = true), callback.asInstanceOf[FsCallback1[ReaddirArrays2]])
139140
}
140141
promiseWithError1[FileIOError, js.Array[Dirent]](callback)
141142
}
@@ -212,12 +213,12 @@ package object fs {
212213
}
213214

214215
@inline
215-
def writeFileFuture(file: String, data: Buffer, options: FileOutputOptions = null): Future[Unit] = {
216+
def writeFileFuture(file: String, data: Buffer, options: FileWriteOptions = null): Future[Unit] = {
216217
promiseWithError0[FileIOError](fs.writeFile(file, data, options, _))
217218
}
218219

219220
@inline
220-
def writeFileFuture(file: String, data: String, options: FileOutputOptions): Future[Unit] = {
221+
def writeFileFuture(file: String, data: String, options: FileWriteOptions): Future[Unit] = {
221222
promiseWithError0[FileIOError](fs.writeFile(file, data, options, _))
222223
}
223224

app/current/src/main/scala/io/scalajs/nodejs/http/Agent.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package io.scalajs.nodejs
22
package http
33

4-
import io.scalajs.RawOptions
54
import io.scalajs.util.PromiseHelper._
65

76
import scala.concurrent.Future
87
import scala.scalajs.js
9-
import scala.scalajs.js.|
108

119
/**
1210
* The HTTP Agent is used for pooling sockets used in HTTP client requests.
@@ -75,7 +73,7 @@ trait Agent extends js.Object {
7573
* callback has a signature of (err, stream).
7674
* @example agent.createConnection(options[, callback])
7775
*/
78-
def createConnection(options: ConnectionOptions | RawOptions, callback: js.Function): Unit = js.native
76+
def createConnection(options: ConnectionOptions, callback: js.Function): Unit = js.native
7977

8078
/**
8179
* Destroy any sockets that are currently in use by the agent.

app/current/src/main/scala/io/scalajs/nodejs/https/Https.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package io.scalajs.nodejs.https
22

3-
import io.scalajs.RawOptions
43
import io.scalajs.nodejs.events.IEventEmitter
54
import io.scalajs.nodejs.http.RequestOptions
65

76
import scala.scalajs.js
87
import scala.scalajs.js.annotation.JSImport
9-
import scala.scalajs.js.|
108

119
/**
1210
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a separate module.
@@ -33,14 +31,14 @@ trait Https extends IEventEmitter {
3331
* The requestListener is a function which is automatically added to the 'request' event.
3432
* @example https.createServer(options[, requestListener])
3533
*/
36-
def createServer(options: ServerOptions | RawOptions, requestListener: js.Function): Server = js.native
34+
def createServer(options: ServerOptions, requestListener: js.Function): Server = js.native
3735

3836
/**
3937
* Returns a new HTTPS web server object. The options is similar to tls.createServer().
4038
* The requestListener is a function which is automatically added to the 'request' event.
4139
* @example https.createServer(options[, requestListener])
4240
*/
43-
def createServer(options: ServerOptions | RawOptions): Server = js.native
41+
def createServer(options: ServerOptions): Server = js.native
4442

4543
/**
4644
* Like http.get() but for HTTPS.
@@ -54,14 +52,14 @@ trait Https extends IEventEmitter {
5452
* @example https.get(options, (res) => { ... })
5553
* @see [[io.scalajs.nodejs.http.Http.get()]]
5654
*/
57-
def get(options: RequestOptions | RawOptions, callback: js.Function): Unit = js.native
55+
def get(options: RequestOptions, callback: js.Function): Unit = js.native
5856

5957
/**
6058
* Makes a request to a secure web server.
6159
* @param options can be an object or a string. If options is a string, it is automatically parsed with url.parse().
6260
* @example http.request(options, callback)
6361
*/
64-
def request(options: RequestOptions | RawOptions, callback: js.Function): Unit = js.native
62+
def request(options: RequestOptions, callback: js.Function): Unit = js.native
6563

6664
/**
6765
* Makes a request to a secure web server.

app/current/src/main/scala/io/scalajs/nodejs/https/package.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ package io.scalajs.nodejs
22

33
import io.scalajs.nodejs.http.{RequestOptions, ServerResponse}
44
import io.scalajs.util.PromiseHelper._
5-
import io.scalajs.{RawOptions, nodejs}
5+
import io.scalajs.nodejs
66

77
import scala.concurrent.Future
8-
import scala.scalajs.js.|
98

109
/**
1110
* https package object
@@ -21,7 +20,7 @@ package object https {
2120
* Like http.get() but for HTTPS.
2221
*/
2322
@inline
24-
def getFuture(options: RequestOptions | RawOptions): Future[ServerResponse] = {
23+
def getFuture(options: RequestOptions): Future[ServerResponse] = {
2524
promiseCallback1[ServerResponse](https.get(options, _))
2625
}
2726

@@ -37,7 +36,7 @@ package object https {
3736
* Makes a request to a secure web server.
3837
*/
3938
@inline
40-
def requestFuture(options: RequestOptions | RawOptions): Future[ServerResponse] = {
39+
def requestFuture(options: RequestOptions): Future[ServerResponse] = {
4140
promiseWithError1[nodejs.Error, ServerResponse](https.request(options, _))
4241
}
4342

app/current/src/main/scala/io/scalajs/nodejs/net/Socket.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package io.scalajs.nodejs
22
package net
33

4-
import io.scalajs.RawOptions
54
import io.scalajs.nodejs.stream.IDuplex
65

76
import scala.scalajs.js
87
import scala.scalajs.js.annotation.JSImport
9-
import scala.scalajs.js.|
108

119
/**
1210
* net.Socket - This object is an abstraction of a TCP or local socket. net.Socket instances implement a duplex Stream
@@ -15,7 +13,7 @@ import scala.scalajs.js.|
1513
*/
1614
@js.native
1715
@JSImport("net", "Socket")
18-
class Socket(options: SocketOptions | RawOptions = js.native) extends IDuplex with HasHandle {
16+
class Socket(options: SocketOptions = js.native) extends IDuplex with HasHandle {
1917

2018
/////////////////////////////////////////////////////////////////////////////////
2119
// Properties
@@ -119,7 +117,7 @@ class Socket(options: SocketOptions | RawOptions = js.native) extends IDuplex wi
119117
* @param connectListener the optional connect listener
120118
* @example socket.connect(options[, connectListener])
121119
*/
122-
def connect(options: ConnectOptions | RawOptions, connectListener: js.Function = js.native): Unit = js.native
120+
def connect(options: ConnectOptions, connectListener: js.Function = js.native): Unit = js.native
123121

124122
/**
125123
* Opens the connection for a given socket.

app/current/src/main/scala/io/scalajs/nodejs/querystring/QueryString.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package io.scalajs.nodejs.querystring
22

3-
import io.scalajs.RawOptions
4-
53
import scala.scalajs.js
64
import scala.scalajs.js.annotation.JSImport
7-
import scala.scalajs.js.|
85

96
/**
107
* Query String
@@ -43,7 +40,7 @@ trait QueryString extends js.Object {
4340
def parse(str: String,
4441
sep: String = js.native,
4542
eq: String = js.native,
46-
options: QueryDecodeOptions | RawOptions = js.native): js.Dictionary[String] = js.native
43+
options: QueryDecodeOptions = js.native): js.Dictionary[String] = js.native
4744

4845
/**
4946
* The querystring.stringify() method produces a URL query string from a given obj by iterating through the
@@ -56,7 +53,7 @@ trait QueryString extends js.Object {
5653
def stringify(obj: js.Any,
5754
sep: String = js.native,
5855
eq: String = js.native,
59-
options: QueryEncodeOptions | RawOptions = js.native): String = js.native
56+
options: QueryEncodeOptions = js.native): String = js.native
6057

6158
/**
6259
* The querystring.unescape() method performs decoding of URL percent-encoded characters on the given str.

0 commit comments

Comments
 (0)