Skip to content

Commit 33f360d

Browse files
author
Lawrence Daniels
committed
Updating to Node v8.7.0 API
1 parent 88691a6 commit 33f360d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+832
-373
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Scala template
13
*.class
24
*.log
35

@@ -6,7 +8,9 @@
68
.history
79
.lib/
810
dist/*
9-
target/
11+
project/target/*
12+
project/project/*
13+
target/*
1014
lib_managed/
1115
src_managed/
1216
project/boot/
@@ -18,4 +22,5 @@ project/plugins/project/
1822

1923
#Intellij
2024
.idea
25+
2126
1.txt

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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" %%% "nodejs" % "0.4.1"
234+
*NOTE*: The SBT artifact for the complete Node.js platform is: "io.scalajs" %%% "nodejs" % "0.4.2"
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.1")
301+
*NOTE*: The full SBT artifact expression is: "io.scalajs.npm" %%% "xxxx" % version (e.g. "io.scalajs.npm" %%% "express" % "0.4.2")
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: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,29 @@ import sbt._
55

66
import scala.language.postfixOps
77

8-
val scalaJsIOVersion = "0.4.1"
8+
val scalaJsIOVersion = "0.4.2"
99
val apiVersion = scalaJsIOVersion
1010
val scalaJsVersion = "2.12.3"
1111

12-
organization := "io.scalajs"
13-
14-
homepage := Some(url("https://github.com/scalajs-io/nodejs"))
15-
1612
lazy val root = (project in file(".")).
1713
enablePlugins(ScalaJSPlugin).
1814
settings(
1915
name := "nodejs",
2016
version := apiVersion,
2117
organization := "io.scalajs",
2218
description := "NodeJS bindings for Scala.js",
19+
homepage := Some(url("https://github.com/scalajs-io/nodejs")),
2320
scalaVersion := scalaJsVersion,
2421
scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-language:implicitConversions", "-Xlint"),
22+
scalacOptions += "-P:scalajs:sjsDefinedByDefault",
2523
scalacOptions in(Compile, doc) ++= Seq("-no-link-warnings"),
2624
autoCompilerPlugins := true,
2725
scalaJSModuleKind := ModuleKind.CommonJSModule,
2826
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full),
29-
logBuffered in Test := false,
27+
logBuffered in Test := true,
3028
libraryDependencies ++= Seq(
3129
"org.scala-lang" % "scala-reflect" % scalaJsVersion,
30+
"org.scalactic" %% "scalactic" % "3.0.1",
3231
"org.scalatest" %%% "scalatest" % "3.0.1" % "test",
3332
"io.scalajs" %%% "core" % scalaJsIOVersion
3433
))

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.1",
3+
"version": "0.4.2",
44
"private": true,
55
"dependencies": {
66
"source-map-support": "^0.4.14"

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.5.5")
88

99
// Testing
1010

11-
//addSbtPlugin("com.artima.supersafe" % "sbtplugin" % "1.1.0")
11+
//addSbtPlugin("com.artima.supersafe" % "sbtplugin" % "1.1.2")
1212

1313
// Publishing
1414

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

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.scalajs.nodejs
33
import io.scalajs.nodejs.stream.Writable
44

55
import scala.scalajs.js
6-
import scala.scalajs.js.annotation.{JSImport, ScalaJSDefined}
6+
import scala.scalajs.js.annotation.JSImport
77

88
/**
99
* The console module provides a simple debugging console that is similar to the JavaScript console mechanism
@@ -16,7 +16,7 @@ import scala.scalajs.js.annotation.{JSImport, ScalaJSDefined}
1616
* <li>A global console instance configured to write to stdout and stderr. Because this object is global, it can be
1717
* used without calling require('console').</li>
1818
* </ul>
19-
* @see https://nodejs.org/api/console.html
19+
* @see https://nodejs.org/dist/latest-v8.x/docs/api/console.html
2020
* @author lawrence.daniels@gmail.com
2121
*/
2222
@js.native
@@ -37,6 +37,28 @@ class Console(stdout: Writable, stderr: Writable = js.native) extends js.Object
3737
*/
3838
def assert(value: js.Any, args: Any*): Unit = js.native
3939

40+
/**
41+
* When stdout is a TTY, calling console.clear() will attempt to clear the TTY. When stdout is not a TTY,
42+
* this method does nothing.
43+
*
44+
* Note: The specific operation of console.clear() can vary across operating systems and terminal types.
45+
* For most Linux operating systems, console.clear() operates similarly to the clear shell command.
46+
* On Windows, console.clear() will clear only the output in the current terminal viewport for the Node.js binary.
47+
*/
48+
def clear(): Unit = js.native
49+
50+
/**
51+
* Maintains an internal counter specific to label and outputs to stdout the number of times console.count() has been called with the given label.
52+
* @param label the display label for the counter. Defaults to 'default'.
53+
*/
54+
def count(label: String = js.native): Unit = js.native
55+
56+
/**
57+
* Resets the internal counter specific to label.
58+
* @param label the display label for the counter. Defaults to 'default'.
59+
*/
60+
def countReset(label: String = js.native): Unit = js.native
61+
4062
/**
4163
* Uses util.inspect() on obj and prints the resulting string to stdout.
4264
* This function bypasses any custom inspect() function defined on obj
@@ -59,6 +81,23 @@ class Console(stdout: Writable, stderr: Writable = js.native) extends js.Object
5981
*/
6082
def error(data: js.Any, args: Any*): Unit = js.native
6183

84+
/**
85+
* Increases indentation of subsequent lines by two spaces.
86+
* If one or more labels are provided, those are printed first without the additional indentation.
87+
* @param label the labels
88+
*/
89+
def group(label: js.Any*): Unit = js.native
90+
91+
/**
92+
* An alias for console.group().
93+
*/
94+
def groupCollapsed(): Unit = js.native
95+
96+
/**
97+
* Decreases indentation of subsequent lines by two spaces.
98+
*/
99+
def groupEnd(): Unit = js.native
100+
62101
/**
63102
* The console.info() function is an alias for console.log().
64103
* @example console.info([data][, ...])
@@ -113,6 +152,7 @@ class Console(stdout: Writable, stderr: Writable = js.native) extends js.Object
113152
* see customizing util.inspect() colors.
114153
* @author lawrence.daniels@gmail.com
115154
*/
116-
@ScalaJSDefined
117-
class ConsoleDirOptions(var showHidden: Boolean = false, var depth: Integer = 2, var colors: Boolean = false)
155+
class ConsoleDirOptions(var showHidden: js.UndefOr[Boolean] = js.undefined,
156+
var depth: js.UndefOr[Int] = js.undefined,
157+
var colors: js.UndefOr[Boolean] = js.undefined)
118158
extends js.Object

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

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

33
import scala.scalajs.js
4-
import scala.scalajs.js.annotation.{JSGlobal, JSImport, JSName}
4+
import scala.scalajs.js.annotation.{JSGlobal, JSImport}
55

66
/**
77
* Creates a new Error object and sets the error.message property to the provided text message.
@@ -13,7 +13,7 @@ import scala.scalajs.js.annotation.{JSGlobal, JSImport, JSName}
1313
* @author lawrence.daniels@gmail.com
1414
*/
1515
@js.native
16-
@JSGlobal("Error")
16+
@JSImport("errors", "Error")
1717
class Error(message0: String = js.native) extends js.Object {
1818

1919
/**
@@ -36,7 +36,7 @@ class Error(message0: String = js.native) extends js.Object {
3636
* @author lawrence.daniels@gmail.com
3737
*/
3838
@js.native
39-
@JSImport("errors", "Error")
39+
@JSGlobal
4040
object Error extends js.Object {
4141

4242
/////////////////////////////////////////////////////////////////////////////////

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ class SystemError(message0: String = js.native) extends Error(message0) {
5555
* @author lawrence.daniels@gmail.com
5656
*/
5757
@js.native
58-
@JSImport("errors", "SystemError")
58+
@JSImport("errors", JSImport.Namespace)
5959
object SystemError extends Error

src/main/scala/io/scalajs/nodejs/buffer/Buffer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.scalajs.nodejs.buffer
33
import io.scalajs.collection.Iterator
44

55
import scala.scalajs.js
6-
import scala.scalajs.js.annotation.{JSBracketAccess, JSGlobal, JSImport, JSName}
6+
import scala.scalajs.js.annotation.{JSBracketAccess, JSGlobal, JSImport}
77
import scala.scalajs.js.typedarray.ArrayBuffer
88
import scala.scalajs.js.|
99

@@ -839,7 +839,7 @@ class Buffer() extends js.Object {
839839
}
840840

841841
@js.native
842-
@JSGlobal("Buffer")
842+
@JSGlobal
843843
object Buffer extends js.Object {
844844

845845
/////////////////////////////////////////////////////////////////////////////////

src/main/scala/io/scalajs/nodejs/child_process/ExecOptions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package child_process
44
import io.scalajs.JsNumber
55

66
import scala.scalajs.js
7-
import scala.scalajs.js.annotation.ScalaJSDefined
7+
88

99
/**
1010
* Spawns a shell then executes the command within that shell, buffering any generated output.
@@ -24,7 +24,7 @@ import scala.scalajs.js.annotation.ScalaJSDefined
2424
* @param uid <Number> Sets the user identity of the process. (See setuid(2).)
2525
* @param gid <Number> Sets the group identity of the process. (See setgid(2).)
2626
*/
27-
@ScalaJSDefined
27+
2828
class ExecOptions(val cwd: js.UndefOr[String] = js.undefined,
2929
val env: js.Any = js.undefined,
3030
val encoding: js.UndefOr[String] = js.undefined,

src/main/scala/io/scalajs/nodejs/child_process/ForkOptions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package child_process
44
import io.scalajs.JsNumber
55

66
import scala.scalajs.js
7-
import scala.scalajs.js.annotation.ScalaJSDefined
7+
88

99
/**
1010
* Fork Options
@@ -22,7 +22,7 @@ import scala.scalajs.js.annotation.ScalaJSDefined
2222
* @param gid <Number> Sets the group identity of the process. (See setgid(2).)
2323
* @author lawrence.daniels@gmail.com
2424
*/
25-
@ScalaJSDefined
25+
2626
class ForkOptions(val cwd: js.UndefOr[String] = js.undefined,
2727
val env: js.Any = js.undefined,
2828
val execPath: js.UndefOr[String] = js.undefined,

src/main/scala/io/scalajs/nodejs/child_process/SpawnOptions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.scalajs.nodejs.child_process
33
import io.scalajs.JsNumber
44

55
import scala.scalajs.js
6-
import scala.scalajs.js.annotation.ScalaJSDefined
6+
77
import scala.scalajs.js.|
88

99
/**
@@ -22,7 +22,7 @@ import scala.scalajs.js.|
2222
* The shell should understand the -c switch on UNIX, or /d /s /c on Windows. Defaults to false (no shell).
2323
* @author lawrence.daniels@gmail.com
2424
*/
25-
@ScalaJSDefined
25+
2626
class SpawnOptions(val cwd: js.UndefOr[String] = js.undefined,
2727
val env: js.Any = js.undefined,
2828
val argv0: js.UndefOr[String] = js.undefined,

src/main/scala/io/scalajs/nodejs/dns/DnsOptions.scala

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

33
import scala.scalajs.js
4-
import scala.scalajs.js.annotation.ScalaJSDefined
4+
55

66
/**
77
* DNS Options
@@ -14,7 +14,7 @@ import scala.scalajs.js.annotation.ScalaJSDefined
1414
* single address. Defaults to false.
1515
* @author lawrence.daniels@gmail.com
1616
*/
17-
@ScalaJSDefined
17+
1818
class DnsOptions(var family: js.UndefOr[Int] = js.undefined,
1919
var hints: js.UndefOr[Int] = js.undefined,
2020
var all: js.UndefOr[Boolean] = js.undefined)

src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala

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

33
import scala.scalajs.js
4-
import scala.scalajs.js.annotation.{JSGlobal, JSImport, JSName}
4+
import scala.scalajs.js.annotation.JSImport
55

66
/**
77
* Much of the Node.js core API is built around an idiomatic asynchronous event-driven architecture
@@ -140,7 +140,7 @@ trait IEventEmitter extends js.Object {
140140
* @author lawrence.daniels@gmail.com
141141
*/
142142
@js.native
143-
@JSGlobal("EventEmitter")
143+
@JSImport("events", JSImport.Namespace)
144144
object EventEmitter extends IEventEmitter {
145145

146146
/**

0 commit comments

Comments
 (0)