Skip to content

Commit 47d1a3f

Browse files
committed
Merge branch 'master' into develop
2 parents 390a49f + 4958324 commit 47d1a3f

File tree

17 files changed

+150
-89
lines changed

17 files changed

+150
-89
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ The following applications were developed using ScalaJs.io:
7676
| Application | Frontend | Backend | Scalajs.io version | Description |
7777
|------------------------------------------------------------------------|-----------------------|--------------------|--------------------|------------------------------------------|
7878
| [Phaser-Invaders](https://github.com/scalajs-io/phaser-invaders-demo) | Scala.js + DOM | Scala + NodeJS | 0.3.0.1 | Port of Phaser Invaders. |
79-
| [Socialize](https://github.com/ldaniels528/scalajs-nodejs-socialized) | Scala.js + AngularJS | Scala.js + NodeJS | 0.3.0.3 | A Facebook-inspired Social networking web application. |
80-
| [Todo MVC](https://github.com/ldaniels528/scalajs-nodejs-todomvc) | Scala.js + AngularJS | Scala.js + NodeJS | 0.2.3.1 | A simple Todo example application. |
81-
| [Trifecta](https://github.com/ldaniels528/trifecta) | Scala.js + AngularJS | Scala + Play 2.4.x | 0.3.0.0 | Trifecta is a web-based and CLI tool that simplifies inspecting Kafka messages and Zookeeper data. |
79+
| [Socialize](https://github.com/scalajs-io/scalajs-nodejs-socialized) | Scala.js + AngularJS | Scala.js + NodeJS | 0.3.0.3 | A Facebook-inspired Social networking web application. |
80+
| [Todo MVC](https://github.com/scalajs-io/scalajs-nodejs-todomvc) | Scala.js + AngularJS | Scala.js + NodeJS | 0.2.3.1 | A simple Todo example application. |
81+
| [Trifecta](https://github.com/scalajs-io/trifecta) | Scala.js + AngularJS | Scala + Play 2.4.x | 0.3.0.0 | Trifecta is a web-based and CLI tool that simplifies inspecting Kafka messages and Zookeeper data. |
8282

8383
### The MEAN Stack — AngularJS, MongoDB, Mongoose, Express and more
8484

@@ -101,7 +101,7 @@ The following applications were developed using ScalaJs.io:
101101
| [mongoose](https://github.com/scalajs-io/mongoose) | 4.8.1 | Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. |
102102
| [mpromise](https://github.com/scalajs-io/mpromise) | 0.5.5 | A promises/A+ conformant implementation, written for mongoose. |
103103

104-
Looking for a complete list of available bindings? Go [here](https://github.com/scalajs-io/scalajs.io-platform)
104+
Looking for a complete list of available bindings? Go [here](https://github.com/scalajs-io/scalajs-io-platform)
105105

106106
<a name="discussions"></a>
107107
### Discussions
@@ -231,7 +231,7 @@ The following core Node.js modules (v7.7.1) have been implemented:
231231
| vm | The vm module provides APIs for compiling and running code within V8 Virtual Machine contexts.|
232232
| zlib | This provides bindings to Gzip/Gunzip, Deflate/Inflate, and DeflateRaw/InflateRaw classes. |
233233

234-
*NOTE*: The SBT artifact for the complete Node.js platform is: "io.scalajs.npm" %%% "nodejs" % "0.4.0-pre2"
234+
*NOTE*: The SBT artifact for the complete Node.js platform is: "io.scalajs.npm" %%% "nodejs" % "0.4.0-pre4"
235235

236236
<a name="npm_modules">
237237
#### Third-party Modules
@@ -298,7 +298,7 @@ The following Third Party/OSS Node.js (npm) modules have been implemented:
298298
| [winston-daily-rotate-file](https://github.com/scalajs-io/winston-daily-rotate-file) | 1.4.4 | A multi-transport async logging library for Node.js. |
299299
| [xml2js](https://github.com/scalajs-io/xml2js) | 0.4.16 | Simple XML to JavaScript object converter. |
300300

301-
*NOTE*: The full SBT artifact expression is: "io.scalajs.npm" %%% "xxxx" % version (e.g. "io.scalajs.npm" %%% "express" % "0.4.0-pre2")
301+
*NOTE*: The full SBT artifact expression is: "io.scalajs.npm" %%% "xxxx" % version (e.g. "io.scalajs.npm" %%% "express" % "0.4.0-pre4")
302302

303303
I've provided an example to demonstrate how similar the Scala.js code is to the JavaScript
304304
that it replaces.

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import sbt._
55

66
import scala.language.postfixOps
77

8-
val scalaJsIOVersion = "0.4.0-pre2"
8+
val scalaJsIOVersion = "0.4.0-pre4"
99
val apiVersion = scalaJsIOVersion
1010
val scalaJsVersion = "2.12.1"
1111

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.4.0-pre2",
3+
"version": "0.4.0-pre4",
44
"private": true,
55
"dependencies": {
66
"source-map": "^0.5.6"

src/main/scala/io/scalajs/nodejs/Process.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ trait Process extends IEventEmitter {
245245
* Returns the current high-resolution real time in a [seconds, nanoseconds] tuple Array. It is relative to an
246246
* arbitrary time in the past. It is not related to the time of day and therefore not subject to clock drift.
247247
* The primary use is for measuring performance between intervals.
248-
* @example process.hrtime()
248+
* @example process.hrtime([time])
249249
*/
250-
def hrtime(): js.Array[Int] = js.native
250+
def hrtime(time: js.Array[Int] = js.native): js.Array[Int] = js.native
251251

252252
/**
253253
* Reads /etc/group and initializes the group access list, using all groups of which the user is a member.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ trait Fs extends IEventEmitter {
674674
* data will be read from the current file position.
675675
* @return the number of bytesRead.
676676
*/
677-
def readSync(fd: FileDescriptor, buffer: Buffer, offset: Int, length: Int, position: Int): Buffer = js.native
677+
def readSync(fd: FileDescriptor, buffer: Buffer, offset: Int, length: Int, position: Int): Int = js.native
678678

679679
/**
680680
* Asynchronous readdir(3). Reads the contents of a directory.

src/main/scala/io/scalajs/nodejs/os/CPUInfo.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import scala.scalajs.js
88
*/
99
@js.native
1010
trait CPUInfo extends js.Object {
11-
var model: String = js.native
12-
var speed: Double = js.native
13-
var times: js.Array[CPUTime] = js.native
11+
var model: String = js.native
12+
var speed: Double = js.native
13+
var times: js.Dictionary[Double] = js.native
1414
}

src/main/scala/io/scalajs/nodejs/os/OS.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ trait OS extends js.Object {
5050
* spent in: user, nice, sys, idle, and irq).
5151
* @example os.cpus()
5252
*/
53-
def cpus(): js.Array[js.Any] = js.native
53+
def cpus(): js.Array[CPUInfo] = js.native
5454

5555
/**
5656
* Returns the endianness of the CPU. Possible values are 'BE' for big endian or 'LE' for little endian.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.scalajs.nodejs
2+
3+
import scala.scalajs.js
4+
5+
/**
6+
* os package object
7+
* @author lawrence.daniels@gmail.com
8+
*/
9+
package object os {
10+
11+
/**
12+
* CPU Info Enrichment
13+
* @param cpuInfo the given [[CPUInfo CPU Info]]
14+
*/
15+
final implicit class CPUInfoEnrichment(val cpuInfo: CPUInfo) extends AnyVal {
16+
17+
@inline
18+
def timesObject: js.Array[CPUTime] = cpuInfo.times.asInstanceOf[js.Array[CPUTime]]
19+
20+
}
21+
22+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package io.scalajs.nodejs.punycode
2+
3+
import scala.scalajs.js
4+
import scala.scalajs.js.annotation.JSImport
5+
6+
/**
7+
* The version of the punycode module bundled in Node.js is being deprecated. In a future major version of Node.js
8+
* this module will be removed. Users currently depending on the punycode module should switch to using the
9+
* userland-provided Punycode.js module instead.
10+
* @see https://nodejs.org/dist/latest-v7.x/docs/api/punycode.html
11+
*/
12+
@js.native
13+
trait Punycode extends js.Object {
14+
15+
/**
16+
* The punycode.decode() method converts a Punycode string of ASCII-only characters to the equivalent
17+
* string of Unicode codepoints.
18+
* @param string a Punycode string of ASCII-only characters
19+
* @return the equivalent string of Unicode codepoints.
20+
*/
21+
def decode(string: String): String = js.native
22+
23+
/**
24+
* The punycode.encode() method converts a string of Unicode codepoints to a Punycode string of ASCII-only characters.
25+
* @param codePoints a string of Unicode codepoints
26+
* @return a Punycode string of ASCII-only characters.
27+
*/
28+
def encode(codePoints: String): String = js.native
29+
30+
/**
31+
* The punycode.toASCII() method converts a Unicode string representing an Internationalized Domain Name to Punycode.
32+
* Only the non-ASCII parts of the domain name will be converted. Calling punycode.toASCII() on a string that already
33+
* only contains ASCII characters will have no effect.
34+
* @param domain the domain name
35+
* @return a Unicode string representing an Internationalized Domain Name as Punycode
36+
*/
37+
def toASCII(domain: String): String = js.native
38+
39+
/**
40+
* The punycode.toUnicode() method converts a string representing a domain name containing Punycode encoded
41+
* characters into Unicode. Only the Punycode encoded parts of the domain name are be converted.
42+
* @param domain a string representing a domain name containing Punycode encoded characters
43+
* @return the Unicode string
44+
*/
45+
def toUnicode(domain: String): String = js.native
46+
47+
/**
48+
* The UCS2 object
49+
* @return The [[UCS2 UCS2]] object
50+
*/
51+
def ucs2: UCS2 = js.native
52+
53+
/**
54+
* Returns a string identifying the current Punycode.js version number.
55+
* @return a string identifying the current Punycode.js version number.
56+
*/
57+
def version: String = js.native
58+
59+
}
60+
61+
/**
62+
* Punycode.UCS2
63+
* @see https://nodejs.org/dist/latest-v7.x/docs/api/punycode.html
64+
*/
65+
@js.native
66+
trait UCS2 extends js.Object {
67+
68+
/**
69+
* The punycode.ucs2.decode() method returns an array containing the numeric codepoint values of each Unicode
70+
* symbol in the string.
71+
* @param string the string containing Unicode symbols
72+
* @return an array containing the numeric codepoint values of each Unicode symbol
73+
*/
74+
def decode(string: String): js.Array[Int] = js.native
75+
76+
/**
77+
* The punycode.ucs2.encode() method returns a string based on an array of numeric code point values.
78+
* @param codePoints an array of numeric code point values
79+
* @return a string based on an array of numeric code point values
80+
*/
81+
def encode(codePoints: js.Array[Int]): String = js.native
82+
83+
}
84+
85+
@js.native
86+
@JSImport("punycode", JSImport.Namespace)
87+
object Punycode extends Punycode

src/main/scala/io/scalajs/nodejs/stream/Writable.scala

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,29 +138,32 @@ trait Writable extends IEventEmitter {
138138
/**
139139
* Flush all data, buffered since stream.cork() call.
140140
* @param chunk The data to write (<String> | <Buffer>)
141-
* @param encoding The encoding, if chunk is a String
142141
* @param callback the Callback for when this chunk of data is flushed
143142
* @return true, if the data was handled completely
144143
* @example writable.write(chunk[, encoding][, callback])
145144
*/
146-
def write(chunk: String, encoding: String, callback: js.Function1[Error, Any]): Boolean = js.native
145+
def write(chunk: Buffer | String, callback: js.Function1[Error, Any] = js.native): Boolean = js.native
147146

148147
/**
149148
* Flush all data, buffered since stream.cork() call.
150149
* @param chunk The data to write (<String> | <Buffer>)
151-
* @param callback the Callback for when this chunk of data is flushed
150+
* @param encoding The encoding, if chunk is a String
152151
* @return true, if the data was handled completely
153152
* @example writable.write(chunk[, encoding][, callback])
154153
*/
155-
def write(chunk: String, callback: js.Function1[Error, Any]): Boolean = js.native
154+
def write(chunk: Buffer | String, encoding: String): Boolean = js.native
156155

157156
/**
158157
* Flush all data, buffered since stream.cork() call.
159-
* @param chunk The data to write (<String> | <Buffer>)
158+
* @param chunk The data to write (<String> | <Buffer>)
159+
* @param encoding The encoding, if chunk is a String
160+
* @param callback the Callback for when this chunk of data is flushed
160161
* @return true, if the data was handled completely
161162
* @example writable.write(chunk[, encoding][, callback])
162163
*/
163-
def write(chunk: Buffer, callback: js.Function1[Error, Any]): Boolean = js.native
164+
def write(chunk: Buffer | String,
165+
encoding: String,
166+
callback: js.Function1[Error, Any]): Boolean = js.native
164167

165168
}
166169

@@ -174,7 +177,7 @@ object Writable {
174177
* Writable Events
175178
* @author lawrence.daniels@gmail.com
176179
*/
177-
implicit class WritableEvents(val writable: Writable) extends AnyVal {
180+
implicit class WritableEvents[T <: Writable](val writable: T) extends AnyVal {
178181

179182
/**
180183
* Emitted when the stream and any of its underlying resources (a file descriptor, for example) have been closed.
@@ -223,7 +226,7 @@ object Writable {
223226
* Writable Extensions
224227
* @author lawrence.daniels@gmail.com
225228
*/
226-
implicit class WritableExtensions(val writable: Writable) extends AnyVal {
229+
implicit class WritableExtensions[T <: Writable](val writable: T) extends AnyVal {
227230

228231
@inline
229232
def endAsync(chunk: Buffer): Promise[Unit] = promiseWithError0[Error](writable.end(chunk, _))
@@ -237,10 +240,7 @@ object Writable {
237240
def endAsync(): Promise[Unit] = promiseWithError0[Error](writable.end)
238241

239242
@inline
240-
def writeAsync(chunk: Buffer): Promise[Unit] = promiseWithError0[Error](writable.write(chunk, _))
241-
242-
@inline
243-
def writeAsync(chunk: String, encoding: String = null): Promise[Unit] = {
243+
def writeAsync(chunk: Buffer | String, encoding: String = null): Promise[Unit] = {
244244
promiseWithError0[Error](writable.write(chunk, encoding, _))
245245
}
246246

@@ -254,5 +254,6 @@ object Writable {
254254
* @param encoding the data's optional encoding
255255
*/
256256
@ScalaJSDefined
257-
class Chunk(val chunk: Buffer | String, val encoding: js.UndefOr[String] = js.undefined)
257+
class Chunk(val chunk: Buffer | String,
258+
val encoding: js.UndefOr[String] = js.undefined)
258259
extends js.Object

src/main/scala/io/scalajs/nodejs/timers/ClearImmediate.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import scala.scalajs.js
1010
trait ClearImmediate extends js.Object {
1111

1212
/**
13-
* Stops an immediateObject, as created by setImmediate, from triggering.
13+
* Stops an immediate, as created by setImmediate, from triggering.
14+
* @param handle the immediate handle
1415
* @example clearImmediate(immediateObject)
1516
*/
16-
def apply(immediateObject: Immediate): Unit = js.native
17+
def apply(handle: Immediate): Unit = js.native
1718

1819
}

src/main/scala/io/scalajs/nodejs/timers/ClearInterval.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import scala.scalajs.js
1010
trait ClearInterval extends js.Object {
1111

1212
/**
13-
* Stops an intervalObject, as created by setInterval, from triggering.
13+
* Stops an interval, as created by setInterval, from triggering.
1414
* @example clearInterval(intervalObject)
1515
*/
16-
def apply(intervalObject: Interval): Unit = js.native
16+
def apply(handle: Timeout): Unit = js.native
1717

1818
}

src/main/scala/io/scalajs/nodejs/timers/ClearTimeout.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import scala.scalajs.js
1010
trait ClearTimeout extends js.Object {
1111

1212
/**
13-
* Prevents a timeoutObject, as created by setTimeout, from triggering.
13+
* Prevents a timeout, as created by setTimeout, from triggering.
1414
* @example clearTimeout(timeoutObject)
1515
*/
16-
def apply(timeoutObject: Timeout): Unit = js.native
16+
def apply(handle: Timeout): Unit = js.native
1717

1818
}

src/main/scala/io/scalajs/nodejs/timers/Interval.scala

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/main/scala/io/scalajs/nodejs/timers/SetInterval.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ trait SetInterval extends js.Object {
1818
* or less than 1, Node.js will use 1 as the delay.
1919
* @example setInterval(callback, delay[, arg][, ...])
2020
*/
21-
def apply(callback: js.Function, delay: Int, args: js.Any*): Interval = js.native
21+
def apply(callback: js.Function, delay: Int, args: js.Any*): Timeout = js.native
2222

2323
}

src/main/scala/io/scalajs/nodejs/timers/Timeout.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ object Timeout {
2727

2828
/**
2929
* Timeout Enrichment
30-
* @param Timeout the given [[Timeout Timeout]] handle
30+
* @param handle the given [[Timeout timeout]] handle
3131
*/
32-
implicit class TimeoutEnrichment(val Timeout: Timeout) extends AnyVal {
32+
implicit class TimeoutEnrichment(val handle: Timeout) extends AnyVal {
3333

3434
@inline
35-
def clear(): Unit = clearTimeout(Timeout)
35+
def clear(): Unit = clearTimeout(handle)
3636

3737
}
3838

0 commit comments

Comments
 (0)