trait JSDataHelpers extends AnyRef
Helpers when working with scalajs data, specifically, js.Object, js.Dynamic and js.Dictionary. Most of these mutate the input source so create a copy of the data prior to calling if you want.
- Alphabetic
- By Inheritance
- JSDataHelpers
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
deepCopy(obj: Object): Object
Slow but steady deep copy using JSON.stringify and JSON.parse.
Slow but steady deep copy using JSON.stringify and JSON.parse.
- Annotations
- @inline()
-
def
doIfDefined(obj: JsAnyDict, p: String, f: (Dictionary[Any]) ⇒ Unit): obj.type
If property is defined, do something to object, otherwise return original object.
If property is defined, do something to object, otherwise return original object. Mutating!
- Annotations
- @inline()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
getAndZap[A](j: JsAnyDict, p: String): Option[A]
Get a value in the js object and return it wrapped in
Option
.Get a value in the js object and return it wrapped in
Option
. If found, it is removed from the object, a mutating operation.- Annotations
- @inline()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
isBlank(obj: JsAnyDict, p: String): Boolean
If property is present, return true if its value is js truthy true else return false.
If property is present, return true if its value is js truthy true else return false.
- Annotations
- @inline()
-
def
isDefined(obj: Dictionary[_], p: String): Boolean
True if property is defined on the object.
True if property is defined on the object. Shouldn't we use hasOwnProperty?
- Annotations
- @inline()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
keepOnly(obj: JsAnyDict, names: String*): obj.type
- Annotations
- @inline()
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
omit(j: Dictionary[_], keys: String*): j.type
Removes keys if present.
Removes keys if present. Mutates input object. lodash naming.
- Annotations
- @inline()
-
def
omitIfMatch(j: Dictionary[_], patterns: Seq[String]): j.type
Removes keys if the field name contains the pattern substring.
Removes keys if the field name contains the pattern substring. This does not use regex.
- Annotations
- @inline()
- To do
Make this more efficient.
-
def
pruneIfBlank(obj: JsAnyDict, p: String*): obj.type
Assuming a property is a string, omit the property from the object if its blank.
Assuming a property is a string, omit the property from the object if its blank. This is a mutating action.
- Annotations
- @inline()
-
def
rename(j: JsAnyDict, renames: (String, String)*): j.type
Rename keys.
Rename keys. Mutates input object. Old keys are removed as they are moved. If a key is not found, that property is not renamed.
- Annotations
- @inline()
-
def
replaceIfBlank(obj: JsAnyDict, p: String, f: (Any) ⇒ Any): obj.type
If the property is present and is not blank, apply f to it.
If the property is present and is not blank, apply f to it.
- Annotations
- @inline()
-
def
roundAt(p: Int)(n: Double): Double
- Annotations
- @inline()
-
def
setTo(obj: JsAnyDict, p: String, value: Any): obj.type
If property is present, replace with value regardless of the current value.
If property is present, replace with value regardless of the current value.
- Annotations
- @inline()
-
def
stdConverter(keeps: Option[String], drops: Option[String], renames: Option[String]): (Object) ⇒ Object
Given some string definitions of keep, drop and rename, create a function that that mutates a js.Object.
Given some string definitions of keep, drop and rename, create a function that that mutates a js.Object. This parses the "dsl" and returns a function to perform the conversion without needing to reparse the "dsl".
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
updateObject[A](drops: Seq[String], renames: Seq[(String, String)], obj: JsAnyDict): Dictionary[Any]
Update an object.
Update an object. Mutates in place! Processng order is drops then renames.
- Annotations
- @inline()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
xfObj[A](obj: JsAnyDict, p: String, pf: PartialFunction[A, Unit]): obj.type
If property is present, apply partial function.
If property is present, apply partial function.
- Annotations
- @inline()