DEV Community

Discussion on: Pattern-Match your JavaScript with Z

Collapse
 
joelnet profile image
JavaScript Joel

This is incredible. I have a lot of questions regarding how this is done. I use Ramda's cond quite a bit. But I really like this syntax.

I'm curious to see how this works when minified. I believe it is using some type of reflection.

Collapse
 
kayis profile image
K

It seems to use a package called js-function-reflector which transforms a function object to it's string representation and parses it again.

github.com/arrizalamin/js-function...

Collapse
 
halcaponey_35 profile image
halcaponey

and js-function-reflector uses the toString() method availaible on functions

Thread Thread
 
joelnet profile image
JavaScript Joel

the toString()

That doesn't seem like it would work for minified code as the parameter names would be uglified.

Thread Thread
 
kayis profile image
K

It works as long as you don't compile the default arguments to ES5.