t

jshelpers

UndefOrCommon

trait UndefOrCommon[A] extends AnyRef

Add Option-like methods to js.UndefOr. Note that js.Undef.orNull exists in scala.js 1.0

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. UndefOrCommon
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def a: UndefOr[A]

Concrete Value Members

  1. def !?[B >: A](default: => B): B

    Same as .getOrElse just shorter.

    Same as .getOrElse just shorter.

    Annotations
    @inline()
  2. def ??[B >: A](default: => B): B

    Same as .getOrElse just shorter.

    Same as .getOrElse just shorter.

    Annotations
    @inline()
  3. def as[B]: UndefOr[B]

    Changes what's inside but preserves UndefOr.

  4. def filterNull: UndefOr[A]

    null => undefined, else the value remains.

  5. def filterTruthy: UndefOr[A]

    Keep the value if its truthy, otherwise return undefined.

  6. def isNull: Boolean

    Tests for overall nullness which is different than .isEmpty|.nonEmpty.

  7. def isTotalEmpty: Boolean

    This may override UndefOr.isEmpty but this checks for null as well.

  8. def toNonNullOption: Option[A]

    This could also be _.toOption.filter(_ != null) but below is slightly faster.

  9. def toNull: |[A, Null]

    Convert UndefOr[A] => A|Null

  10. def toStringJs: String

    Calls toString.

    Calls toString. I'm not sure this is needed at all.

  11. def toTruthy: Boolean

    Equivalent to !!someJSValue

  12. def toUndefOrNull: UndefOr[|[A, Null]]

    Uh-oh, thought it was js.UndefOr[A] but you need to say its a js.UndefOr[A|Null] because the docs were wrong :-).

    Uh-oh, thought it was js.UndefOr[A] but you need to say its a js.UndefOr[A|Null] because the docs were wrong :-).

    Annotations
    @inline()