-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* master: Fixed SBT dependency Continued development 1. Added puny code (although it’s deprecated) 2. Fixes on stream.Writable class 3. Fixes for setInterval function 4. Fixed issue with process.hrtime() Pre-release v0.4.0-pre3: Miscellaneous fixes in OS and Stream packages Improved the repl binding # Conflicts: # src/main/scala/io/scalajs/nodejs/stream/Writable.scala
- Loading branch information
Showing
18 changed files
with
245 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package io.scalajs.nodejs | ||
|
||
import scala.scalajs.js | ||
|
||
/** | ||
* repl package object | ||
* @author [email protected] | ||
*/ | ||
package object repl { | ||
|
||
type REPLContext = js.Dynamic | ||
|
||
/** | ||
* REPL Server events | ||
* @param server the given [[REPLServer instance]] | ||
*/ | ||
final implicit class REPLServerEvents(val server: REPLServer) extends AnyVal { | ||
|
||
@inline | ||
def contextAs[T]: T = server.context.asInstanceOf[T] | ||
|
||
/** | ||
* The 'exit' event is emitted when the REPL is exited either by receiving the .exit command as input, | ||
* the user pressing CTRL-C twice to signal SIGINT, or by pressing CTRL-D to signal 'end' on the input stream. | ||
* The listener callback is invoked without any arguments. | ||
* @param listener The listener callback | ||
*/ | ||
@inline | ||
def onExit(listener: () => Any): server.type = server.on("exit", listener) | ||
|
||
/** | ||
* The 'reset' event is emitted when the REPL's context is reset. This occurs whenever the .clear command | ||
* is received as input unless the REPL is using the default evaluator and the repl.REPLServer instance | ||
* was created with the useGlobal option set to true. The listener callback will be called with a reference | ||
* to the context object as the only argument. | ||
* @param listener The listener callback | ||
*/ | ||
@inline | ||
def onReset(listener: REPLContext => Any): server.type = server.on("reset", listener) | ||
|
||
} | ||
|
||
/** | ||
* Various behaviors of the Node.js REPL can be customized using the following environment variables: | ||
* <ul> | ||
* <li>NODE_REPL_HISTORY</li> | ||
* <li>NODE_REPL_HISTORY_SIZE</li> | ||
* <li>NODE_REPL_MODE</li> | ||
* </ul> | ||
*/ | ||
final implicit class EnvironmentVariableOptions(val env: Environment) extends AnyVal { | ||
|
||
/** | ||
* When a valid path is given, persistent REPL history will be saved to the specified file rather | ||
* than .node_repl_history in the user's home directory. Setting this value to "" will disable persistent | ||
* REPL history. Whitespace will be trimmed from the value. | ||
*/ | ||
@inline | ||
def NODE_REPL_HISTORY: Option[String] = env.get("NODE_REPL_HISTORY") | ||
|
||
/** | ||
* Previously in Node.js/io.js v2.x, REPL history was controlled by using a NODE_REPL_HISTORY_FILE environment | ||
* variable, and the history was saved in JSON format. This variable has now been deprecated, and the old | ||
* JSON REPL history file will be automatically converted to a simplified plain text format. This new file | ||
* will be saved to either the user's home directory, or a directory defined by the NODE_REPL_HISTORY variable, | ||
* as documented in the Environment Variable Options. | ||
*/ | ||
@inline | ||
@deprecated("Use NODE_REPL_HISTORY instead.", since = "3.0.0") | ||
def NODE_REPL_HISTORY_FILE: Option[String] = env.get("NODE_REPL_HISTORY_FILE") | ||
|
||
/** | ||
* Defaults to 1000. Controls how many lines of history will be persisted if history is available. | ||
* Must be a positive number. | ||
*/ | ||
@inline | ||
def NODE_REPL_HISTORY_SIZE: Option[Int] = env.get("NODE_REPL_HISTORY_SIZE").map(_.toInt) | ||
|
||
/** | ||
* May be any of sloppy, strict, or magic. Defaults to magic, which will automatically run "strict mode only" | ||
* statements in strict mode. | ||
*/ | ||
@inline | ||
def NODE_REPL_MODE: Option[String] = env.get("NODE_REPL_MODE") | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package io.scalajs.nodejs | ||
package stream | ||
|
||
import io.scalajs.util.PromiseHelper._ | ||
import io.scalajs.util.PromiseHelper.Implicits._ | ||
import io.scalajs.nodejs.buffer.Buffer | ||
import io.scalajs.nodejs.events.IEventEmitter | ||
import io.scalajs.util.PromiseHelper._ | ||
|
||
import scala.concurrent.Promise | ||
import scala.scalajs.js | ||
|
@@ -136,6 +135,24 @@ trait Writable extends IEventEmitter { | |
*/ | ||
def uncork(): Unit = 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 | ||
* @return true, if the data was handled completely | ||
* @example writable.write(chunk[, encoding][, callback]) | ||
*/ | ||
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 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: Buffer | String, encoding: String): Boolean = js.native | ||
|
||
/** | ||
* Flush all data, buffered since stream.cork() call. | ||
* @param chunk The data to write (<String> | <Buffer>) | ||
|
@@ -145,8 +162,8 @@ trait Writable extends IEventEmitter { | |
* @example writable.write(chunk[, encoding][, callback]) | ||
*/ | ||
def write(chunk: Buffer | String, | ||
encoding: String = js.native, | ||
callback: js.Function1[Error, Any] = js.native): Boolean = js.native | ||
encoding: String, | ||
callback: js.Function1[Error, Any]): Boolean = js.native | ||
|
||
} | ||
|
||
|
@@ -160,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. | ||
|
@@ -209,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, _)) | ||
|
Oops, something went wrong.