Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ldaniels528 committed Apr 18, 2017
2 parents 390a49f + 4958324 commit 47d1a3f
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 89 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ The following applications were developed using ScalaJs.io:
| Application | Frontend | Backend | Scalajs.io version | Description |
|------------------------------------------------------------------------|-----------------------|--------------------|--------------------|------------------------------------------|
| [Phaser-Invaders](https://github.com/scalajs-io/phaser-invaders-demo) | Scala.js + DOM | Scala + NodeJS | 0.3.0.1 | Port of Phaser Invaders. |
| [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. |
| [Todo MVC](https://github.com/ldaniels528/scalajs-nodejs-todomvc) | Scala.js + AngularJS | Scala.js + NodeJS | 0.2.3.1 | A simple Todo example application. |
| [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. |
| [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. |
| [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. |
| [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. |

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

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

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

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

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

<a name="npm_modules">
#### Third-party Modules
Expand Down Expand Up @@ -298,7 +298,7 @@ The following Third Party/OSS Node.js (npm) modules have been implemented:
| [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. |
| [xml2js](https://github.com/scalajs-io/xml2js) | 0.4.16 | Simple XML to JavaScript object converter. |

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

I've provided an example to demonstrate how similar the Scala.js code is to the JavaScript
that it replaces.
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sbt._

import scala.language.postfixOps

val scalaJsIOVersion = "0.4.0-pre2"
val scalaJsIOVersion = "0.4.0-pre4"
val apiVersion = scalaJsIOVersion
val scalaJsVersion = "2.12.1"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodejs-sfs",
"version": "0.4.0-pre2",
"version": "0.4.0-pre4",
"private": true,
"dependencies": {
"source-map": "^0.5.6"
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/io/scalajs/nodejs/Process.scala
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ trait Process extends IEventEmitter {
* Returns the current high-resolution real time in a [seconds, nanoseconds] tuple Array. It is relative to an
* arbitrary time in the past. It is not related to the time of day and therefore not subject to clock drift.
* The primary use is for measuring performance between intervals.
* @example process.hrtime()
* @example process.hrtime([time])
*/
def hrtime(): js.Array[Int] = js.native
def hrtime(time: js.Array[Int] = js.native): js.Array[Int] = js.native

/**
* Reads /etc/group and initializes the group access list, using all groups of which the user is a member.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/io/scalajs/nodejs/fs/Fs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ trait Fs extends IEventEmitter {
* data will be read from the current file position.
* @return the number of bytesRead.
*/
def readSync(fd: FileDescriptor, buffer: Buffer, offset: Int, length: Int, position: Int): Buffer = js.native
def readSync(fd: FileDescriptor, buffer: Buffer, offset: Int, length: Int, position: Int): Int = js.native

/**
* Asynchronous readdir(3). Reads the contents of a directory.
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/io/scalajs/nodejs/os/CPUInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scala.scalajs.js
*/
@js.native
trait CPUInfo extends js.Object {
var model: String = js.native
var speed: Double = js.native
var times: js.Array[CPUTime] = js.native
var model: String = js.native
var speed: Double = js.native
var times: js.Dictionary[Double] = js.native
}
2 changes: 1 addition & 1 deletion src/main/scala/io/scalajs/nodejs/os/OS.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ trait OS extends js.Object {
* spent in: user, nice, sys, idle, and irq).
* @example os.cpus()
*/
def cpus(): js.Array[js.Any] = js.native
def cpus(): js.Array[CPUInfo] = js.native

/**
* Returns the endianness of the CPU. Possible values are 'BE' for big endian or 'LE' for little endian.
Expand Down
22 changes: 22 additions & 0 deletions src/main/scala/io/scalajs/nodejs/os/package.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.scalajs.nodejs

import scala.scalajs.js

/**
* os package object
* @author [email protected]
*/
package object os {

/**
* CPU Info Enrichment
* @param cpuInfo the given [[CPUInfo CPU Info]]
*/
final implicit class CPUInfoEnrichment(val cpuInfo: CPUInfo) extends AnyVal {

@inline
def timesObject: js.Array[CPUTime] = cpuInfo.times.asInstanceOf[js.Array[CPUTime]]

}

}
87 changes: 87 additions & 0 deletions src/main/scala/io/scalajs/nodejs/punycode/Punycode.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package io.scalajs.nodejs.punycode

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

/**
* The version of the punycode module bundled in Node.js is being deprecated. In a future major version of Node.js
* this module will be removed. Users currently depending on the punycode module should switch to using the
* userland-provided Punycode.js module instead.
* @see https://nodejs.org/dist/latest-v7.x/docs/api/punycode.html
*/
@js.native
trait Punycode extends js.Object {

/**
* The punycode.decode() method converts a Punycode string of ASCII-only characters to the equivalent
* string of Unicode codepoints.
* @param string a Punycode string of ASCII-only characters
* @return the equivalent string of Unicode codepoints.
*/
def decode(string: String): String = js.native

/**
* The punycode.encode() method converts a string of Unicode codepoints to a Punycode string of ASCII-only characters.
* @param codePoints a string of Unicode codepoints
* @return a Punycode string of ASCII-only characters.
*/
def encode(codePoints: String): String = js.native

/**
* The punycode.toASCII() method converts a Unicode string representing an Internationalized Domain Name to Punycode.
* Only the non-ASCII parts of the domain name will be converted. Calling punycode.toASCII() on a string that already
* only contains ASCII characters will have no effect.
* @param domain the domain name
* @return a Unicode string representing an Internationalized Domain Name as Punycode
*/
def toASCII(domain: String): String = js.native

/**
* The punycode.toUnicode() method converts a string representing a domain name containing Punycode encoded
* characters into Unicode. Only the Punycode encoded parts of the domain name are be converted.
* @param domain a string representing a domain name containing Punycode encoded characters
* @return the Unicode string
*/
def toUnicode(domain: String): String = js.native

/**
* The UCS2 object
* @return The [[UCS2 UCS2]] object
*/
def ucs2: UCS2 = js.native

/**
* Returns a string identifying the current Punycode.js version number.
* @return a string identifying the current Punycode.js version number.
*/
def version: String = js.native

}

/**
* Punycode.UCS2
* @see https://nodejs.org/dist/latest-v7.x/docs/api/punycode.html
*/
@js.native
trait UCS2 extends js.Object {

/**
* The punycode.ucs2.decode() method returns an array containing the numeric codepoint values of each Unicode
* symbol in the string.
* @param string the string containing Unicode symbols
* @return an array containing the numeric codepoint values of each Unicode symbol
*/
def decode(string: String): js.Array[Int] = js.native

/**
* The punycode.ucs2.encode() method returns a string based on an array of numeric code point values.
* @param codePoints an array of numeric code point values
* @return a string based on an array of numeric code point values
*/
def encode(codePoints: js.Array[Int]): String = js.native

}

@js.native
@JSImport("punycode", JSImport.Namespace)
object Punycode extends Punycode
27 changes: 14 additions & 13 deletions src/main/scala/io/scalajs/nodejs/stream/Writable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,29 +138,32 @@ trait Writable extends IEventEmitter {
/**
* Flush all data, buffered since stream.cork() call.
* @param chunk The data to write (<String> | <Buffer>)
* @param encoding The encoding, if chunk is a String
* @param callback the Callback for when this chunk of data is flushed
* @return true, if the data was handled completely
* @example writable.write(chunk[, encoding][, callback])
*/
def write(chunk: String, encoding: String, callback: js.Function1[Error, Any]): Boolean = js.native
def write(chunk: Buffer | String, callback: js.Function1[Error, Any] = js.native): Boolean = js.native

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

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

}

Expand All @@ -174,7 +177,7 @@ object Writable {
* Writable Events
* @author [email protected]
*/
implicit class WritableEvents(val writable: Writable) extends AnyVal {
implicit class WritableEvents[T <: Writable](val writable: T) extends AnyVal {

/**
* Emitted when the stream and any of its underlying resources (a file descriptor, for example) have been closed.
Expand Down Expand Up @@ -223,7 +226,7 @@ object Writable {
* Writable Extensions
* @author [email protected]
*/
implicit class WritableExtensions(val writable: Writable) extends AnyVal {
implicit class WritableExtensions[T <: Writable](val writable: T) extends AnyVal {

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

@inline
def writeAsync(chunk: Buffer): Promise[Unit] = promiseWithError0[Error](writable.write(chunk, _))

@inline
def writeAsync(chunk: String, encoding: String = null): Promise[Unit] = {
def writeAsync(chunk: Buffer | String, encoding: String = null): Promise[Unit] = {
promiseWithError0[Error](writable.write(chunk, encoding, _))
}

Expand All @@ -254,5 +254,6 @@ object Writable {
* @param encoding the data's optional encoding
*/
@ScalaJSDefined
class Chunk(val chunk: Buffer | String, val encoding: js.UndefOr[String] = js.undefined)
class Chunk(val chunk: Buffer | String,
val encoding: js.UndefOr[String] = js.undefined)
extends js.Object
5 changes: 3 additions & 2 deletions src/main/scala/io/scalajs/nodejs/timers/ClearImmediate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import scala.scalajs.js
trait ClearImmediate extends js.Object {

/**
* Stops an immediateObject, as created by setImmediate, from triggering.
* Stops an immediate, as created by setImmediate, from triggering.
* @param handle the immediate handle
* @example clearImmediate(immediateObject)
*/
def apply(immediateObject: Immediate): Unit = js.native
def apply(handle: Immediate): Unit = js.native

}
4 changes: 2 additions & 2 deletions src/main/scala/io/scalajs/nodejs/timers/ClearInterval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import scala.scalajs.js
trait ClearInterval extends js.Object {

/**
* Stops an intervalObject, as created by setInterval, from triggering.
* Stops an interval, as created by setInterval, from triggering.
* @example clearInterval(intervalObject)
*/
def apply(intervalObject: Interval): Unit = js.native
def apply(handle: Timeout): Unit = js.native

}
4 changes: 2 additions & 2 deletions src/main/scala/io/scalajs/nodejs/timers/ClearTimeout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import scala.scalajs.js
trait ClearTimeout extends js.Object {

/**
* Prevents a timeoutObject, as created by setTimeout, from triggering.
* Prevents a timeout, as created by setTimeout, from triggering.
* @example clearTimeout(timeoutObject)
*/
def apply(timeoutObject: Timeout): Unit = js.native
def apply(handle: Timeout): Unit = js.native

}
50 changes: 0 additions & 50 deletions src/main/scala/io/scalajs/nodejs/timers/Interval.scala

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/scala/io/scalajs/nodejs/timers/SetInterval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ trait SetInterval extends js.Object {
* or less than 1, Node.js will use 1 as the delay.
* @example setInterval(callback, delay[, arg][, ...])
*/
def apply(callback: js.Function, delay: Int, args: js.Any*): Interval = js.native
def apply(callback: js.Function, delay: Int, args: js.Any*): Timeout = js.native

}
6 changes: 3 additions & 3 deletions src/main/scala/io/scalajs/nodejs/timers/Timeout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ object Timeout {

/**
* Timeout Enrichment
* @param Timeout the given [[Timeout Timeout]] handle
* @param handle the given [[Timeout timeout]] handle
*/
implicit class TimeoutEnrichment(val Timeout: Timeout) extends AnyVal {
implicit class TimeoutEnrichment(val handle: Timeout) extends AnyVal {

@inline
def clear(): Unit = clearTimeout(Timeout)
def clear(): Unit = clearTimeout(handle)

}

Expand Down
Loading

0 comments on commit 47d1a3f

Please sign in to comment.