trait UndefOrCommon[A] extends AnyRef
Add Option-like methods to js.UndefOr. Note that js.Undef.orNull exists in scala.js 1.0
- Alphabetic
- By Inheritance
- UndefOrCommon
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def a: UndefOr[A]
Concrete Value Members
- def !?[B >: A](default: => B): B
Same as
.getOrElse
just shorter.Same as
.getOrElse
just shorter.- Annotations
- @inline()
- def ??[B >: A](default: => B): B
Same as
.getOrElse
just shorter.Same as
.getOrElse
just shorter.- Annotations
- @inline()
- def as[B]: UndefOr[B]
Changes what's inside but preserves UndefOr.
- def filterNull: UndefOr[A]
null => undefined, else the value remains.
- def filterTruthy: UndefOr[A]
Keep the value if its truthy, otherwise return undefined.
- def isNull: Boolean
Tests for overall nullness which is different than
.isEmpty|.nonEmpty
. - def isTotalEmpty: Boolean
This may override
UndefOr.isEmpty
but this checks for null as well. - def toNonNullOption: Option[A]
This could also be
_.toOption.filter(_ != null)
but below is slightly faster. - def toNull: |[A, Null]
Convert UndefOr[A] => A|Null
- def toStringJs: String
Calls toString.
Calls toString. I'm not sure this is needed at all.
- def toTruthy: Boolean
Equivalent to !!someJSValue
- def toUndefOrNull: UndefOr[|[A, Null]]
Uh-oh, thought it was
js.UndefOr[A]
but you need to say its ajs.UndefOr[A|Null]
because the docs were wrong :-).Uh-oh, thought it was
js.UndefOr[A]
but you need to say its ajs.UndefOr[A|Null]
because the docs were wrong :-).- Annotations
- @inline()