Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit ab67aa2

Browse files
authored
Merge pull request #177 from exoego/deprecation
Deprecate helper method unrelated to nodejs
2 parents 0970cd1 + 59fe665 commit ab67aa2

File tree

8 files changed

+24
-5
lines changed

8 files changed

+24
-5
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.scalajs.nodejs
2+
3+
import scala.scalajs.js
4+
5+
object TestHelper {
6+
def isDefined(obj: js.Any): Boolean = obj != null && !js.isUndefined(obj)
7+
}

app/nodejs-v10/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.scalajs.nodejs
22
package child_process
33

44
import io.scalajs.nodejs.buffer.Buffer
5-
import io.scalajs.util.ScalaJsHelper._
5+
import io.scalajs.nodejs.TestHelper._
66
import io.scalajs.util.NodeJSConverters._
77

88
import scala.concurrent.{ExecutionContext, Promise}

app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.scalajs.nodejs.fs
22

33
import io.scalajs.nodejs.setImmediate
44
import io.scalajs.util.NodeJSConverters._
5-
import io.scalajs.util.ScalaJsHelper._
5+
import io.scalajs.nodejs.TestHelper._
66

77
import scala.concurrent.{ExecutionContext, Promise}
88
import org.scalatest.funspec.AsyncFunSpec

app/nodejs-v10/src/test/scala/io/scalajs/nodejs/os/OSTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.scalajs.nodejs.os
22

3-
import io.scalajs.util.ScalaJsHelper._
3+
import io.scalajs.nodejs.TestHelper._
44
import org.scalatest.funspec.AnyFunSpec
55

66
/**

app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala

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

4-
import io.scalajs.util.JSONHelper._
54
import org.scalatest.funspec.AnyFunSpec
65

6+
import scala.scalajs.js
7+
78
/**
89
* URLObject Tests
910
*/
@@ -14,7 +15,7 @@ class URLObjectTest extends AnyFunSpec {
1415

1516
it("should break down URLs into components") {
1617
assert(
17-
urlObject.toJson === "\"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node\""
18+
js.JSON.stringify(urlObject) === "\"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node\""
1819
)
1920
// """{"protocol":"https:","slashes":true,"auth":null,"host":"www.google.com","port":null,"hostname":"www.google.com","hash":"#q=node","search":"?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","query":"sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","pathname":"/webhp","path":"/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","href":"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node"}"""
2021
}

core/src/main/scala/io/scalajs/util/DateHelper.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import scala.scalajs.js
66
/**
77
* Date Helper
88
*/
9+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
910
object DateHelper {
1011

1112
/**
1213
* Date Enrichment
1314
* @param date0 the given [[js.Date date]]
1415
*/
16+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
1517
implicit final class DateEnrichment(private val date0: js.Date) extends AnyVal {
1618
@inline
1719
def +(duration: Duration) = new js.Date(date0.getTime() + duration.toMillis)
@@ -39,6 +41,7 @@ object DateHelper {
3941
* Duration Enrichment
4042
* @param duration the given [[Duration duration]]
4143
*/
44+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
4245
implicit final class DurationEnrichment(private val duration: Duration) extends AnyVal {
4346
@inline
4447
def +(date: js.Date) = new js.Date(date.getTime() + duration.toMillis)

core/src/main/scala/io/scalajs/util/JSONHelper.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import scala.scalajs.js
55
/**
66
* JSON Helper
77
*/
8+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
89
object JSONHelper {
910

1011
/**
1112
* JSON Conversions
1213
* @param value the given JavaScript value
1314
*/
15+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
1416
implicit final class JSONConversionsToJson[T <: js.Any](val value: T) extends AnyVal {
1517
@inline
1618
def toJson: String = js.JSON.stringify(value)
@@ -23,11 +25,13 @@ object JSONHelper {
2325
* JSON Conversions
2426
* @param text the given text string
2527
*/
28+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
2629
implicit final class JSONConversionFromJson(val text: String) extends AnyVal {
2730
@inline
2831
def fromJson[T <: js.Any]: T = js.JSON.parse(text).asInstanceOf[T]
2932
}
3033

34+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
3135
implicit final class ScalaJsJSONEnrichment(val json: js.JSON.type) extends AnyVal {
3236
@inline
3337
def parseAs[T](text: String): T =

core/src/main/scala/io/scalajs/util/ScalaJsHelper.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ import scala.scalajs.js
55
/**
66
* ScalaJS Convenience Helper Functions
77
*/
8+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
89
object ScalaJsHelper {
910
////////////////////////////////////////////////////////////////////////
1011
// Convenience Functions
1112
////////////////////////////////////////////////////////////////////////
1213

14+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
1315
@inline
1416
def die[T](message: String): T = throw new IllegalStateException(message)
1517

18+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
1619
@inline
1720
def isDefined(obj: js.Any): Boolean = obj != null && !js.isUndefined(obj)
1821

@@ -24,6 +27,7 @@ object ScalaJsHelper {
2427
* js.Dynamic to Value Extensions
2528
* @param obj the given [[js.Dynamic object]]
2629
*/
30+
@deprecated("Unrelated to Node.js. Use your own extension method.", "v0.10.0")
2731
implicit final class JsAnyExtensions(val obj: js.Any) extends AnyVal {
2832
@inline
2933
def asUndefOr[T]: js.UndefOr[T] = obj.asInstanceOf[js.UndefOr[T]]

0 commit comments

Comments
 (0)