chandu0101 / macros   2016.11.0

GitHub
Scala versions: 2.12 2.11
Scala.js versions: 0.6

macros

A few helper macros

libraryDependencies += "com.github.chandu0101" %%% "macros" % "2016.11.0"

JSMacro :

It converts scala case class/class primary constructor fields to js object

Example :

 case class Test(x: String,@rename("y1") y: Int,@exclude z : String) {
   def toJS = JSMacro[Test](this)
 }
 
 > val t = Test("hello",5,"invisble")
 
 > t.toJS
 { x : "hello", y1 : 5}

***````-

FunctionMacro :

It converts function params to javascript object

Example :

 def Test(x: String,@rename("y1") y: Int,@exclude z : String): js.Object {
   val p = FunctionMacro()
   p
 }
 
 > val t = Test("hello",5,"invisible")
 
 > t
 { x : "hello", y1 : 5}