Skip to content

Commit 80502a7

Browse files
committed
Merge commit 'a05f6748ad2a0045d25b1a30346a74a331a8be69' into develop
* commit 'a05f6748ad2a0045d25b1a30346a74a331a8be69': Miscellaneous fixes Fixed version error # Conflicts: # src/main/scala/io/scalajs/nodejs/fs/ReadStream.scala # src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala # src/main/scala/io/scalajs/nodejs/net/Socket.scala # src/main/scala/io/scalajs/nodejs/stream/Duplex.scala # src/main/scala/io/scalajs/nodejs/stream/Readable.scala # src/main/scala/io/scalajs/nodejs/stream/Writable.scala
2 parents 51633d3 + a05f674 commit 80502a7

20 files changed

+223
-125
lines changed

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import sbt._
55

66
import scala.language.postfixOps
77

8-
val scalaJsIOVersion = "0.3.0.5"
8+
val scalaJsIOVersion = "0.3.0.6"
99
val apiVersion = scalaJsIOVersion
1010
val scalaJsVersion = "2.12.1"
1111

1212
organization := "io.scalajs"
1313

14-
homepage := Some(url("https://github.com/scalajs-io/scalajs.io"))
14+
homepage := Some(url("https://github.com/scalajs-io/nodejs"))
1515

1616
lazy val root = (project in file(".")).
1717
enablePlugins(ScalaJSPlugin).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nodejs-sfs",
3-
"version": "0.3.0.5",
3+
"version": "0.3.05",
44
"private": true,
55
"dependencies": {
66
"source-map": "^0.5.6"

src/main/scala/io/scalajs/nodejs/crypto/Cipher.scala

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

33
import io.scalajs.nodejs.buffer.Buffer
4-
import io.scalajs.nodejs.stream.Duplex
4+
import io.scalajs.nodejs.stream.IDuplex
55

66
import scala.scalajs.js
77

@@ -17,7 +17,7 @@ import scala.scalajs.js
1717
* @author lawrence.daniels@gmail.com
1818
*/
1919
@js.native
20-
trait Cipher extends Duplex {
20+
trait Cipher extends IDuplex {
2121

2222
/**
2323
* Returns any remaining enciphered contents. If output_encoding parameter is one of 'binary', 'base64' or 'hex',
@@ -27,7 +27,7 @@ trait Cipher extends Duplex {
2727
* Attempts to call cipher.final() more than once will result in an error being thrown.
2828
* @example cipher.final([output_encoding])
2929
*/
30-
def `final`(output_encoding: String ): String = js.native
30+
def `final`(output_encoding: String): String = js.native
3131

3232
/**
3333
* Returns any remaining enciphered contents. If output_encoding parameter is one of 'binary', 'base64' or 'hex',

src/main/scala/io/scalajs/nodejs/crypto/Decipher.scala

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

33
import io.scalajs.nodejs.buffer.Buffer
4-
import io.scalajs.nodejs.stream.Duplex
4+
import io.scalajs.nodejs.stream.IDuplex
55

66
import scala.scalajs.js
77

@@ -17,7 +17,7 @@ import scala.scalajs.js
1717
* @author lawrence.daniels@gmail.com
1818
*/
1919
@js.native
20-
trait Decipher extends Duplex {
20+
trait Decipher extends IDuplex {
2121

2222
/**
2323
* Returns any remaining deciphered contents. If output_encoding parameter is one of 'binary', 'base64' or 'hex',

src/main/scala/io/scalajs/nodejs/crypto/Hash.scala

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

33
import io.scalajs.nodejs.buffer.Buffer
4-
import io.scalajs.nodejs.stream.Duplex
4+
import io.scalajs.nodejs.stream.IDuplex
55

66
import scala.scalajs.js
77

@@ -16,7 +16,7 @@ import scala.scalajs.js
1616
* @author lawrence.daniels@gmail.com
1717
*/
1818
@js.native
19-
trait Hash extends Duplex {
19+
trait Hash extends IDuplex {
2020

2121
/**
2222
* Calculates the digest of all of the data passed to be hashed (using the hash.update() method). The encoding can

src/main/scala/io/scalajs/nodejs/crypto/Hmac.scala

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

33
import io.scalajs.nodejs.buffer.Buffer
4-
import io.scalajs.nodejs.stream.Duplex
4+
import io.scalajs.nodejs.stream.IDuplex
55

66
import scala.scalajs.js
77

@@ -17,7 +17,7 @@ import scala.scalajs.js
1717
* @author lawrence.daniels@gmail.com
1818
*/
1919
@js.native
20-
trait Hmac extends Duplex {
20+
trait Hmac extends IDuplex {
2121

2222
/**
2323
* Calculates the HMAC digest of all of the data passed using hmac.update(). The encoding can be 'hex', 'binary'

src/main/scala/io/scalajs/nodejs/crypto/Sign.scala

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

33
import io.scalajs.nodejs.buffer.Buffer
4-
import io.scalajs.nodejs.stream
5-
import io.scalajs.nodejs.stream.Duplex
4+
import io.scalajs.nodejs.stream.IDuplex
65

76
import scala.scalajs.js
87

@@ -18,7 +17,7 @@ import scala.scalajs.js
1817
* @author lawrence.daniels@gmail.com
1918
*/
2019
@js.native
21-
trait Sign extends Duplex {
20+
trait Sign extends IDuplex {
2221

2322
def sign(private_key: String): String = js.native
2423

src/main/scala/io/scalajs/nodejs/crypto/Verify.scala

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

33
import io.scalajs.nodejs.buffer.Buffer
4-
import io.scalajs.nodejs.stream
5-
import io.scalajs.nodejs.stream.Duplex
4+
import io.scalajs.nodejs.stream.IDuplex
65

76
import scala.scalajs.js
87

@@ -17,7 +16,7 @@ import scala.scalajs.js
1716
* @author lawrence.daniels@gmail.com
1817
*/
1918
@js.native
20-
trait Verify extends Duplex {
19+
trait Verify extends IDuplex {
2120

2221
/**
2322
* Updates the Verify content with the given data.

src/main/scala/io/scalajs/nodejs/fs/ReadStream.scala

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
package io.scalajs.nodejs.fs
1+
package io.scalajs.nodejs
2+
package fs
23

3-
import io.scalajs.nodejs
4-
import io.scalajs.nodejs.FileDescriptor
54
import io.scalajs.nodejs.buffer.Buffer
5+
import io.scalajs.nodejs.stream.Readable
6+
import io.scalajs.util.PromiseHelper.promiseCallback1
67

8+
import scala.concurrent.Promise
79
import scala.scalajs.js
810
import scala.scalajs.js.|
911

@@ -12,14 +14,33 @@ import scala.scalajs.js.|
1214
* @see https://nodejs.org/api/stream.html#stream_class_stream_readable
1315
*/
1416
@js.native
15-
trait ReadStream extends nodejs.stream.Readable {
17+
trait ReadStream extends Readable {
18+
19+
/////////////////////////////////////////////////////////////////////////////////
20+
// Properties
21+
/////////////////////////////////////////////////////////////////////////////////
22+
23+
/**
24+
* The number of bytes read so far.
25+
*/
26+
def bytesRead: Double = js.native
1627

1728
/**
1829
* The path to the file the stream is reading from as specified in the first argument to fs.createReadStream().
1930
* If path is passed as a string, then readStream.path will be a string. If path is passed as a Buffer, then
2031
* readStream.path will be a Buffer.
2132
*/
22-
def path: String | Buffer = js.native
33+
def path: Buffer | String = js.native
34+
35+
/////////////////////////////////////////////////////////////////////////////////
36+
// Methods
37+
/////////////////////////////////////////////////////////////////////////////////
38+
39+
/**
40+
* Undocumented method
41+
* @see https://github.com/nodejs/node-v0.x-archive/blob/cfcb1de130867197cbc9c6012b7e84e08e53d032/lib/fs.js#L1597-L1620
42+
*/
43+
def close[A](callback: js.Function1[Unit, A]): Unit = js.native
2344

2445
}
2546

@@ -35,13 +56,24 @@ object ReadStream {
3556
*/
3657
implicit class ReadStreamExtensions(val stream: ReadStream) extends AnyVal {
3758

59+
@inline
60+
def closeAsync: Promise[Unit] = promiseCallback1[Unit](stream.close)
61+
62+
}
63+
64+
/**
65+
* Read Stream Events
66+
* @author lawrence.daniels@gmail.com
67+
*/
68+
implicit class ReadStreamEvents(val stream: ReadStream) extends AnyVal {
69+
3870
/**
3971
* Emitted when the ReadStream's underlying file descriptor has been closed using the fs.close() method.
4072
* @param listener the event handler
4173
* @since 0.1.93
4274
*/
4375
@inline
44-
def onClose(listener: () => Any): stream.type = stream.on("close", listener)
76+
def onClose[A](listener: () => A): stream.type = stream.on("close", listener)
4577

4678
/**
4779
* Emitted when the ReadStream's file is opened.
@@ -52,7 +84,7 @@ object ReadStream {
5284
* @since 0.1.93
5385
*/
5486
@inline
55-
def onOpen(listener: FileDescriptor => Any): stream.type = stream.on("open", listener)
87+
def onOpen[A](listener: FileDescriptor => A): stream.type = stream.on("open", listener)
5688

5789
}
5890

src/main/scala/io/scalajs/nodejs/fs/WriteStream.scala

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
package io.scalajs.nodejs.fs
1+
package io.scalajs.nodejs
2+
package fs
23

3-
import io.scalajs.nodejs.FileDescriptor
4+
import io.scalajs.nodejs.buffer.Buffer
45
import io.scalajs.nodejs.stream.Writable
6+
import io.scalajs.util.PromiseHelper._
57

8+
import scala.concurrent.Promise
69
import scala.scalajs.js
10+
import scala.scalajs.js.|
711

812
/**
913
* fs.WriteStream - WriteStream is a Writable Stream.
@@ -12,6 +16,10 @@ import scala.scalajs.js
1216
@js.native
1317
trait WriteStream extends Writable {
1418

19+
/////////////////////////////////////////////////////////////////////////////////
20+
// Properties
21+
/////////////////////////////////////////////////////////////////////////////////
22+
1523
/**
1624
* The number of bytes written so far. Does not include data that is still queued for writing.
1725
*/
@@ -22,7 +30,17 @@ trait WriteStream extends Writable {
2230
* If path is passed as a string, then writeStream.path will be a string. If path is passed as a Buffer, then
2331
* writeStream.path will be a Buffer.
2432
*/
25-
def path: js.Any = js.native
33+
def path: Buffer | String = js.native
34+
35+
/////////////////////////////////////////////////////////////////////////////////
36+
// Methods
37+
/////////////////////////////////////////////////////////////////////////////////
38+
39+
/**
40+
* Undocumented method
41+
* @see https://github.com/nodejs/node-v0.x-archive/blob/cfcb1de130867197cbc9c6012b7e84e08e53d032/lib/fs.js#L1597-L1620
42+
*/
43+
def close[A](callback: js.Function1[Unit, A]): Unit = js.native
2644

2745
}
2846

@@ -38,12 +56,24 @@ object WriteStream {
3856
*/
3957
implicit class WriteStreamExtensions(val stream: WriteStream) extends AnyVal {
4058

59+
@inline
60+
def closeAsync: Promise[Unit] = promiseCallback1[Unit](stream.close)
61+
62+
}
63+
64+
/**
65+
* Write Stream Events
66+
* @author lawrence.daniels@gmail.com
67+
*/
68+
implicit class WriteStreamEvents(val stream: WriteStream) extends AnyVal {
69+
4170
/**
4271
* Emitted when the WriteStream's underlying file descriptor has been closed using the fs.close() method.
4372
* @param listener the event handler
4473
* @since 0.1.93
4574
*/
46-
@inline def onClose(listener: () => Any) = stream.on("close", listener)
75+
@inline
76+
def onClose[A](listener: () => A): stream.type = stream.on("close", listener)
4777

4878
/**
4979
* Emitted when the WriteStream's file is opened.
@@ -53,7 +83,8 @@ object WriteStream {
5383
* </ul>
5484
* @since 0.1.93
5585
*/
56-
@inline def onOpen(listener: FileDescriptor => Any) = stream.on("open", listener)
86+
@inline
87+
def onOpen[A](listener: FileDescriptor => A): stream.type = stream.on("open", listener)
5788

5889
}
5990

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@ import scala.scalajs.js.|
1313
*/
1414
package object fs {
1515

16+
/////////////////////////////////////////////////////////////////////////////////
17+
// Type Definitions
18+
/////////////////////////////////////////////////////////////////////////////////
19+
1620
type FileMode = Integer
1721

1822
type FileType = Int
1923

24+
/////////////////////////////////////////////////////////////////////////////////
25+
// Implicit conversions and classes
26+
/////////////////////////////////////////////////////////////////////////////////
27+
2028
/**
2129
* File System Extensions
2230
* @param fs the given [[Fs file system]] instance

src/main/scala/io/scalajs/nodejs/http/IncomingMessage.scala

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

3-
import io.scalajs.nodejs.net.Socket
4-
import io.scalajs.nodejs.stream
53
import io.scalajs.nodejs.net.Socket
64
import io.scalajs.nodejs.stream.Readable
75

@@ -111,10 +109,10 @@ object IncomingMessage {
111109
implicit class IncomingMessageExtensions(val message: IncomingMessage) extends AnyVal {
112110

113111
@inline
114-
def onClose(callback: js.Function) = message.on("close", callback)
112+
def onClose(callback: js.Function): message.type = message.on("close", callback)
115113

116114
@inline
117-
def setTimeout(duration: FiniteDuration, callback: js.Function) =
115+
def setTimeout(duration: FiniteDuration, callback: js.Function): Unit =
118116
message.setTimeout(duration.toMillis.toDouble, callback)
119117

120118
}

src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.scalajs.nodejs.http
22

33
import io.scalajs.nodejs.buffer.Buffer
44
import io.scalajs.nodejs.events.IEventEmitter
5-
import io.scalajs.nodejs.stream.Duplex
5+
import io.scalajs.nodejs.stream.IDuplex
66

77
import scala.scalajs.js
88

@@ -12,7 +12,7 @@ import scala.scalajs.js
1212
* @see [[https://nodejs.org/api/http.html#http_class_http_serverresponse]]
1313
*/
1414
@js.native
15-
trait ServerResponse extends Duplex with IEventEmitter {
15+
trait ServerResponse extends IEventEmitter with IDuplex {
1616

1717
/////////////////////////////////////////////////////////////////////////////////
1818
// Properties

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

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

33
import io.scalajs.RawOptions
4-
import io.scalajs.nodejs.stream.Duplex
4+
import io.scalajs.nodejs.stream.{Duplex, IDuplex}
55

66
import scala.scalajs.js
77
import scala.scalajs.js.annotation.JSImport
@@ -15,7 +15,7 @@ import scala.scalajs.js.|
1515
*/
1616
@js.native
1717
@JSImport("net", "Socket")
18-
class Socket extends Duplex(js.native) {
18+
class Socket extends IDuplex {
1919

2020
/////////////////////////////////////////////////////////////////////////////////
2121
// Properties

0 commit comments

Comments
 (0)