Skip to content

Commit

Permalink
Misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aappddeevv committed Apr 19, 2024
1 parent d07cb1e commit 827460f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/mssql/src/main/scala/mssql/jsimports.scala
Expand Up @@ -22,7 +22,7 @@
package mssql

import scala.scalajs.js
import js.annotation._
import js.annotation.*

/** Node event emmitter. */
@js.native
Expand Down
8 changes: 4 additions & 4 deletions jshelpers/src/main/scala/null.scala
Expand Up @@ -66,7 +66,7 @@ object jsnull:
/** If Null, then false, else true. */
@targetName("toTruthyOrNull")
def toTruthy: Boolean =
if js.DynamicImplicits.truthValue(a.asInstanceOf[js.Dynamic]) then true
if a != null && js.DynamicImplicits.truthValue(a.asInstanceOf[js.Dynamic]) then true
else false

/** Uh-oh, thought it was `A|Null` but you need to say its a
Expand All @@ -81,18 +81,18 @@ object jsnull:
else js.defined(forceGet)

def toTruthyUndefOr: js.UndefOr[A] =
if js.DynamicImplicits.truthValue(a.asInstanceOf[js.Dynamic]) then
if a != null && js.DynamicImplicits.truthValue(a.asInstanceOf[js.Dynamic]) then
js.defined(forceGet)
else js.undefined

def toTruthyOption: Option[A] =
if js.DynamicImplicits.truthValue(a.asInstanceOf[js.Dynamic]) then
if a != null && js.DynamicImplicits.truthValue(a.asInstanceOf[js.Dynamic]) then
Option(forceGet)
else None

@targetName("filterTruthOrNull")
def filterTruthy: A | Null =
if js.DynamicImplicits.truthValue(a.asInstanceOf[js.Dynamic]) then a
if a != null && js.DynamicImplicits.truthValue(a.asInstanceOf[js.Dynamic]) then a
else null.asInstanceOf[A | Null]

/** Absorb the null and change A|Null => A. Value could still be null,
Expand Down

0 comments on commit 827460f

Please sign in to comment.