From a2cf367dc000e0fffed2a9579fd8f6019d0cdf98 Mon Sep 17 00:00:00 2001 From: exoego Date: Mon, 24 Feb 2020 20:41:41 +0900 Subject: [PATCH] Remove deprecated utilities (not deprecated in Node.js) --- .../io/scalajs/nodejs/buffer/package.scala | 16 ------ .../io/scalajs/nodejs/os/OSConstants.scala | 5 -- .../io/scalajs/nodejs/process/Process.scala | 6 +-- .../io/scalajs/nodejs/process/package.scala | 3 -- .../io/scalajs/util/NodeJSConverters.scala | 13 ----- .../io/scalajs/nodejs/buffer/BufferTest.scala | 12 ----- .../child_process/ChildProcessTest.scala | 1 - .../scala/io/scalajs/nodejs/fs/FsTest.scala | 1 - .../scala/io/scalajs/util/DateHelper.scala | 52 ------------------- .../scala/io/scalajs/util/JSONHelper.scala | 44 ---------------- .../scala/io/scalajs/util/ScalaJsHelper.scala | 41 --------------- 11 files changed, 1 insertion(+), 193 deletions(-) delete mode 100644 app/current/src/main/scala/io/scalajs/util/NodeJSConverters.scala delete mode 100644 core/src/main/scala/io/scalajs/util/DateHelper.scala delete mode 100644 core/src/main/scala/io/scalajs/util/JSONHelper.scala delete mode 100644 core/src/main/scala/io/scalajs/util/ScalaJsHelper.scala diff --git a/app/current/src/main/scala/io/scalajs/nodejs/buffer/package.scala b/app/current/src/main/scala/io/scalajs/nodejs/buffer/package.scala index d0d4c461b..629c8fe6f 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/buffer/package.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/buffer/package.scala @@ -45,22 +45,6 @@ package object buffer { js.Iterator.IteratorOps(buffer.entries()).toIterator.flatMap(_.lastOption).map(n => f"$n%02x").mkString } - /** - * Buffer Extensions - */ - @deprecated("Use io.scalajs.nodejs.buffer package object instead", "v0.10.0") - implicit final class BufferObjExtensions(val unused: Buffer.type) extends AnyVal { - @deprecated("Use io.scalajs.nodejs.buffer.transcode instead", "v0.10.0") - def transcode(source: Uint8Array, fromEnc: String, toEnc: String): Buffer = - BufferNamespace.transcode(source, fromEnc, toEnc) - @deprecated("Use io.scalajs.nodejs.buffer.INSPECT_MAX_BYTES instead", "v0.10.0") - def INSPECT_MAX_BYTES = BufferNamespace.INSPECT_MAX_BYTES - @deprecated("Use io.scalajs.nodejs.buffer.kMaxLength instead", "v0.10.0") - def kMaxLength = BufferNamespace.kMaxLength - @deprecated("Use io.scalajs.nodejs.buffer.constants instead", "v0.10.0") - def constants = io.scalajs.nodejs.buffer.constants - } - /** * Re-encodes the given `Buffer` or `Uint8Array` instance from one character encoding to another. * Returns a new `Buffer` instance. diff --git a/app/current/src/main/scala/io/scalajs/nodejs/os/OSConstants.scala b/app/current/src/main/scala/io/scalajs/nodejs/os/OSConstants.scala index 372ac6c78..dd33fcded 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/os/OSConstants.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/os/OSConstants.scala @@ -1,14 +1,9 @@ package io.scalajs.nodejs.os import scala.scalajs.js -import scala.scalajs.js.annotation.JSBracketAccess @js.native trait OSConstants extends js.Object { - @deprecated("Use named members", "v0.10.0") - @JSBracketAccess - def apply(key: String): js.Any = js.native - val UV_UDP_REUSEADDR: Int = js.native val dlopen: OSDlopenConstants = js.native val errno: OSErrnoConstants = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala b/app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala index 949c9a341..6995f226f 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/process/Process.scala @@ -5,7 +5,7 @@ import io.scalajs.nodejs.events.IEventEmitter import io.scalajs.nodejs.tty.{ReadStream, WriteStream} import scala.scalajs.js -import scala.scalajs.js.annotation.{JSBracketAccess, JSGlobal} +import scala.scalajs.js.annotation.JSGlobal import scala.scalajs.js.| /** @@ -481,10 +481,6 @@ trait ResourceUsage extends js.Object { @js.native trait Features extends js.Object { - @deprecated("Use named members", "v0.10.0") - @JSBracketAccess - def apply(key: String): Boolean = js.native - val debug: Boolean = js.native val uv: Boolean = js.native val ipv6: Boolean = js.native diff --git a/app/current/src/main/scala/io/scalajs/nodejs/process/package.scala b/app/current/src/main/scala/io/scalajs/nodejs/process/package.scala index 37ab74a50..3aaebff69 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/process/package.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/process/package.scala @@ -13,9 +13,6 @@ package object process { type ExitCode = Int type SendHandle = net.Socket | net.Server - @deprecated("Use io.scalajs.nodejs.Error", "v0.10.0") - type Warning = Error - /** * Process Object Extensions * @param process the given [[Process process]] diff --git a/app/current/src/main/scala/io/scalajs/util/NodeJSConverters.scala b/app/current/src/main/scala/io/scalajs/util/NodeJSConverters.scala deleted file mode 100644 index 7eeab77fd..000000000 --- a/app/current/src/main/scala/io/scalajs/util/NodeJSConverters.scala +++ /dev/null @@ -1,13 +0,0 @@ -package io.scalajs.util - -import io.scalajs.nodejs.Error - -import scala.scalajs.js - -object NodeJSConverters { - @deprecated("Use io.scalajs.nodejs.ErrorExtensions", "v0.10.0") - implicit final class ErrorExtensions(val error: Error) extends AnyVal { - @inline - def toException(): Exception = js.JavaScriptException(error.message) - } -} diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala index 0b2a97277..12358ab25 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala @@ -122,30 +122,18 @@ class BufferTest extends AnyFunSpec { // package object method assert(buffer.transcode(Buffer.from("hello"), "utf8", "ascii").toString("ascii") === "hello") assert(buffer.transcode(Buffer.from("€"), "utf8", "ascii").toString("ascii") === "?") - - // extension method - assert(Buffer.transcode(Buffer.from("hello"), "utf8", "ascii").toString("ascii") === "hello") - assert(Buffer.transcode(Buffer.from("€"), "utf8", "ascii").toString("ascii") === "?") } it("should support fields") { // package object method assert(buffer.INSPECT_MAX_BYTES > 0) assert(buffer.kMaxLength > 0) - - // extension method - assert(Buffer.INSPECT_MAX_BYTES > 0) - assert(Buffer.kMaxLength > 0) } it("should support constants") { // package object method assert(buffer.constants.MAX_LENGTH > 0) assert(buffer.constants.MAX_STRING_LENGTH > 0) - - // extension method - assert(Buffer.constants.MAX_LENGTH > 0) - assert(Buffer.constants.MAX_STRING_LENGTH > 0) } } } diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala index 142bcf6ec..be8729a47 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala @@ -3,7 +3,6 @@ package child_process import io.scalajs.nodejs.buffer.Buffer import io.scalajs.nodejs.TestHelper._ -import io.scalajs.util.NodeJSConverters._ import scala.concurrent.{ExecutionContext, Promise} import scala.scalajs.js diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala index 37a0e004e..40a26f442 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala @@ -1,7 +1,6 @@ package io.scalajs.nodejs.fs import io.scalajs.nodejs.setImmediate -import io.scalajs.util.NodeJSConverters._ import io.scalajs.nodejs.TestHelper._ import scala.concurrent.{ExecutionContext, Promise} diff --git a/core/src/main/scala/io/scalajs/util/DateHelper.scala b/core/src/main/scala/io/scalajs/util/DateHelper.scala deleted file mode 100644 index f0020c7e9..000000000 --- a/core/src/main/scala/io/scalajs/util/DateHelper.scala +++ /dev/null @@ -1,52 +0,0 @@ -package io.scalajs.util - -import scala.concurrent.duration.Duration -import scala.scalajs.js - -/** - * Date Helper - */ -@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") -object DateHelper { - - /** - * Date Enrichment - * @param date0 the given [[js.Date date]] - */ - @deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") - implicit final class DateEnrichment(private val date0: js.Date) extends AnyVal { - @inline - def +(duration: Duration) = new js.Date(date0.getTime() + duration.toMillis) - - @inline - def -(duration: Duration) = new js.Date(date0.getTime() - duration.toMillis) - - @inline - def -(date1: js.Date): Double = date0.getTime() - date1.getTime() - - @inline - def >(date1: js.Date): Boolean = date0.getTime() > date1.getTime() - - @inline - def >=(date1: js.Date): Boolean = date0.getTime() >= date1.getTime() - - @inline - def <(date1: js.Date): Boolean = date0.getTime() < date1.getTime() - - @inline - def <=(date1: js.Date): Boolean = date0.getTime() <= date1.getTime() - } - - /** - * Duration Enrichment - * @param duration the given [[Duration duration]] - */ - @deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") - implicit final class DurationEnrichment(private val duration: Duration) extends AnyVal { - @inline - def +(date: js.Date) = new js.Date(date.getTime() + duration.toMillis) - - @inline - def -(date: js.Date) = new js.Date(date.getTime() - duration.toMillis) - } -} diff --git a/core/src/main/scala/io/scalajs/util/JSONHelper.scala b/core/src/main/scala/io/scalajs/util/JSONHelper.scala deleted file mode 100644 index 400200022..000000000 --- a/core/src/main/scala/io/scalajs/util/JSONHelper.scala +++ /dev/null @@ -1,44 +0,0 @@ -package io.scalajs.util - -import scala.scalajs.js - -/** - * JSON Helper - */ -@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") -object JSONHelper { - - /** - * JSON Conversions - * @param value the given JavaScript value - */ - @deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") - implicit final class JSONConversionsToJson[T <: js.Any](val value: T) extends AnyVal { - @inline - def toJson: String = js.JSON.stringify(value) - - @inline - def toPrettyJson: String = js.JSON.stringify(value, null.asInstanceOf[js.Array[js.Any]], 4) - } - - /** - * JSON Conversions - * @param text the given text string - */ - @deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") - implicit final class JSONConversionFromJson(val text: String) extends AnyVal { - @inline - def fromJson[T <: js.Any]: T = js.JSON.parse(text).asInstanceOf[T] - } - - @deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") - implicit final class ScalaJsJSONEnrichment(val json: js.JSON.type) extends AnyVal { - @inline - def parseAs[T](text: String): T = - js.JSON.parse(text).asInstanceOf[T] - - @inline - def parseAs[T](text: String, reviver: js.Function2[js.Any, js.Any, js.Any]): T = - js.JSON.parse(text, reviver).asInstanceOf[T] - } -} diff --git a/core/src/main/scala/io/scalajs/util/ScalaJsHelper.scala b/core/src/main/scala/io/scalajs/util/ScalaJsHelper.scala deleted file mode 100644 index 0e0fd537b..000000000 --- a/core/src/main/scala/io/scalajs/util/ScalaJsHelper.scala +++ /dev/null @@ -1,41 +0,0 @@ -package io.scalajs.util - -import scala.scalajs.js - -/** - * ScalaJS Convenience Helper Functions - */ -@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") -object ScalaJsHelper { - //////////////////////////////////////////////////////////////////////// - // Convenience Functions - //////////////////////////////////////////////////////////////////////// - - @deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") - @inline - def die[T](message: String): T = throw new IllegalStateException(message) - - @deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") - @inline - def isDefined(obj: js.Any): Boolean = obj != null && !js.isUndefined(obj) - - //////////////////////////////////////////////////////////////////////// - // Implicit Definitions and Classes - //////////////////////////////////////////////////////////////////////// - - /** - * js.Dynamic to Value Extensions - * @param obj the given [[js.Dynamic object]] - */ - @deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0") - implicit final class JsAnyExtensions(val obj: js.Any) extends AnyVal { - @inline - def asUndefOr[T]: js.UndefOr[T] = obj.asInstanceOf[js.UndefOr[T]] - - @inline - def asOpt[T]: Option[T] = obj.asInstanceOf[js.UndefOr[T]].toOption - - @inline - def asDynamic: js.Dynamic = obj.asInstanceOf[js.Dynamic] - } -}