Skip to content

Commit

Permalink
Minor edits in jshelpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
aappddeevv committed Apr 5, 2024
1 parent bb776e9 commit fee90c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions components/mssql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ mssql facade at https://github.com/tediousjs/node-mssql

You can turn on debugging using `DEBUG=mssql:* node <script-that-uses-mssql>.js`.
There is also `mssql:tedi`.

Minimum known version 10.0.2
3 changes: 2 additions & 1 deletion components/mssql/src/main/scala/mssql/jsimports.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
package mssql

import scala.scalajs.js
import js.|
import js.annotation._

/** Node event emmitter. */
Expand Down Expand Up @@ -161,7 +160,9 @@ trait BaseResult extends js.Object {
/** No type constraints on the recordsets, use with care. */
@js.native
trait Result extends BaseResult {
/** The default recordset returned. */
def recordset[T]: RecordSet[T] = js.native
/** Could have more than one recordset returned, access them in the array. */
def recordsets[T]: js.Array[RecordSet[T]] = js.native
}

Expand Down
14 changes: 7 additions & 7 deletions jshelpers/src/main/scala/undefor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ object undefor:
inline private def forceGet: T = a.asInstanceOf[T]

/** Determine if is defined including the value not being null. */
@targetName("isDefinedUndefOrNull")
def isDefined: Boolean = if !js.isUndefined(a) && a != null then true else false
// @targetName("isDefinedUndefOrNull")
// def isDefined: Boolean = if !js.isUndefined(a) && a != null then true else false

/** Convenience. */
@targetName("isEmptyUndefOrNull")
def isEmpty: Boolean = !isDefined
// /** Convenience. */
// @targetName("isEmptyUndefOrNull")
// def isEmpty: Boolean = !isDefined

//def isEmpty: Boolean = !a.asInstanceOf[js.UndefOr[T]].isDefined

/** Treat null as undefined and change type from `js.UndefOr[T|Null]` to `js.UndefOr[T]`. */
@targetName("undefAbsorbUndefOrNull")
def absorbNull: js.UndefOr[T] =
if a == null then js.undefined
if js.isUndefined(a) || a == null then js.undefined
else a.asInstanceOf[js.UndefOr[T]]

/** Collapse everything at once. */
Expand All @@ -146,7 +146,7 @@ object undefor:
if a != null && a.isDefined then a.asInstanceOf[js.UndefOr[T] | Null]
else ().asInstanceOf[js.UndefOr[T] | Null]

/** Undestands UndefOr and Null to do the orElse. */
/** Understands UndefOr and Null to do the orElse. */
@targetName("getOrElseUndefOrNull")
def getOrElse[B >: T](default: => T): T =
if a == null || a.isEmpty then default else a.asInstanceOf[T]
Expand Down

0 comments on commit fee90c9

Please sign in to comment.